/* Zimmam platform — base styles.
   Layout uses CSS logical properties (inline-start/end), so <html dir="rtl">
   mirrors everything without a separate RTL stylesheet. Palette = Zimmam brand tokens. */

:root {
  --bg: #F1ECE3;
  --surface: #FFFFFF;
  --surface-2: #E8E2D6;
  --border: #D9D1C2;
  --primary: #1F2A33;
  --primary-ink: #FFFFFF;
  --accent: #C49A6C;
  --text: #14181C;
  --muted: #5D6670;
  --success: #2D5F4F;
  --warning: #B68A1F;
  --danger: #9B2C2C;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .06), 0 4px 16px rgba(20, 24, 28, .06);
  --sidebar-w: 248px;
  --font-latin: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'Readex Pro', 'Geist', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-latin);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-family: var(--font-ar); }

a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: .875rem; font-weight: 500; margin-block-end: .35rem; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .75rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.field { margin-block-end: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--primary); border-radius: 8px;
  background: var(--primary); color: var(--primary-ink);
  padding: .55rem 1rem; min-height: 40px; text-decoration: none;
}
.btn:hover { filter: brightness(1.15); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: .3rem .65rem; min-height: 32px; font-size: .85rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary);
  text-decoration: underline; cursor: pointer; }
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.3em; margin-block: .25rem .75rem; }
.form-note  { color: var(--success); font-size: .9rem; }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow); padding: 28px 24px;
}
.auth-brand { display: flex; align-items: center; justify-content: space-between; margin-block-end: 1.25rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 6px; background: var(--primary);
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 6px;
}
.brand-mark i { background: var(--bg); border-radius: 1px; }
.brand-mark i:nth-child(2) { background: var(--accent); }
.qr { display: grid; place-items: center; margin-block: 1rem; }
.qr img { width: 200px; height: 200px; background: #fff; }
.secret { font-family: ui-monospace, monospace; font-size: .85rem; word-break: break-all;
  background: var(--surface-2); padding: .5rem; border-radius: 6px; direction: ltr; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; }
.sidebar {
  background: var(--primary); color: #E9EDF0; display: flex; flex-direction: column;
  padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; padding: 0 8px 18px; }
.sidebar .brand-mark { background: #2E3B46; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: .55rem .75rem; border-radius: 8px; color: inherit; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: #fff;
  box-shadow: inset 3px 0 0 var(--accent); }
html[dir="rtl"] .nav a[aria-current="page"] { box-shadow: inset -3px 0 0 var(--accent); }
.sidebar-foot { margin-block-start: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1);
  font-size: .85rem; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot .role { color: #AEB7BF; margin-block-end: .6rem; }
.sidebar-foot .btn { border-color: rgba(255,255,255,.3); color: #fff; background: transparent; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.menu-btn { display: none; }
.content { padding: 24px 28px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.placeholder { text-align: center; padding: 56px 20px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-block-end: 16px;
  overflow-x: auto; }
.tabs button {
  font: inherit; background: none; border: 0; padding: .6rem .9rem; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-block-end: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: .6rem .7rem; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
html[lang="ar"] th { text-transform: none; letter-spacing: 0; }
td select { width: auto; padding: .3rem .5rem; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill-ok { background: #DCE9E3; color: var(--success); }
.pill-warn { background: #F3E8C9; color: #7A5C10; }
.pill-off { background: #F1DCDC; color: var(--danger); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

dialog { border: 0; border-radius: 14px; box-shadow: var(--shadow); padding: 24px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 24, 28, .45); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-block-start: 8px; }

.toasts { position: fixed; inset-block-end: 16px; inset-inline-end: 16px; display: flex;
  flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--primary); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow);
  max-width: 360px; }
.toast-error { background: var(--danger); }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar-w); z-index: 50;
    transform: translateX(-100%); transition: transform .2s;
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-inline: 16px; }
}
.topbar-start { display: flex; align-items: center; gap: 10px; }
