/* ═══════════════════════════════════════════════════════
   CULTURARED — Sidebar Unificado v4.0
   Responsive: Mobile (<768px) → off-canvas + bottom nav
              Tablet (768-1024px) → compact sidebar
              Desktop (≥1025px) → full sidebar
   ═══════════════════════════════════════════════════════ */

/* ═══ CUSTOM PROPERTIES ═══ */
:root {
  --sidebar-bg: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  --sidebar-text: rgba(255,255,255,.88);
  --sidebar-text-muted: rgba(255,255,255,.5);
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active-bg: rgba(108,92,231,.15);
  --sidebar-border: rgba(255,255,255,.08);
  --sidebar-width: var(--layout-sidebar-width, 260px);
  --sidebar-collapsed-width: var(--layout-sidebar-collapsed, 72px);

  --glass-bg: rgba(26,26,46,.85);
  --glass-border: rgba(255,255,255,.12);
  --glass-blur: 12px;

  --nav-icon-size: 22px;
  --nav-icon-color: rgba(255,255,255,.5);

  --accent: var(--color-primary, #6c5ce7);
  --accent-hover: var(--color-primary-hover, #7c6ff0);
  --accent-light: var(--color-primary-light, rgba(108,92,231,.12));
  --accent-glow: 0 0 20px rgba(108,92,231,.3);

  --bg: var(--color-surface, #f5f6fa);
  --card: var(--color-container, #ffffff);
  --text: var(--color-text, #2d3436);
  --text-secondary: var(--color-text-secondary, #636e72);
  --border: var(--color-border, #e0e0e0);
  --radius: var(--radius-lg, 12px);
  --radius-sm: var(--radius-md, 8px);
  --radius-lg: var(--radius-xl, 16px);
  --shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.08));
  --shadow-lg: var(--shadow-lg, 0 8px 32px rgba(0,0,0,.12));
  --header-h: 60px;
  --bottom-nav-h: var(--layout-bottom-nav-height, 64px);

  --font-scale: 1;
  --font-base: calc(14px * var(--font-scale));

  scroll-behavior: smooth;
  font-family: var(--font-sans, 'Inter', system-ui, -apple-system, sans-serif);
}

/* ═══ THEMES ═══ */
[data-theme="dark"] {
  --sidebar-bg: linear-gradient(180deg, #0f0f1a 0%, #1a1a2e 100%);
  --bg: #0f0f1a; --card: #1a1a2e; --text: #eee;
  --text-secondary: #999; --border: #2a2a3e;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.4);
}
[data-theme="highcontrast"] {
  --sidebar-bg: #000;
  --bg: #000; --card: #111; --text: #fff;
  --text-secondary: #ccc; --border: #444;
  --accent: #ff0; --accent-hover: #ff3;
  --accent-light: rgba(255,255,0,.15);
}
[data-accent="blue"]   { --accent:#2980b9; --accent-hover:#3498db; --accent-light:rgba(41,128,185,.15); }
[data-accent="green"]  { --accent:#27ae60; --accent-hover:#2ecc71; --accent-light:rgba(39,174,96,.15); }
[data-accent="orange"] { --accent:#e67e22; --accent-hover:#f39c12; --accent-light:rgba(230,126,34,.15); }
[data-accent="red"]    { --accent:#c0392b; --accent-hover:#e74c3c; --accent-light:rgba(192,57,43,.15); }
[data-accent="black"]  { --accent:#d4a853; --accent-hover:#e0b960; --accent-light:rgba(212,168,83,.15); }

/* ═══ RESET ═══ */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--font-base); }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; min-height: 100vh;
  margin: 0; padding: 0;
  transition: background .3s, color .3s;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════
   SIDEBAR — Base (mobile-first: off-canvas)
   ═══════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh; height: 100dvh;
  background: var(--sidebar-bg);
  background-attachment: fixed;
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  box-shadow: 2px 0 24px rgba(0,0,0,.15);
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar.open {
  transform: translateX(0);
}

/* ── Brand ── */
.sidebar-brand {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.sidebar-brand::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 20px; right: 20px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 60%);
  border-radius: 1px; opacity: .6;
}
.sidebar-brand h2 {
  font-size: 1.05rem; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  color: #fff; margin: 0; overflow: hidden;
  letter-spacing: -.01em; flex: 1;
}
.sidebar-brand h2 i { 
  color: var(--accent); font-size: 1.15rem;
  filter: drop-shadow(0 0 8px rgba(108,92,231,.4));
  flex-shrink: 0;
}
.sidebar-brand .sic-subtitle {
  display: block;
  font-size: .6rem; font-weight: 500;
  color: var(--sidebar-text-muted);
  letter-spacing: .06em; text-transform: uppercase;
  margin-top: 2px;
}

/* ── Branding Logo ── */
.sidebar-logo {
  width: 28px; height: 28px;
  border-radius: 6px; object-fit: contain;
  flex-shrink: 0;
  background: rgba(255,255,255,.06);
  padding: 2px;
}

/* ── Toggle button ── */
.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--sidebar-text-muted);
  cursor: pointer; font-size: .75rem;
  transition: all .2s; flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: #fff; }

/* ── Navigation ── */
.sidebar-nav {
  flex: 1;
  padding: 4px 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.sidebar-nav .nav-section {
  font-size: .6rem; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--sidebar-text-muted);
  padding: 20px 20px 8px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-nav .nav-section::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0; opacity: .5;
  box-shadow: 0 0 6px var(--accent);
}

.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px; margin: 2px 8px;
  color: var(--sidebar-text-muted);
  text-decoration: none; font-size: .85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all .2s cubic-bezier(.4,0,.2,1);
  white-space: nowrap; position: relative;
}
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.06); color: #fff;
  transform: translateX(2px);
}
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg); color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent), 0 0 20px rgba(108,92,231,.08);
}
.sidebar-nav .nav-link.active::after {
  content: '';
  position: absolute;
  left: -3px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0; opacity: .9;
  box-shadow: 0 0 10px var(--accent);
}
.sidebar-nav .nav-link i {
  width: 22px; text-align: center;
  font-size: .9rem; color: rgba(255,255,255,.4);
  flex-shrink: 0; transition: all .2s;
}
.sidebar-nav .nav-link.active i { color: var(--accent); opacity: 1; }

/* ── Footer ── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-brand-info {
  padding: 0 0 8px 0;
  text-align: center;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 8px;
}
.sidebar-brand-info span {
  display: block;
  font-size: .7rem; font-weight: 600;
  color: var(--sidebar-text);
  letter-spacing: .02em;
}
.sidebar-brand-info small {
  display: block;
  font-size: .58rem;
  color: var(--sidebar-text-muted);
  margin-top: 1px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sidebar.collapsed .sidebar-brand-info { display: none; }

.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  color: #e74c3c;
  text-decoration: none;
  font-size: .82rem; font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.sidebar-footer a:hover {
  background: rgba(231,76,60,.12);
}
.sidebar-footer a i {
  width: 18px; text-align: center;
  font-size: .85rem;
}

/* ═══════════════════════════════════════════════════
   OVERLAY (mobile)
   ═══════════════════════════════════════════════════ */
.sic-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1050;
  transition: opacity .3s;
}
.sic-overlay.active {
  display: block;
}

/* ═══════════════════════════════════════════════════
   BOTTOM NAV (mobile)
   ═══════════════════════════════════════════════════ */
.sic-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 900;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.sic-bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .6rem; font-weight: 500;
  transition: color .15s;
  position: relative;
}
.sic-bottom-nav a i {
  font-size: 1.15rem;
  transition: color .15s;
}
.sic-bottom-nav a.active {
  color: var(--accent);
}
.sic-bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: var(--bottom-nav-h);
  transition: margin-left .35s cubic-bezier(.4,0,.2,1);
}
.main-content main {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════
   SIC TOPBAR
   ═══════════════════════════════════════════════════ */
.sic-topbar {
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}
.sic-topbar .sic-hamburger {
  display: flex;
  align-items: center; justify-content: center;
  background: none; border: none;
  width: 36px; height: 36px;
  cursor: pointer; color: var(--text);
  border-radius: 8px; font-size: 1.1rem;
  transition: background .15s;
}
.sic-topbar .sic-hamburger:hover {
  background: var(--sidebar-hover);
}
.sic-topbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 1rem;
  color: var(--text);
}
.sic-topbar-brand i { color: var(--accent); font-size: 1.1rem; }
.sic-topbar-spacer { flex: 1; }

.sic-module-select {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-size: .82rem; font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2212%22 height=%2212%22 viewBox=%220 0 12 12%22%3E%3Cpath fill=%22%23636e72%22 d=%22M6 8L1 3h10z%22/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.sic-module-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* ═══════════════════════════════════════════════════
   USER MENU (topbar)
   ═══════════════════════════════════════════════════ */
.sic-user-menu {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
  position: relative; user-select: none;
}
.sic-user-menu:hover { background: var(--bg); }
.sic-user-name {
  font-size: .82rem; font-weight: 500;
  color: var(--text);
  max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.sic-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem; flex-shrink: 0;
}
.sic-chevron {
  font-size: .6rem; color: var(--text-secondary);
  transition: transform .2s;
}
.sic-user-menu:hover .sic-chevron { transform: rotate(180deg); }

.sic-user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 1000; overflow: hidden;
}
.sic-user-dropdown.open { display: block; }

.sic-dropdown-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--bg);
}
.sic-avatar-lg {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.sic-dropdown-name {
  font-weight: 600; font-size: .9rem; color: var(--text);
}
.sic-dropdown-role {
  font-size: .75rem; color: var(--text-secondary);
  text-transform: capitalize;
}
.sic-dropdown-divider {
  height: 1px; background: var(--border);
}
.sic-dropdown-section { padding: 12px 16px; }
.sic-dropdown-label {
  font-size: .7rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 8px;
}

.sic-font-controls { display: flex; align-items: center; gap: 6px; }
.sic-font-controls button {
  width: 32px; height: 28px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--card); cursor: pointer;
  font-size: .75rem; font-weight: 600;
  color: var(--text); transition: all .15s;
}
.sic-font-controls button:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.sic-btn-reset {
  margin-left: auto !important;
  font-size: .7rem !important;
  padding: 0 8px !important;
  width: auto !important;
}

.sic-theme-controls { display: flex; gap: 8px; }
.sic-theme-btn {
  padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); cursor: pointer;
  font-size: .85rem; transition: all .15s;
}
.sic-theme-btn:hover { border-color: var(--accent); }
.sic-theme-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.sic-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: var(--text); text-decoration: none;
  font-size: .82rem; transition: background .15s;
}
.sic-dropdown-item:hover { background: var(--bg); }
.sic-dropdown-item i {
  width: 18px; text-align: center;
  color: var(--text-secondary); font-size: .85rem;
}
.sic-dropdown-item.sic-logout { color: #e74c3c; }
.sic-dropdown-item.sic-logout i { color: #e74c3c; }

.sic-btn-login {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--accent); color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: .82rem; font-weight: 500;
  transition: opacity .15s;
}
.sic-btn-login:hover { opacity: .85; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE — Tablet (≥768px)
   ═══════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
  }
  .sidebar.collapsed .sidebar-brand { padding: 16px 0; justify-content: center; }
  .sidebar.collapsed .sidebar-brand::after { display: none; }
  .sidebar.collapsed .sidebar-brand h2 span,
  .sidebar.collapsed .sidebar-brand .sic-subtitle,
.sidebar.collapsed .sidebar-brand .branding-logo-small { display: none; }
  .sidebar.collapsed .sidebar-logo { width: 32px; height: 32px; border-radius: 8px; }
  .sidebar.collapsed .sidebar-toggle {
    position: fixed; bottom: 16px;
    left: calc(var(--sidebar-collapsed-width) / 2 - 15px);
    transform: rotate(180deg); z-index: 1110;
    background: var(--sidebar-bg);
  }
  .sidebar.collapsed .nav-section { display: none; }
  .sidebar.collapsed .sidebar-nav .nav-link { justify-content: center; padding: 11px 0; margin: 2px 8px; }
  .sidebar.collapsed .sidebar-nav .nav-link span { display: none; }
  .sidebar.collapsed .sidebar-nav .nav-link.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .sidebar.collapsed .sidebar-nav .nav-link.active::after { display: none; }
  .sidebar.collapsed .sidebar-footer a { justify-content: center; }
  .sidebar.collapsed .sidebar-footer a span { display: none; }

  .main-content {
    margin-left: var(--sidebar-width);
  }
  .main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
  }

  .sic-topbar .sic-hamburger { display: none; }
  .sic-bottom-nav { display: none; }
  .sic-overlay { display: none !important; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — Mobile (<768px)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .main-content {
    margin-left: 0 !important;
    padding-bottom: calc(var(--bottom-nav-h) + 16px);
  }
  .main-content main { padding: 12px; }
  .sic-user-name { display: none; }
  .sic-user-dropdown { width: 260px; right: -8px; }
  .sic-module-selector { display: none; }
  .sidebar.collapsed { width: var(--sidebar-width); }

  /* Sidebar drawer ocupa máximo 85% del ancho en móviles chicos */
  .sidebar { max-width: 85vw; }

  /* Evitar doble hamburger: el topbar ya tiene uno */
  .sidebar-brand .hamburger { display: none; }

  /* Compactar header del sidebar en móvil */
  .sidebar-brand { padding: 14px 14px 12px; }
  .sidebar-brand h2 { font-size: .95rem; }

  /* Logo más chico en móvil */
  .sidebar-logo { width: 24px; height: 24px; }
}
