/**
 * CSS Modules — Layout
 * App shell, Sidebar, Grid, Cards, Panels
 * Check Pro v12.44.782 — Minimalista Premium
 */

/* ═══ APP SHELL ═══ */
.app-container {
  display: flex; height: 100vh; height: 100dvh; background: var(--bg-app);
  overflow: hidden;
}

/* ═══ SIDEBAR ═══ */
.app-sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: var(--z-sticky);
  transition: transform var(--duration-slow) var(--ease);
}

/* Brand */
.app-sidebar-brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.app-sidebar-brand-icon {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: var(--accent); display: flex; align-items: center; justify-content: center;
}
.app-sidebar-brand-icon .material-symbols-outlined { font-size: 18px; color: #fff; }
.app-sidebar-brand-title {
  font-size: var(--text-base); font-weight: 700; color: var(--text-primary);
}
.app-sidebar-brand-title span { color: var(--accent); }
.app-sidebar-brand-subtitle {
  font-size: 10px; color: var(--text-muted); font-weight: 400;
}

/* Nav */
.app-nav {
  flex: 1; padding: var(--space-3) var(--space-3);
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 12px; border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--duration-fast); border: none; background: none;
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light); color: var(--accent);
}
.nav-item .material-symbols-outlined { font-size: 20px; flex-shrink: 0; }
.nav-item-text { white-space: nowrap; }

/* Nav section */
.nav-section {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

/* Sidebar footer */
.app-sidebar-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}
.sidebar-user-section {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) 0;
}
.sidebar-user-name {
  font-size: var(--text-sm); font-weight: 500; color: var(--text-primary);
}
.sidebar-user-role {
  font-size: var(--text-xs); color: var(--text-muted);
}
.sidebar-footer-version {
  font-size: 10px; color: var(--text-muted); margin-top: var(--space-2);
}

/* ═══ MOBILE SIDEBAR ═══ */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: var(--z-overlay);
}
.hamburger-btn {
  display: none; position: fixed; top: var(--space-3); left: var(--space-3);
  z-index: var(--z-sticky); width: 40px; height: 40px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 20px;
  color: var(--text-primary); cursor: pointer;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .hamburger-btn { display: flex; align-items: center; justify-content: center; }
  .app-main-content { margin-left: 0 !important; }
}

/* ═══ MAIN CONTENT ═══ */
.app-main-content {
  flex: 1; margin-left: var(--sidebar-width);
  height: 100vh; height: 100dvh; padding: var(--space-6);
  max-width: calc(100vw - var(--sidebar-width));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (max-width: 768px) {
  .app-main-content {
    margin-left: 0; padding: var(--space-4) var(--space-4) var(--space-16);
    max-width: 100vw;
  }
}

/* ═══ PAGE HEADER ═══ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-6); gap: var(--space-4); flex-wrap: wrap;
}
.page-header-left { display: flex; flex-direction: column; gap: var(--space-1); }
.page-title { font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: var(--text-sm); color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: var(--space-3); }

/* ═══ SECTION ═══ */
.view-section { animation: fadeIn var(--duration-slow) var(--ease-out); }

/* ═══ CARDS ═══ */
.card {
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-lg); transition: all var(--duration-normal) var(--ease);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.card-body { padding: var(--space-5); }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border);
}
.card-hover:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }

.card-grid { display: grid; gap: var(--space-4); }
.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .card-grid-2, .card-grid-3, .card-grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .card-grid-3, .card-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ═══ PANELS ═══ */
.panel {
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.panel-body { padding: var(--space-5); }

/* ═══ STATS BAR ═══ */
.stats-bar {
  display: flex; gap: var(--space-4); padding: var(--space-4) 0;
  overflow-x: auto;
}
.stat-item {
  display: flex; flex-direction: column; gap: var(--space-1);
  min-width: 120px;
}
.stat-item-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; }
.stat-item-value { font-size: var(--text-xl); font-weight: 700; color: var(--text-primary); }

/* ═══ SEARCH BAR ═══ */
.search-bar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast) var(--ease);
}
.search-bar:focus-within { border-color: var(--border-focus); }
.search-bar .material-symbols-outlined { font-size: 20px; color: var(--text-muted); }
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  font-size: var(--text-sm); color: var(--text-primary);
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ═══ HAMBURGER ═══ */
.hamburger-btn { font-family: inherit; }

/* ═══ BOTTOM SHEET (mobile) ═══ */
.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card); border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-xl); z-index: var(--z-modal);
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--ease);
  max-height: 80vh; overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet-handle {
  width: 40px; height: 4px; border-radius: var(--radius-full);
  background: var(--border); margin: var(--space-3) auto var(--space-2);
}

/* ═══ TOAST CONTAINER ═══ */
.toast-container { pointer-events: none; }
.toast { pointer-events: auto; }

/* ═══ FLEX UTILITIES ═══ */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-start { display: flex; align-items: flex-start; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ═══ SPACING ═══ */
.space-y-2 > * + * { margin-top: var(--space-2); }
.space-y-3 > * + * { margin-top: var(--space-3); }
.space-y-4 > * + * { margin-top: var(--space-4); }
.space-y-6 > * + * { margin-top: var(--space-6); }

/* ═══ GLASS CARD (legacy support) ═══ */
.glass-card {
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
}

/* ═══ SUGGESTIONS DROPDOWN ═══ */
.suggestions-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown); max-height: 240px; overflow-y: auto;
  animation: fadeInDown var(--duration-normal) var(--ease-out);
}
.suggestion-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); cursor: pointer;
  transition: background var(--duration-fast);
}
.suggestion-item:hover { background: var(--bg-hover); }

/* ═══ CHIP GROUP ═══ */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ═══ FILTER BAR ═══ */
.filter-bar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0; flex-wrap: wrap;
}

/* ═══ RESPONSIVE GRID ═══ */
@media (max-width: 640px) {
  .app-container { flex-direction: column; }
}

/* ═══ SIDEBAR FOOTER — F-UX unificación (clases que el markup consumía sin definir) ═══ */
.sidebar-user-section {
  margin-top: auto; /* empuja al fondo del sidebar */
  flex-direction: column; align-items: stretch; gap: var(--space-2);
  padding: var(--space-3); border-top: 1px solid var(--border);
}
.sidebar-user-info { display: flex; align-items: center; gap: var(--space-3); }
.sidebar-user-avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-full); color: var(--text-secondary);
}
.sidebar-user-avatar .material-symbols-outlined { font-size: 18px; }
.sidebar-user-details { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; }
.sidebar-user-actions { display: flex; align-items: center; gap: var(--space-2); }
.sidebar-action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
}
.sidebar-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-action-btn .material-symbols-outlined { font-size: 18px; }
.logout-btn:hover { background: var(--error-bg); color: var(--error); }
.sidebar-footer { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-2); }
.sidebar-footer-version { font-size: 10px; color: var(--text-muted); }
.sidebar-footer-link { font-size: 10px; color: var(--text-muted); text-decoration: none; }
.sidebar-footer-link:hover { color: var(--text-link); }
