/* ===== Nalar CMS — theme tokens & base layout ===== */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --brand: #1C79BA;
  --brand-hover: #166398;
  --brand-text: #1C79BA;
  --brand-soft: #e8f3fa;

  --bg: #f7f8fa;
  --surface: #f1f3f5;
  --surface-hover: #e7eaed;
  --border: #e6e8eb;
  --border-strong: #d3d7dc;

  --text-primary: #16191d;
  --text-secondary: #5c6470;
  --text-tertiary: #96a0aa;

  --blue: #3b82f6;      --blue-soft: #eaf1ff;
  --emerald: #10b981;   --emerald-soft: #e7faf1;
  --amber: #ea9a1a;     --amber-soft: #fdf3e2;
  --purple: #8b5cf6;    --purple-soft: #f2edfd;
  --pink: #ec4899;      --pink-soft: #fdeef5;
  --teal: #14b8a6;      --teal-soft: #e7f9f6;
  --red: #ef4444;       --red-soft: #fdeeee;
  --slate: #667085;     --slate-soft: #eef0f3;
  --indigo: #6366f1;    --indigo-soft: #eceeff;

  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 10px;
  --r-full: 999px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 32, 0.05);
  --shadow-sm: 0 2px 5px rgba(16, 24, 32, 0.06);
  --shadow-md: 0 6px 16px rgba(16, 24, 32, 0.08);
  --shadow-lg: 0 14px 32px rgba(16, 24, 32, 0.12);

  --sidebar-w: 212px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(239, 68, 68, 0.07), transparent 32%),
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.07), transparent 32%),
    radial-gradient(circle at 0% 100%, rgba(13, 118, 184, 0.08), transparent 32%),
    radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.06), transparent 32%);
  background-attachment: fixed;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--brand-text); text-decoration: none; }
a:not(.btn):hover { color: var(--brand-hover); text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.flash-banner { margin-bottom:14px; padding:11px 14px; border-radius:var(--r-md); font-size:12.5px; line-height:1.5; }
.flash-banner.success { background:var(--emerald-soft); color:#047857; border:1px solid #a7f3d0; }
.flash-banner.error { background:var(--red-soft); color:#b91c1c; border:1px solid #fecaca; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

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

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
  transition: width 0.16s ease, transform 0.16s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 13px 14px; border-bottom: 1px solid var(--border); }
.sidebar-brand .mark {
  width: 26px; height: 26px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px;
}
.sidebar-brand .brand-mark {
  width: 26px; height: 26px; border-radius: var(--r-sm); flex-shrink: 0;
  display: none; object-fit: cover;
}
.sidebar-brand .brand-wordmark {
  height: 22px; width: auto; max-width: 120px; object-fit: contain;
  display: block; flex-shrink: 1;
}
.sidebar-brand span { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; }
.sidebar-collapse-btn { margin-left: auto; width: 22px; height: 22px; border-radius: var(--r-sm); border: none; background: transparent; color: var(--text-tertiary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-collapse-btn svg { width: 14px; height: 14px; }
.sidebar-collapse-btn:hover { background: var(--surface); color: var(--text-primary); }

.site-switcher { position: relative; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.site-switcher-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: #fff;
  color: var(--text-primary); font-size: 12.5px; font-weight: 600; text-align: left;
}
.site-switcher-btn svg { width: 14px; height: 14px; color: var(--text-tertiary); flex-shrink: 0; }
.site-switcher-btn svg:last-child { margin-left: auto; }
.site-switcher-btn:hover { border-color: var(--border-strong); background: var(--surface); }
.site-switcher-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.site-switcher-menu { left: 10px; right: 10px; top: calc(100% - 4px); width: auto; }
.site-switcher-menu .menu-item { position: relative; }
.site-switcher-menu .menu-item.active { background: var(--brand-soft); color: var(--brand-text); }
.site-switcher-check { margin-left: auto; display: flex; }
.site-switcher-check svg { width: 14px; height: 14px; color: var(--brand-text); }
.sidebar.collapsed .site-switcher { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav-section-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-tertiary); padding: 12px 8px 5px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--r-sm);
  color: var(--text-secondary); font-weight: 500; font-size: 12.5px; white-space: nowrap;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: var(--r-md); }
.sidebar-user:hover { background: var(--surface); }
.sidebar-user .name { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.sidebar-user .role { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .sidebar-brand { flex-direction: column; justify-content: center; gap: 8px; padding: 12px 6px; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-brand .brand-wordmark,
.sidebar.collapsed .nav-section-label, .sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-user .name, .sidebar.collapsed .sidebar-user .role { display: none; }
.sidebar.collapsed .sidebar-brand .brand-mark { display: block; }
.sidebar.collapsed .sidebar-collapse-btn { margin-left: 0; }
.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar.collapsed .sidebar-user { justify-content: center; }

.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h);
  background: rgba(247, 248, 250, 0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px; z-index: 30;
  transition: left 0.16s ease;
}
.topbar-crumb { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.topbar-crumb .site-pill { display:flex; align-items:center; gap:5px; font-weight:600; color: var(--text-primary); background:#fff; border:1px solid var(--border); padding:5px 9px; border-radius: var(--r-full); }
.topbar-crumb .site-pill svg { width: 12px; height: 12px; color: var(--text-tertiary); }
.topbar-crumb .sep { color: var(--text-tertiary); }
.topbar-crumb .page-name { color: var(--text-secondary); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-actions .topbar-search { margin: 0; border: none; }
.topbar-actions .btn-sm { white-space: nowrap; }
.topbar-actions .btn-sm svg { width: 13px; height: 13px; }
.popover-wrap { position: relative; }
.topbar-icon-btn {
  width: 30px; height: 30px; border-radius: var(--r-full); border: 1px solid transparent; background: transparent;
  display: flex; align-items: center; justify-content: center; color: var(--text-secondary); position: relative;
}
.topbar-icon-btn svg { width: 15px; height: 15px; }
.topbar-icon-btn:hover { background: var(--surface); }
.topbar-icon-btn .dot { position:absolute; top:5px; right:6px; width:6px; height:6px; border-radius:50%; background: var(--red); border: 1.5px solid #fff; }
.hamburger-btn { display: none; }
.sidebar-overlay { display: none; }

.search-menu { padding: 8px; }
.notif-menu { padding: 0; }
.notif-head { padding: 9px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 12px; }
.notif-list { max-height: 280px; overflow-y: auto; }
.notif-item { display: flex; gap: 9px; align-items: flex-start; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface); }
.notif-item .notif-icon { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item .notif-icon svg { width: 13px; height: 13px; }
.notif-text { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.notif-text b { color: var(--text-primary); font-weight: 600; }
.notif-time { font-size: 10.5px; color: var(--text-tertiary); margin-top: 2px; }
.notif-foot { display: flex; justify-content: center; padding: 9px; border-top: 1px solid var(--border); font-size: 11.5px; font-weight: 600; }

.user-menu-wrap { position: relative; }
.user-menu-trigger { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: var(--r-full); background: transparent; border: none; }
.user-menu-trigger:hover { background: var(--surface); }

.content { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); flex: 1; min-width: 0; transition: margin-left 0.16s ease; }
.content-inner { padding: 18px 20px 44px; max-width: 1360px; }

body.sidebar-collapsed .content { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .topbar { left: var(--sidebar-w-collapsed); }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(16,24,32,0.35); z-index: 35; }
  .topbar, body.sidebar-collapsed .topbar { left: 0; }
  .content, body.sidebar-collapsed .content { margin-left: 0; }
  .hamburger-btn { display: flex; }
  .topbar-crumb .site-pill span { display: none; }
}
