/* ===== LAYOUT: HEADER, SIDEBAR, MAIN CONTENT ===== */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background var(--transition);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  flex-shrink: 0;
}

.app-header .logo svg {
  width: 28px;
  height: 28px;
}

.app-header .logo span.highlight {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-actions .btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  color: var(--text-secondary);
}

.header-actions .btn-icon:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* ===== APP LAYOUT ===== */

.app-layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  overflow-y: auto;
  z-index: 90;
  transition: width var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section {
  padding: 8px 8px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

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

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item .nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== MAIN CONTENT ===== */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-height: calc(100vh - var(--header-height));
  transition: margin-left var(--transition);
}

.module-panel {
  display: none;
  max-width: var(--content-max);
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.module-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.module-header {
  margin-bottom: 24px;
}

.module-header h2 {
  margin-bottom: 4px;
}

.module-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Two-column layout for modules */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.module-grid .full-width {
  grid-column: 1 / -1;
}

/* ===== FOOTER ===== */

.app-footer {
  margin-left: var(--sidebar-width);
  padding: 16px 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  transition: margin-left var(--transition);
}

.app-footer a {
  color: var(--accent);
  font-weight: 500;
}

.app-footer a:hover {
  color: var(--accent-hover);
}

/* ===== MOBILE BOTTOM TAB BAR ===== */

.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-tabs-inner {
  display: flex;
  min-width: max-content;
}

.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-tab svg {
  width: 20px;
  height: 20px;
}

.mobile-tab.active {
  color: var(--accent);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1200px) {
  .module-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: 80px;
  }

  .app-footer {
    margin-left: 0;
    padding-bottom: 80px;
  }

  .mobile-tabs {
    display: block;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 12px;
  }

  .app-header .logo span.text {
    display: none;
  }

  .main-content {
    padding: 12px;
    padding-bottom: 80px;
  }

  .module-header h2 {
    font-size: 1.2rem;
  }
}

/* ===== PRINT ===== */

@media print {
  .app-header, .sidebar, .mobile-tabs, .header-actions,
  .btn, button {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .module-panel {
    display: block !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }
}
