/* ==========================================================================
   Base + Layout — Sidebar, Header, Content Shell, Mobile Nav
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-slate-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------------------
   App Shell
   ------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
}

/* -------------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform var(--transition-base), width var(--transition-base);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand__logo {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-500));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: var(--fs-md);
  flex-shrink: 0;
}

.sidebar-brand__text { line-height: 1.2; overflow: hidden; }
.sidebar-brand__title { font-weight: 700; font-size: var(--fs-base); color: var(--text-primary); white-space: nowrap; }
.sidebar-brand__subtitle { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 11px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.nav-item i, .nav-item svg { width: 19px; flex-shrink: 0; text-align: center; }

.nav-item:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }

.nav-item.active {
  background: var(--color-primary-500);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8, 14, 28, 0.55);
  z-index: 39;
}

/* -------------------------------------------------------------------------
   Content Area / Header
   ------------------------------------------------------------------------- */
.content-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: var(--space-4);
}

.topbar-left { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.topbar-title { font-size: var(--fs-lg); font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }

.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--color-slate-100); color: var(--text-primary); }

.menu-btn { display: none; }

.header-search {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  width: 280px;
  height: 40px;
}
.header-search input { border: none; background: transparent; outline: none; width: 100%; font-size: var(--fs-sm); color: var(--text-primary); }
.header-search i { color: var(--text-muted); font-size: 13px; }

.user-chip { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; padding: 6px 8px 6px 6px; border-radius: var(--radius-full); transition: background var(--transition-fast); }
.user-chip:hover { background: var(--bg-surface-alt); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-500)); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:600; font-size: var(--fs-sm); flex-shrink:0; }
.user-chip__name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; }
.user-chip__role { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

.page-body { padding: var(--space-6); flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-header h1 { font-size: var(--fs-2xl); font-weight: 700; margin: 0 0 4px; color: var(--text-primary); }
.page-header p { margin: 0; color: var(--text-secondary); font-size: var(--fs-sm); }

/* -------------------------------------------------------------------------
   Bottom Navigation (mobile)
   ------------------------------------------------------------------------- */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  z-index: 45;
  align-items: stretch;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(16,24,40,0.06);
}
.bottom-nav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-muted); font-size: 11px; font-weight: 600;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.bottom-nav__item i { font-size: 18px; }
.bottom-nav__item.active { color: var(--color-primary-500); }

/* -------------------------------------------------------------------------
   Login Page
   ------------------------------------------------------------------------- */
.login-screen { min-height: 100vh; position: relative; display: flex; }
.login-bg {
  position: fixed; inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.login-bg::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(20,30,45,0.18);
}
.login-panel { position: relative; z-index: 1; flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }

.login-card {
  width: 100%; max-width: 420px;
  text-align: center;
  background: rgba(205, 222, 235, 0.28);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(11,28,58,0.28);
  padding: 44px 40px 36px;
}
.login-card__logo-img { display: block; height: 130px; width: auto; margin: 0 auto 18px; object-fit: contain; }
.login-card__title {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-primary-900);
  margin: 0 0 28px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.login-card .field--chip { position: relative; text-align: left; margin-bottom: 22px; }
.field-chip {
  position: absolute;
  top: -11px; left: 14px;
  background: var(--color-primary-500);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  z-index: 1;
}
.login-card .input.input--pill {
  width: 100%;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 14px;
  padding: 14px 18px;
  min-height: 52px;
  color: var(--color-primary-900);
  font-size: var(--fs-base);
}
.login-card .input.input--pill:focus { outline: none; border-color: var(--color-primary-500); box-shadow: 0 0 0 3px var(--color-primary-100); }

.login-card .btn-primary { border-radius: 12px; min-height: 50px; margin-top: 6px; }

/* -------------------------------------------------------------------------
   Utility
   ------------------------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.w-full { width: 100%; }
