/* ============================================================
   MaaşAnaliz Layout System — v1.0
   App shell: sidebar, header, content, mobile bottom nav
   ============================================================ */

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

/* ---------- 2. SIDEBAR (desktop) ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform var(--t-smooth), width var(--t-smooth);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--dark-foreground);
  letter-spacing: -0.02em;
}
.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--dark-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 16px 14px 6px;
  opacity: 0.6;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--dark-border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  text-decoration: none;
  transition: background var(--t-fast);
}
.sidebar-user:hover { background: var(--dark-border); }
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  object-fit: cover;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 11px;
  color: var(--dark-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 3. MAIN CONTENT AREA ---------- */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ---------- 4. TOP HEADER ---------- */
.top-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 16px;
}
.top-header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.top-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 5. CONTENT WRAPPER ---------- */
.content-wrapper {
  flex: 1;
  padding: 24px;
  width: 100%;
}
@media (min-width: 1024px) {
  .content-wrapper { padding: 32px; }
}

/* ---------- 6. MOBILE BOTTOM NAV ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  transition: color var(--t-fast);
  position: relative;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 var(--r-full) var(--r-full);
}
.bottom-nav-icon { width: 22px; height: 22px; }

/* ---------- 7. RESPONSIVE BREAKPOINTS ---------- */

/* Tablet & below: hide sidebar, show toggle */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--sh-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 49;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.show { display: block; }
}

/* Mobile: show bottom nav, adjust content */
@media (max-width: 767px) {
  .bottom-nav { display: block; }
  .content-wrapper { padding: 10px; padding-bottom: calc(10px + var(--bottom-nav-h)); }
  .top-header { padding: 0 12px; }
  .top-header-title { font-size: 16px; }
}

/* ---------- 8. PAGE HEADER (content area) ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------- 9. GRID UTILITIES ---------- */
.grid-stats {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .grid-stats { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-stats { grid-template-columns: repeat(4, 1fr); } }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }

.grid-3 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ---------- 10. MOBILE MENU TOGGLE ---------- */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
}
@media (max-width: 1023px) {
  .menu-toggle { display: inline-flex; }
}
