/* ═══════════════════════════════════════════
   LAYOUT — layout.css
   ════════════════════════════════════════════ */

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════
   SIDEBAR
   ══════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width var(--transition-slow), min-width var(--transition-slow);
  overflow: hidden;
  z-index: var(--z-sticky);
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.logo-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.logo-mark svg { width: 36px; height: 36px; }

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-white);
  white-space: nowrap;
  letter-spacing: 0;
  transition: opacity var(--transition-slow);
}
.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--transition-base), color var(--transition-base);
  white-space: nowrap;
  position: relative;
}

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

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--color-white);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--color-accent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

.nav-label {
  font-size: var(--text-sm);
  font-weight: 500;
  transition: opacity var(--transition-slow);
  white-space: nowrap;
}
.sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

.nav-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: var(--color-white);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  transition: opacity var(--transition-slow);
}
.sidebar.collapsed .nav-badge { opacity: 0; }

.nav-alert-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: var(--color-white);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  transition: opacity var(--transition-slow);
}
.sidebar.collapsed .nav-alert-badge { opacity: 0; }

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-shrink: 0;
}

.sidebar-tip {
  background: rgba(184,132,42,0.10);
  border: 1px solid rgba(184,132,42,0.22);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  position: relative;
}
.sidebar-tip p {
  font-size: var(--text-xs);
  color: var(--color-accent-light);
  line-height: 1.5;
}
.tip-close {
  position: absolute;
  top: 6px; right: 8px;
  background: none;
  border: none;
  color: var(--color-accent-light);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0.6;
}
.tip-close:hover { opacity: 1; }
.sidebar.collapsed .sidebar-tip { display: none; }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  width: 100%;
  transition: background var(--transition-base), color var(--transition-base);
  white-space: nowrap;
}
.theme-toggle:hover { background: var(--sidebar-hover-bg); color: var(--color-white); }
.theme-toggle svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
}
.icon-dark { display: none; }
[data-theme="dark"] .icon-light { display: none; }
[data-theme="dark"] .icon-dark { display: block; }

.sidebar-collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  align-self: flex-end;
  transition: background var(--transition-base), color var(--transition-base), transform var(--transition-slow);
  flex-shrink: 0;
}
.sidebar-collapse:hover { background: var(--sidebar-hover-bg); color: var(--color-white); }
.sidebar.collapsed .sidebar-collapse { transform: rotate(180deg); align-self: center; }
.sidebar-collapse svg { width: 16px; height: 16px; }

/* ══════════════
   MAIN CONTENT
   ══════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Header */
.top-header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  gap: var(--space-4);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
}

.breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.sidebar-mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}
.sidebar-mobile-toggle svg { width: 20px; height: 20px; stroke: currentColor; }
.sidebar-mobile-toggle:hover { background: var(--color-surface-2); color: var(--color-text); }

/* Sections */
.main-content > section,
.sections-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.section {
  padding: var(--space-8);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  animation: fadeInUp 0.25s ease both;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.section-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Grid helpers */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-6);
}

/* ══════════════
   RESPONSIVE
   ══════════════ */
@media (max-width: 1024px) {
  .section { padding: var(--space-6); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: var(--z-modal);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-mobile-toggle { display: flex; }
  .section { padding: var(--space-4); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .section { padding: var(--space-3); }
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header-right { justify-content: flex-start; }
}
