/* ============================================================
   LAYOUT.CSS — Sidebar, Topbar, Page Structure
============================================================ */

/* ── APP SHELL ───────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transition: width 0.2s ease;
  z-index: 100;
}

.sidebar-logo {
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo img {
  height: 36px;
  width: auto;
}

.sidebar-logo-text {
  color: var(--accent);
  font-size: 1.1em;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-logo-sub {
  color: rgba(255,255,255,0.4);
  font-size: 0.72em;
  margin-top: 2px;
}

/* Nav sections */
.nav-section {
  padding: 16px 0 4px;
}

.nav-section-label {
  padding: 0 16px 6px;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--nav-label-color, rgba(255,255,255,0.3));
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--nav-text, rgba(255,255,255,0.7));
  font-size: 0.88em;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--nav-hover-bg, rgba(255,255,255,0.06));
  color: var(--nav-hover-text, #fff);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 1em;
  opacity: 0.8;
}

/* Sub-items — indented, slightly smaller, used for grouping under a parent */
.nav-item.nav-sub {
  padding-left: 36px;
  font-size: 0.82em;
  opacity: 0.85;
}
.nav-item.nav-sub .nav-icon {
  font-size: 0.92em;
}

/* Sidebar footer — user info */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border, rgba(255,255,255,0.08));
}

.sidebar-user-name {
  color: var(--nav-hover-text, #fff);
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.72em;
  color: var(--accent);
  text-transform: capitalize;
  margin-top: 1px;
}

.sidebar-user-entity {
  font-size: 0.70em;
  color: var(--nav-text, rgba(255,255,255,0.35));
  margin-top: 1px;
}

/* ── MAIN AREA ───────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ── TOPBAR ──────────────────────────────────────────────── */
#topbar {
  height: 52px;
  min-height: 52px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 50;
}

#topbar-title {
  font-size: 1.05em;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

#topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* Theme toggle */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.15s;
}
#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── PAGE CONTENT ────────────────────────────────────────── */
#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── LOADING ─────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,13,20,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── LOGIN PAGE ──────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-text {
  font-size: 1.5em;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}

.login-logo-sub {
  font-size: 0.78em;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-title {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 0; min-width: 0; overflow: hidden; }
  #sidebar.open { width: 220px; min-width: 220px; position: fixed; height: 100%; }
  #page-content { padding: 12px; }
}
