/* ========================================
   LAYOUT - Sidebar, Header, Content Area
   ======================================== */

/* ---- App Container ---- */
.app {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: var(--z-base);
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--gradient-sidebar);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-sticky);
  transition: transform var(--duration-slow) var(--ease-out),
              width var(--duration-slow) var(--ease-out);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--accent-muted) 30%,
    var(--accent-muted) 70%,
    transparent 100%
  );
  pointer-events: none;
}

/* Sidebar Header */
.sidebar-header {
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.sidebar-logo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.2) 50%, transparent 60%);
  animation: shimmer 3s ease-in-out infinite;
  background-size: 200% 100%;
}

.sidebar-title {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
}

.sidebar-subtitle {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: var(--sp-4) var(--sp-3);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-section-title {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  cursor: pointer;
  user-select: none;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-muted);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: var(--font-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  min-width: 22px;
  text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sidebar-footer .nav-item {
  color: var(--text-muted);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  transition: margin-left var(--duration-slow) var(--ease-out);
}

/* ---- Header ---- */
.main-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--page-padding);
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  flex-shrink: 0;
  gap: var(--sp-4);
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
  font-size: 1.25rem;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.page-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.header-spacer {
  flex: 1;
}

.header-date {
  font-size: var(--font-sm);
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

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

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--page-padding);
}

.page-content > * {
  max-width: var(--content-max-width);
}

/* Page section spacing */
.page-section {
  margin-bottom: var(--sp-8);
}

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

.section-title {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

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

/* ---- Overlay (for mobile sidebar) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-sticky) - 1);
  opacity: 0;
  transition: opacity var(--duration-base);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ---- Grid Layouts ---- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-6);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-6);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-6);
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-6);
}

/* Two column layout */
.layout-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-6);
}
