/* ============================================================
   LAYOUT.CSS - Sidebar, Navbar, Main, Auth wrapper
   ============================================================ */

/* ---------- Shell Dashboard ---------- */
.app-shell { min-height: 100vh; display: flex; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, var(--bg-app) 100%);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  z-index: 1040;
  transition: width var(--transition), transform var(--transition);
}
.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.05rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  min-height: var(--navbar-h);
}
.brand-logo {
  width: 42px; height: 42px; flex: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  display: grid; place-items: center;
  color: #1c1813; font-weight: 800; font-size: 1.05rem;
  box-shadow: var(--shadow-gold);
}
.brand-text { line-height: 1.15; }
.brand-text .name { color: var(--text-strong); font-weight: 800; font-size: 1rem; }
.brand-text .ver { color: var(--gold); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: .85rem .7rem 1.2rem; }
.nav-section-label {
  font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); padding: 1rem .8rem .4rem; font-weight: 700;
}
.nav-link-app {
  display: flex; align-items: center; gap: .8rem;
  padding: .68rem .85rem; margin-bottom: .15rem;
  color: var(--text-muted); border-radius: var(--radius-sm);
  font-weight: 500; font-size: .9rem;
  transition: all var(--transition); position: relative;
}
.nav-link-app svg { width: 20px; height: 20px; flex: none; }
.nav-link-app:hover { background: var(--bg-hover); color: var(--text-strong); }
.nav-link-app.active {
  background: linear-gradient(90deg, var(--gold-glow), transparent);
  color: var(--gold);
}
.nav-link-app.active::before {
  content: ''; position: absolute; left: 0; top: 18%; bottom: 18%;
  width: 3px; border-radius: 0 4px 4px 0; background: var(--gold);
}
.sidebar-footer { padding: .8rem .85rem; border-top: 1px solid var(--border-soft); }

/* ---------- Main ---------- */
.main-area { flex: 1 1 auto; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left var(--transition); }

/* ---------- Top Navbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--navbar-h);
  background: rgba(28,24,19,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem;
}
.topbar .menu-toggle { display: none; background: none; border: 0; color: var(--text-muted); cursor: pointer; }
.topbar-search {
  flex: 0 1 360px; position: relative;
}
.topbar-search input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 999px; color: var(--text-body); padding: .5rem 1rem .5rem 2.4rem;
}
.topbar-search svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-faint); }

/* ---------- Search dropdown ---------- */
.topbar-search { position: relative; }
.search-box {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; z-index: 1100;
}
.search-box.show { display: block; }
.search-item {
  display: flex; align-items: center; gap: .6rem; padding: .65rem .85rem;
  color: var(--text-body); text-decoration: none; border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition);
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover { background: var(--bg-hover); }
.search-item span { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.search-item b { color: var(--text-strong); font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item small { color: var(--text-faint); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-loading, .search-empty { color: var(--text-faint); font-size: .82rem; justify-content: center; }
.topbar-spacer { flex: 1 1 auto; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-muted);
  cursor: pointer; transition: all var(--transition); position: relative;
}
.icon-btn:hover { color: var(--gold); border-color: var(--gold-dim); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg-sidebar); }

/* User chip */
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .3rem .35rem .3rem .7rem; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-color); cursor: pointer; }
.user-chip:hover { border-color: var(--gold-dim); }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #1c1813; background: linear-gradient(135deg, var(--gold-soft), var(--gold-dim)); }
.user-chip .who { line-height: 1.1; }
.user-chip .who .nm { color: var(--text-strong); font-weight: 600; font-size: .85rem; }
.user-chip .who .rl { color: var(--text-faint); font-size: .72rem; text-transform: capitalize; }

/* ---------- Content ---------- */
.content { padding: 1.5rem 1.4rem 2.5rem; flex: 1 1 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }

/* ---------- Footer copyright ---------- */
.app-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: .4rem; flex-wrap: wrap;
  padding: .75rem 1.4rem; font-size: .75rem; color: var(--text-muted);
  border-top: 1px solid var(--border-color); flex: none;
}
.app-footer__sep { color: var(--gold-dim); }
.app-footer--auth { border-top: none; justify-content: center; padding: 1rem .5rem .25rem; }

/* ---------- Auth Layout (Login) ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
  background: var(--bg-app);
}
.auth-visual {
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(212,175,55,.18), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(59,158,255,.12), transparent 55%),
    linear-gradient(160deg, #211b13 0%, #16130f 70%);
  background-size: 200% 200%;
  animation: auth-bg-shift 18s ease infinite;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 2.5rem; border-right: 1px solid var(--border-color);
}
@keyframes auth-bg-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.auth-visual > :not(.auth-orb):not(.auth-grid) { position: relative; z-index: 2; }

/* Orbs beranimasi (cahaya melayang) */
.auth-orb {
  position: absolute; border-radius: 50%; filter: blur(50px);
  opacity: .45; pointer-events: none; z-index: 1;
}
.auth-orb--1 {
  width: 320px; height: 320px; top: -60px; right: -40px;
  background: radial-gradient(circle, rgba(212,175,55,.55), transparent 70%);
  animation: orb-float-a 14s ease-in-out infinite;
}
.auth-orb--2 {
  width: 260px; height: 260px; bottom: 8%; left: -80px;
  background: radial-gradient(circle, rgba(59,158,255,.4), transparent 70%);
  animation: orb-float-b 17s ease-in-out infinite;
}
.auth-orb--3 {
  width: 180px; height: 180px; top: 45%; right: 15%;
  background: radial-gradient(circle, rgba(212,175,55,.3), transparent 70%);
  animation: orb-float-c 11s ease-in-out infinite;
}
@keyframes orb-float-a {
  0%, 100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(-40px, 50px) scale(1.15); }
}
@keyframes orb-float-b {
  0%, 100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(50px, -40px) scale(1.1); }
}
@keyframes orb-float-c {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(-30px, -25px) scale(1.2); }
  66%      { transform: translate(35px, 30px) scale(.9); }
}

/* Grid dekoratif berpendar */
.auth-grid {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(212,175,55,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,175,55,.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 75%);
  animation: grid-pan 30s linear infinite;
}
@keyframes grid-pan {
  0%   { background-position: 0 0, 0 0; }
  100% { background-position: 44px 44px, 44px 44px; }
}

/* Entrance: fade + slide up dengan delay per item */
.auth-anim {
  opacity: 0;
  animation: auth-fade-up .7s cubic-bezier(.22,.61,.36,1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes auth-fade-up {
  0%   { opacity: 0; transform: translateY(24px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Efek shimmer pada teks gold */
.auth-shimmer {
  background: linear-gradient(100deg, var(--gold) 20%, #fff7dc 40%, var(--gold) 60%, var(--gold-dim) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: shimmer-pan 5s linear infinite;
}
@keyframes shimmer-pan {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Logo pulse lembut */
.logo-row .brand-logo { animation: logo-glow 4s ease-in-out infinite; }
@keyframes logo-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,175,55,0); }
  50%      { box-shadow: 0 0 22px 4px rgba(212,175,55,.28); }
}

/* Aksesibilitas: matikan animasi bila user memilih reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .auth-visual,
  .auth-orb, .auth-grid, .auth-anim,
  .auth-shimmer, .logo-row .brand-logo {
    animation: none !important;
  }
  .auth-anim { opacity: 1 !important; transform: none !important; }
}

.auth-visual .logo-row { display: flex; align-items: center; gap: .8rem; }
.auth-visual h1 { font-size: 2rem; line-height: 1.25; max-width: 24ch; }
.auth-visual .lead { color: var(--text-muted); max-width: 42ch; }
.auth-visual .feat { display: flex; gap: 1.4rem; flex-wrap: wrap; color: var(--text-muted); font-size: .85rem; }
.auth-visual .feat span { display: inline-flex; align-items: center; gap: .4rem; }
.auth-form-side { display: grid; place-items: center; padding: 2rem 1.4rem; }
.auth-card { width: 100%; max-width: 410px; }

/* ---------- Login disclaimer ---------- */
.login-disclaimer {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-surface);
  overflow: hidden;
}
.login-disclaimer__head {
  display: flex; align-items: center; gap: .45rem;
  padding: .5rem .7rem; cursor: pointer; user-select: none;
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  transition: color var(--transition);
}
.login-disclaimer__head:hover { color: var(--gold); }
.login-disclaimer__icon {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  background: var(--gold-glow); color: var(--gold);
}
.login-disclaimer__title { flex: 1; }
.login-disclaimer__caret { transition: transform var(--transition); }
.login-disclaimer__head[aria-expanded="true"] .login-disclaimer__caret { transform: rotate(180deg); }
.login-disclaimer__head[aria-expanded="true"] { color: var(--gold); border-bottom: 1px solid var(--border-color); }
.login-disclaimer__body {
  padding: .7rem .85rem;
  color: var(--text-muted); line-height: 1.5;
}
.login-disclaimer__body strong { color: var(--text-body); font-weight: 600; }
.auth-glow {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5;
  pointer-events: none;
}

/* ---------- Sidebar collapsed (desktop toggle) ---------- */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-c); }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-section-label,
body.sidebar-collapsed .sidebar .nav-link-app span,
body.sidebar-collapsed .sidebar .sidebar-footer { display: none; }
body.sidebar-collapsed .main-area { margin-left: var(--sidebar-w-c); }

/* ---------- Responsive ---------- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .topbar .menu-toggle { display: grid; place-items: center; }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1035;
  }
}
@media (max-width: 767.98px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

/* ---------- Bottom Navigation (mobile only) ---------- */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
  .main-area { padding-bottom: 70px; }
  body.sidebar-open .bottom-nav { display: none; }
  .bottom-nav {
    display: flex; align-items: flex-end; justify-content: space-around;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1032;
    height: 64px; padding: 0 .2rem env(safe-area-inset-bottom, 0);
    background: rgba(28,24,19,.97); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
  }
  .bn-item {
    flex: 1 1 0; min-width: 0; position: relative; height: 64px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-muted); text-decoration: none; padding: 0; cursor: pointer;
    background: none; border: 0; font-size: .64rem; line-height: 1; font-weight: 600;
  }
  .bn-item .bn-ic { display: grid; place-items: center; height: 24px; }
  .bn-item .bn-ic svg { width: 22px; height: 22px; }
  .bn-item .bn-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bn-item.bn-dropup .bn-toggle {
    width: 100%; height: 100%; background: none; border: 0; color: inherit;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: .64rem; font-weight: 600; padding: 0; cursor: pointer;
  }
  .bn-item.active { color: var(--gold); }
  .bn-item.active::before {
    content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    border-radius: 0 0 4px 4px; background: var(--gold);
  }

  /* Item menonjol (tengah) */
  .bn-item.bn-prominent { justify-content: flex-end; }
  .bn-item.bn-prominent .bn-ic {
    position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
    color: #1c1813; border: 3px solid var(--bg-sidebar);
    box-shadow: var(--shadow-gold);
  }
  .bn-item.bn-prominent .bn-ic svg { width: 24px; height: 24px; color: #1c1813; }
  .bn-item.bn-prominent .bn-lbl { position: absolute; bottom: 7px; left: 0; right: 0; text-align: center; }
  .bn-item.bn-prominent.active::before { display: none; }
  .bn-item.bn-prominent.active { color: var(--gold); }

  /* Popup menu (dropup) */
  .bn-menu {
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .35rem; min-width: 200px; margin-bottom: 8px;
  }
  .bn-sub {
    display: flex; align-items: center; gap: .6rem;
    color: var(--text-body); border-radius: var(--radius-sm);
    padding: .58rem .65rem; font-size: .82rem; font-weight: 500;
  }
  .bn-sub svg { width: 17px; height: 17px; color: var(--gold); flex: none; }
  .bn-sub:hover, .bn-sub:focus, .bn-sub.active { background: var(--bg-hover); color: var(--gold); }
  .bn-sub.active svg { color: var(--gold); }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .sidebar-backdrop, .page-head, .bottom-nav,
  #btnDownloadQr, #btnPrint,
  button[onclick="window.print()"] { display: none !important; }
  .main-area { margin-left: 0 !important; padding-bottom: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card-app { border: 1px solid #ccc !important; box-shadow: none !important; }
  /* Kartu Dapur */
  #kartuCard { max-width: 100% !important; border: 2px solid #999 !important; }
  #kartuCard h4, #kartuCard .fw-600 { color: #1c1813 !important; }
  #kartuCard .text-gold { color: #a98c2c !important; }
  #kartuCard .text-muted-2 { color: #666 !important; }
  #qrKartu { background: #fff !important; }
  .badge-app { border: 1px solid #999 !important; color: #333 !important; }
  @page { margin: 1cm; }
}
