/* ═══════════════════════════════════════════════
   CONCENTRADOR — App Layout Styles
   ════════════════════════════════════════════ */

/* ─── App shell ──────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-logo {
  padding: 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; overflow: hidden; white-space: nowrap;
}
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg,#4a90e8,#a371f7);
  display: flex; align-items: center; justify-content: center;
  font-size: .9em; font-weight: 700; color: #fff; flex-shrink: 0;
}
.logo-text { font-size: .84em; font-weight: 700; color: #fff; line-height: 1.2; }
.logo-sub  { font-size: .72em; color: rgba(255,255,255,.4); }
.sidebar-text { overflow: hidden; }

.sidebar-nav { flex: 1; padding: 10px 6px; overflow-y: auto; overflow-x: hidden; }

.nav-section-label {
  font-size: .68em; font-weight: 700; color: rgba(255,255,255,.3);
  text-transform: uppercase; letter-spacing: .09em;
  padding: 8px 10px 3px; margin-top: 4px;
  white-space: nowrap; overflow: hidden;
}
#sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; margin: 0; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 6px;
  cursor: pointer; color: rgba(255,255,255,.58);
  font-size: .88em; font-weight: 500;
  transition: all var(--transition);
  position: relative; margin-bottom: 1px;
  text-decoration: none; white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(74,144,232,.22); color: #7bb8ff; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 2px; background: #4a90e8; border-radius: 0 2px 2px 0;
}
.nav-icon  { width: 18px; text-align: center; font-size: .92em; flex-shrink: 0; }
.nav-label { transition: opacity var(--transition); flex: 1; }
.nav-badge {
  margin-left: auto; flex-shrink: 0;
  background: rgba(74,144,232,.25); color: #7bb8ff;
  font-size: .7em; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  border: 1px solid rgba(74,144,232,.35);
  transition: opacity var(--transition);
}
.nav-badge.red   { background: rgba(212,43,43,.25); color: #ff8080; border-color: rgba(212,43,43,.35); }
.nav-badge.green { background: rgba(26,158,74,.25);  color: #5ddc8a; border-color: rgba(26,158,74,.35); }

#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-badge { opacity: 0; width: 0; overflow: hidden; }

/* Sidebar tooltip on collapse */
#sidebar.collapsed .nav-item { justify-content: center; }
#sidebar.collapsed .nav-item:hover::after {
  content: attr(data-label);
  position: absolute; left: calc(var(--sidebar-collapsed) + 8px); top: 50%; transform: translateY(-50%);
  background: #1a2440; color: #fff; font-size: .8em; font-weight: 600;
  padding: 5px 10px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.2); pointer-events: none; z-index: 999;
}

.sidebar-footer {
  padding: 10px 6px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0; overflow: hidden;
}
.user-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 6px; cursor: pointer;
  transition: background var(--transition); white-space: nowrap; overflow: hidden;
}
.user-pill:hover { background: rgba(255,255,255,.08); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg,#4a90e8,#a371f7);
  display: flex; align-items: center; justify-content: center;
  font-size: .75em; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: .8em; font-weight: 600; color: #fff; }
.user-role { font-size: .7em; color: rgba(255,255,255,.38); }

#sidebar.collapsed .user-pill { justify-content: center; }
#sidebar.collapsed .sidebar-text { opacity: 0; width: 0; overflow: hidden; }

/* ─── Topbar ─────────────────────────────────── */
#topbar {
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 1.2em; padding: 5px 7px;
  border-radius: 5px; transition: all var(--transition);
  flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--surface3); color: var(--text); }

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .85em; color: var(--text2); flex: 1;
}
.topbar-sep { color: var(--text3); }
.topbar-current { color: var(--text); font-weight: 600; }

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

/* Font size controls */
.font-controls {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 3px;
}
.fc-btn {
  background: none; border: none; cursor: pointer;
  font-size: .78em; font-weight: 700; color: var(--text2);
  padding: 3px 7px; border-radius: 4px; transition: all var(--transition);
  font-family: inherit;
}
.fc-btn:hover { background: var(--surface); color: var(--accent); }
.fc-label {
  font-size: .72em; font-weight: 700; color: var(--text3);
  min-width: 18px; text-align: center;
}

/* Notification icon */
.topbar-icon-btn {
  position: relative; cursor: pointer;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 9px;
  font-size: .85em; color: var(--text2);
  display: flex; align-items: center; gap: 5px;
  transition: all var(--transition); white-space: nowrap;
}
.topbar-icon-btn:hover { border-color: var(--border2); color: var(--text); }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--red); color: #fff;
  font-size: .65em; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

/* User dropdown */
.user-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 500;
  padding: 4px;
  animation: modalIn .15s ease;
}
.user-dropdown.open { display: block; }
.topbar-icon-btn { position: relative; }
.ud-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 5px;
  font-size: .88em; color: var(--text2); cursor: pointer;
  transition: all var(--transition);
}
.ud-item:hover { background: var(--surface3); color: var(--text); }
.ud-item.danger { color: var(--red); }
.ud-item.danger:hover { background: var(--red-subtle); }
.ud-divider { height: 1px; background: var(--border); margin: 3px 0; }

/* ─── Main content area ──────────────────────── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
#main.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

.content {
  flex: 1;
  padding: 26px 28px;
  max-width: 1320px;
  width: 100%;
}

/* Page header */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-title    { font-size: 1.4em; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .85em; color: var(--text2); margin-top: 3px; }
.page-actions  { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Notifications panel */
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  transition: background var(--transition); cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: #f0f5ff; }
.notif-item.unread:hover { background: #e8efff; }
.notif-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1em; flex-shrink: 0;
}
.notif-title { font-size: .88em; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-desc  { font-size: .8em; color: var(--text2); }
.notif-time  { font-size: .75em; color: var(--text3); margin-top: 3px; }

/* ═══════════════════════════════════════════════
   RESPONSIVE DESIGN
   ════════════════════════════════════════════ */

/* ─── Overlay for mobile sidebar ─────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26,36,64,.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ─── Tablet (≤ 1024px) ──────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }

  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .three-col  { grid-template-columns: 1fr 1fr; }

  .topbar-breadcrumb { font-size: .78em; }

  /* Hide font controls label on tablet */
  .fc-label { display: none; }

  /* Topbar: hide "Nueva Pagaduría" text label, keep icon-ish */
  .topbar-new-label { display: none; }
}

/* ─── Mobile (≤ 768px) ───────────────────────── */
@media (max-width: 768px) {

  /* Sidebar becomes an off-canvas drawer */
  #sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important; /* override collapsed */
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Main always full-width on mobile */
  #main { margin-left: 0 !important; }

  /* Topbar */
  #topbar { padding: 0 14px; gap: 8px; }
  .topbar-breadcrumb { display: none; }
  .font-controls { display: none; }
  .topbar-actions { gap: 6px; }

  /* "Nueva Pagaduría" button — icon only */
  .topbar-actions .btn-primary .btn-label { display: none; }
  .topbar-actions .btn-primary::before { content: '+'; margin: 0; }

  /* Content padding */
  .content { padding: 16px; }

  /* Grids → single column */
  .stats-grid,
  .two-col,
  .three-col,
  .form-grid,
  .form-grid-3 { grid-template-columns: 1fr !important; }

  /* col-span overrides */
  .col-2, .col-3 { grid-column: span 1 !important; }

  /* Page header stack */
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; }

  /* Tab bar scrollable */
  .tab-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* Table: horizontal scroll */
  .table-wrap { overflow-x: auto; }
  table { min-width: 560px; }

  /* Table header stack */
  .table-header { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .search-box input { width: 140px; }

  /* Wizard steps: only show active + adjacent, rest show dots */
  .wizard-steps { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; }
  .step-label { display: none; }
  .wizard-step.active .step-label { display: block; }

  /* Modal full-screen on mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 18px 18px 0 0;
    max-width: 100% !important;
    max-height: 92vh;
  }
  .modal-body { max-height: 60vh; }

  /* Cards full width */
  .card { border-radius: 10px; }

  /* DL list */
  .dl { grid-template-columns: 1fr; gap: 4px 0; }
  .dl dt { color: var(--text3); font-size: .75em; margin-top: 8px; }
  .dl dt:first-child { margin-top: 0; }

  /* Filter tabs scrollable */
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .filter-tab { flex-shrink: 0; }

  /* Timeline */
  .timeline { padding-left: 12px; }

  /* Stat cards compact */
  .stat-value { font-size: 1.5em; }

  /* Multi-add grid */
  .multi-add-item > div[style*="grid"] { grid-template-columns: 1fr !important; }

  /* user dropdown position */
  .user-dropdown { right: -10px; min-width: 180px; }

  /* OTP row */
  .otp-row { gap: 5px; }
  .otp-input { width: 40px; height: 46px; font-size: 1.1em; }

  /* Auth split: hide left panel */
  .auth-left { display: none; }
  .auth-right { padding: 28px 20px; }
}

/* ─── Small mobile (≤ 480px) ─────────────────── */
@media (max-width: 480px) {
  html { font-size: calc(13px * var(--font-scale)); }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card  { padding: 13px 14px; }
  .stat-value { font-size: 1.35em; }
  .stat-icon  { font-size: 18px; }

  .content { padding: 12px; }

  .page-title { font-size: 1.15em; }

  .btn { padding: 6px 11px; font-size: .82em; }
  .btn-sm { padding: 4px 9px; font-size: .76em; }

  .table-wrap { border-radius: 8px; }
  table { min-width: 480px; }

  /* Modal full height */
  .modal { max-height: 95vh; }
  .modal-body { max-height: 65vh; }

  /* Checklist items */
  .checklist-item { font-size: .82em; }
}

/* ─── Print styles ────────────────────────────── */
@media print {
  #sidebar, #topbar, .page-actions, .btn, .modal-overlay { display: none !important; }
  #main { margin-left: 0 !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .table-wrap, .stat-card { box-shadow: none !important; border: 1px solid #ddd; }
  .stats-grid { grid-template-columns: repeat(4,1fr); }
  .two-col    { grid-template-columns: 1fr 1fr; }
}
