/* =============================================================
   Layout — app shell, sidebar, header, login
   ============================================================= */

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; transition: grid-template-columns var(--t); }
.app.collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar { background: var(--grad-sidebar); color: var(--text-on-dark); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: var(--z-sidebar); border-inline-end: 1px solid rgba(0,0,0,.2); }

.brand { display: flex; align-items: center; gap: 11px; padding: 17px 16px; border-bottom: 1px solid rgba(250,234,201,.09); min-height: var(--header-h); }
.brand-logo { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--grad-gold); display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 4px 14px rgba(201,135,10,.4); }
.brand-logo svg { width: 23px; height: 23px; }
.brand-txt { overflow: hidden; white-space: nowrap; }
.brand-txt h1 { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; color: #FAEAC9; line-height: 1.1; }
.brand-txt span { font-size: var(--fs-xs); color: #C2A878; font-weight: 500; }
.app.collapsed .brand-txt { display: none; }

.side-scroll { flex: 1; overflow-y: auto; padding: 12px 12px 18px; }
.side-scroll::-webkit-scrollbar { width: 5px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(250,234,201,.16); }

.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 4px; }
.nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(250,234,201,.4); padding: 0 12px 8px; }
.app.collapsed .nav-label { text-align: center; font-size: 0; padding-bottom: 4px; }
.app.collapsed .nav-label::after { content: "•"; font-size: 12px; }

.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); color: rgba(250,234,201,.78); font-size: var(--fs-base); font-weight: 500; margin-bottom: 3px; position: relative; transition: var(--t-fast); cursor: pointer; }
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item .nav-name { overflow: hidden; white-space: nowrap; }
.nav-item:hover { background: rgba(250,234,201,.07); color: #FAEAC9; }
.nav-item.active { background: var(--gold-tint-2); color: #FFE7B0; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; inset-inline-end: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 22px; background: var(--gold-soft); border-radius: 3px 0 0 3px; }
[dir="ltr"] .nav-item.active::before { border-radius: 0 3px 3px 0; }
.nav-item .nav-badge { margin-inline-start: auto; background: var(--gold); color: var(--on-gold); font-size: 10px; font-weight: 800; min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--r-pill); display: grid; place-items: center; }
.app.collapsed .nav-item { justify-content: center; padding: 11px; }
.app.collapsed .nav-item .nav-name, .app.collapsed .nav-item .nav-badge { display: none; }

/* sidebar footer: connection status */
.side-foot { padding: 12px; border-top: 1px solid rgba(250,234,201,.09); }
.wa-status { display: flex; align-items: center; gap: 10px; background: rgba(46,158,91,.16); border: 1px solid rgba(46,158,91,.3); border-radius: var(--r-sm); padding: 10px 12px; }
.wa-status .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex-shrink: 0; animation: pulse 2s infinite; }
.wa-status .ws-txt { overflow: hidden; white-space: nowrap; }
.wa-status .ws-txt strong { display: block; font-size: var(--fs-sm); color: #BFE9CE; font-weight: 600; }
.wa-status .ws-txt span { font-size: var(--fs-xs); color: rgba(191,233,206,.7); }
.app.collapsed .wa-status .ws-txt { display: none; }
.app.collapsed .wa-status { justify-content: center; }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- Header ---------- */
.header { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: var(--z-header); }
.menu-toggle { display: none; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.crumb .cur { color: var(--text); font-weight: 600; }
.crumb svg { width: 14px; height: 14px; color: var(--text-3); }
.header .h-search { width: min(360px, 32vw); margin-inline-start: auto; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-actions.no-search { margin-inline-start: auto; }
.header-search-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  z-index: var(--z-dropdown);
  max-height: min(360px, 62vh);
  overflow-y: auto;
  padding: 6px;
}
.header-search-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-xs);
  color: var(--text);
  text-align: start;
  transition: var(--t-fast);
}
.header-search-item:hover,
.header-search-item.active { background: var(--gold-tint); }
.header-search-item strong {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.header-search-item small {
  display: block;
  color: var(--text-2);
  font-size: 11px;
  margin-top: 2px;
}
.header-search-url {
  color: var(--text-3);
  font-size: 11px;
  direction: ltr;
  white-space: nowrap;
}
.header-search-empty {
  padding: 10px 12px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.h-divider { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }

/* profile chip */
.profile-chip { display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 10px; border-radius: var(--r-sm); transition: var(--t); position: relative; }
[dir="ltr"] .profile-chip { padding: 5px 10px 5px 6px; }
.profile-chip:hover { background: var(--bg-2); }
.profile-chip .pc-txt { text-align: end; line-height: 1.2; }
.profile-chip .pc-txt strong { font-size: var(--fs-sm); font-weight: 600; display: block; }
.profile-chip .pc-txt span { font-size: var(--fs-xs); color: var(--text-2); }
.profile-chip .pc-av { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--grad-gold); display: grid; place-items: center; color: var(--on-gold); font-weight: 800; }
@media (max-width: 720px) { .profile-chip .pc-txt { display: none; } }

/* notification dropdown */
.notif-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 10px); width: 360px; max-width: 88vw; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-lg); z-index: var(--z-dropdown); animation: pop var(--t-fast) both; overflow: hidden; }
.notif-panel .np-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif-panel .np-head h4 { font-size: var(--fs-md); }
.notif-panel .np-head button { font-size: var(--fs-xs); color: var(--gold-deep); font-weight: 600; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-row { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); transition: var(--t-fast); cursor: pointer; }
.notif-row:hover { background: var(--bg-2); }
.notif-row.unread { background: var(--gold-tint); }
.notif-row .nic { width: 36px; height: 36px; border-radius: var(--r-xs); display: grid; place-items: center; flex-shrink: 0; }
.notif-row .nic svg { width: 16px; height: 16px; }
.nic.ic-ai { background: var(--ai-tint); color: var(--ai); }
.nic.ic-green { background: var(--green-tint); color: var(--green); }
.nic.ic-gold { background: var(--gold-tint); color: var(--gold-deep); }
.nic.ic-blue { background: var(--blue-tint); color: var(--blue); }
.nic.ic-red { background: var(--red-tint); color: var(--red); }
.notif-row .nr-txt strong { font-size: var(--fs-sm); font-weight: 600; display: block; }
.notif-row .nr-txt p { font-size: var(--fs-xs); color: var(--text-2); margin: 2px 0; line-height: 1.5; }
.notif-row .nr-txt time { font-size: 10.5px; color: var(--text-3); }
.np-foot { padding: 11px; text-align: center; }
.np-foot button { font-size: var(--fs-sm); color: var(--gold-deep); font-weight: 600; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 24px 22px 40px; overflow-x: hidden; min-height: 0; }
.content.flush { padding: 0; overflow: hidden; }
.container { max-width: var(--maxw); margin: 0 auto; }
.page { display: none; animation: fadeIn var(--t) both; }
.page.active { display: block; }

/* grids */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .span-2 { grid-column: span 1; } }
/* phones: collapse any 2-col layout to a single column, even when inline styles set them */
@media (max-width: 720px) { .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; } }

/* ---------- Mobile sidebar + tight header ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(30,19,8,.5); z-index: calc(var(--z-sidebar) - 1); }
@media (max-width: 920px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  /* RTL: sidebar comes from the right (inline-end); LTR: from the left. */
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w); transform: translateX(calc(-110% * var(--dir, 1))); transition: transform var(--t); box-shadow: var(--sh-lg); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; }
  .menu-toggle { display: inline-flex; }
  .header { padding: 0 12px; gap: 8px; }
  .header .h-search { width: auto; flex: 1; min-width: 0; }
  .header .h-search input { font-size: var(--fs-xs); }
  .crumb { font-size: var(--fs-xs); }
  .h-divider { display: none; }
  .content { padding: 16px 14px 28px; }
  .page-head h2 { font-size: var(--fs-xl); }
  .page-head p { font-size: var(--fs-sm); }
}
@media (max-width: 560px) {
  .header { padding: 0 10px; gap: 4px; }
  .header .h-search { display: none; }   /* tight phones: hide global search, keep page-level search */
  .crumb > span:first-child { display: none; }   /* drop the brand prefix; keep current page */
  .crumb svg { display: none; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .pc-av { width: 32px !important; height: 32px !important; }
  .content { padding: 14px 12px 24px; }
}

/* =============================================================
   Login (split screen)
   ============================================================= */
.login { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.login-hero { background: var(--grad-hero); color: var(--text-on-dark); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 48px 54px; }
.login-hero::before { content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(circle, rgba(201,135,10,.34), transparent 70%); top: -120px; inset-inline-end: -120px; }
.login-hero::after { content: ""; position: absolute; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(224,165,43,.22), transparent 70%); bottom: -120px; inset-inline-start: -80px; animation: pulse 6s ease-in-out infinite; }
/* honeycomb texture */
.hero-comb { position: absolute; inset: 0; opacity: .07; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 0l28 16v32L28 64 0 48V16zM28 64l28 16v32L28 128 0 112V80z' fill='none' stroke='%23FAEAC9' stroke-width='2'/%3E%3C/svg%3E"); background-size: 56px auto; }
.login-hero > * { position: relative; z-index: 1; }
.lh-top { display: flex; align-items: center; gap: 13px; }
.lh-logo { width: 52px; height: 52px; border-radius: var(--r-md); background: var(--grad-gold); display: grid; place-items: center; box-shadow: var(--sh-gold); }
.lh-logo svg { width: 30px; height: 30px; }
.lh-top h1 { font-family: var(--font-display); font-size: var(--fs-2xl); color: #FAEAC9; }
.lh-top span { font-size: var(--fs-sm); color: #C2A878; display: block; }
.lh-mid { max-width: 440px; }
.lh-tag { display: inline-flex; align-items: center; gap: 7px; background: var(--gold-tint-2); border: 1px solid rgba(224,165,43,.4); color: #FFE7B0; font-size: var(--fs-xs); font-weight: 600; padding: 6px 13px; border-radius: var(--r-pill); margin-bottom: 22px; }
.lh-mid h2 { font-family: var(--font-display); font-size: 34px; line-height: 1.3; color: #FFF3DC; margin-bottom: 14px; }
[dir="ltr"] .lh-mid h2 { font-family: var(--font-latin-display); }
.lh-mid > p { color: rgba(250,234,201,.72); font-size: var(--fs-md); line-height: 1.7; }
.lh-feats { margin-top: 30px; display: flex; flex-direction: column; gap: 15px; }
.lh-feats li { display: flex; align-items: center; gap: 13px; font-size: var(--fs-base); color: rgba(250,234,201,.9); }
.lh-feats .fic { width: 36px; height: 36px; border-radius: var(--r-sm); background: rgba(250,234,201,.1); border: 1px solid rgba(250,234,201,.16); display: grid; place-items: center; color: var(--gold-soft); flex-shrink: 0; }
.lh-feats .fic svg { width: 18px; height: 18px; }
.lh-foot { font-size: var(--fs-xs); color: rgba(250,234,201,.5); }

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); position: relative; }
.login-top-actions { position: absolute; top: 22px; inset-inline-end: 26px; display: flex; gap: 6px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .lc-head { margin-bottom: 26px; }
.login-card .lc-head h3 { font-size: var(--fs-2xl); font-family: var(--font-display); }
[dir="ltr"] .login-card .lc-head h3 { font-family: var(--font-latin-display); }
.login-card .lc-head p { color: var(--text-2); margin-top: 5px; }
.login-row { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 18px; }
.login-row label { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.login-row label input { accent-color: var(--gold); width: 15px; height: 15px; }
.login-row a { font-size: var(--fs-sm); color: var(--gold-deep); font-weight: 600; }
.login-demo { margin-top: 22px; padding: 13px 15px; background: var(--gold-tint); border: 1px dashed var(--gold); border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--gold-deep); line-height: 1.7; }
.login-demo strong { color: var(--text); }

/* password field: input + separate eye toggle (sits OUTSIDE the input, on inline-end) */
.pass-wrap { display: flex; align-items: stretch; gap: 8px; }
.pass-eye { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: var(--r-sm); flex-shrink: 0; color: var(--text-3); }
.pass-eye:hover { color: var(--gold-deep); border-color: var(--gold); background: var(--gold-tint); }

/* =============================================================
   Mobile login — clean, calm, focused.
   Design principles:
   • One ambient accent (a soft gold radial glow behind the logo) — nothing else competing
   • Consistent 24px horizontal padding everywhere
   • Clear vertical rhythm: brand block, card, footer with breathing room between
   • The gold "دخول" button is the single point of focus
   ============================================================= */
@media (min-width: 881px) {
  .login-form-side .mob-brand { display: none; }
}
@media (max-width: 880px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }

  .login-form-side {
    padding: 0;
    background: var(--bg);
    display: flex; flex-direction: column;
    min-height: 100vh;
    position: relative; overflow: hidden;
  }
  /* one soft gold halo behind the logo — quiet, branded */
  .login-form-side::before {
    content: ""; position: absolute; top: -120px; inset-inline-start: 50%;
    transform: translateX(-50%);
    width: 460px; height: 460px; border-radius: 50%;
    background: radial-gradient(circle, rgba(201,135,10,.18), transparent 65%);
    z-index: 0; pointer-events: none;
  }

  /* top utility row — lang/theme toggles */
  .login-top-actions {
    position: relative; inset: auto;
    padding: 16px 24px 0;
    display: flex; justify-content: flex-end; gap: 6px;
    z-index: 2;
  }

  /* brand block — logo + name + tagline */
  .login-form-side .mob-brand {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; padding: 24px 24px 4px;
    z-index: 2; position: relative; text-align: center;
  }
  .login-form-side .mob-brand .mb-logo {
    width: 64px; height: 64px; border-radius: 18px;
    background: var(--grad-gold);
    display: grid; place-items: center;
    box-shadow: 0 10px 30px rgba(201,135,10,.30), 0 2px 6px rgba(201,135,10,.20);
  }
  .login-form-side .mob-brand .mb-logo svg { width: 32px; height: 32px; }
  .login-form-side .mob-brand h1 {
    font-family: var(--font-display); font-size: 22px; font-weight: 700;
    color: var(--text); margin-top: 4px;
  }
  .login-form-side .mob-brand span {
    font-size: var(--fs-xs); color: var(--text-2); letter-spacing: .02em;
  }

  /* the card itself */
  .login-card {
    margin: 28px 24px 0;
    padding: 28px 22px 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(58, 38, 17, .06);
    z-index: 2; max-width: none;
  }
  .login-card .lc-head { margin-bottom: 22px; text-align: start; }
  .login-card .lc-head h3 { font-size: 22px; font-weight: 700; color: var(--text); }
  .login-card .lc-head p { color: var(--text-2); font-size: var(--fs-sm); margin-top: 6px; }

  /* footer line */
  .login-form-side::after {
    content: "© 2026 سبا · Saba Land"; display: block;
    margin: 28px 24px 18px; text-align: center;
    font-size: var(--fs-xs); color: var(--text-3); letter-spacing: .02em;
    z-index: 2; position: relative;
  }
  [dir="ltr"] .login-form-side::after { content: "© 2026 Saba Land"; }
}

/* very small phones (iPhone SE-era) — tighten a hair, but keep the same rhythm */
@media (max-width: 380px) {
  .login-top-actions { padding: 14px 20px 0; }
  .login-form-side .mob-brand { padding: 20px 20px 4px; }
  .login-card { margin: 24px 20px 0; padding: 24px 18px 22px; }
  .login-form-side::after { margin: 24px 20px 16px; }
}
