/* ==========================================================================
   Layout Principal — Sidebar + Topbar + Contenido
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-canvas);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
  background-color: var(--bg-canvas);
  border-right: 1px solid rgba(203, 213, 225, 0.45);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-6);
}

.sidebar-logo {
  width: 40px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.sidebar-brand-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: var(--space-4) var(--space-3) var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.7);
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.nav-item.active {
  background-color: var(--bg-surface);
  color: var(--brand-primary);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background-color: var(--brand-primary);
}

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

.sidebar-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-divider);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background-color: var(--text-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.user-handle {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.btn-logout:hover {
  background-color: rgba(255, 255, 255, 0.7);
}

/* Main Workspace */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-8) var(--space-8);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

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

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
}

.page-icon {
  width: 24px;
  height: 24px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

.global-search {
  position: relative;
  width: 260px;
}

.global-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.global-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-card);
  font-size: 13px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.global-search input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

.icon-pill-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.icon-pill-btn:hover {
  background-color: var(--bg-surface-hover);
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background-color: var(--text-primary);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-pill {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.api-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-right: 6px;
}

.api-status-dot.online {
  background-color: var(--accent-green);
}

.api-status-dot.local {
  background-color: var(--accent-amber);
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: -260px;
    transition: left 200ms ease-out;
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open {
    left: 0;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .main-area {
    padding: var(--space-4);
  }
  .global-search {
    width: 100%;
  }
}
