/* ============================================================
   RESPONSIVE.CSS — Breakpoints + Sidebar drawer mobile
   ============================================================ */

/* ---------- SIDEBAR GLOBAL (desktop ≥ 992px) ---------- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 260px; background: #fff;
  border-right: 1.5px solid rgba(var(--color-primary-rgb),.1);
  display: flex; flex-direction: column; z-index: 1020;
  overflow-y: auto; overflow-x: hidden;
  transition: width .2s ease;
}

/* Overlay — oculto siempre por defecto */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1045;
}

/* ---------- MOBILE / TABLET (< 992px) ---------- */
@media (max-width: 991.98px) {
  .main-content { margin-left: 0 !important; }

  /* Sidebar fuera de pantalla a la izquierda */
  .sidebar {
    left: -280px;           /* oculto fuera del viewport */
    width: 280px;
    z-index: 1050;
    transition: left .28s cubic-bezier(.4,0,.2,1);
    background: #fff;
    box-shadow: none;
  }

  /* Sidebar abierto — entra desde la izquierda */
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 32px rgba(0,0,0,.18);
  }

  /* Overlay visible solo cuando sidebar está abierto */
  .sidebar-overlay.open { display: block; }

  .grid-4    { grid-template-columns: repeat(2, 1fr); }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-3    { grid-template-columns: repeat(2, 1fr); }
  .page-inner { padding: 1.5rem; }
}

/* ---------- TABLET PEQUEÑA (< 768px) ---------- */
@media (max-width: 767.98px) {
  body { font-size: 14px; }

  .navbar-brand-icon { display: none; }
  .navbar-brand-text { display: inline; }
  .navbar-actions .btn-text { display: none; }

  /* Landing: reducir padding del hero */
  .landing-hero { padding: 3.5rem 1.25rem 2.5rem; }
  .hero-stats    { gap: 1.5rem; margin-top: 2.5rem; padding-top: 1.5rem; }
  .cta-card      { padding: 2.5rem 1.75rem; }

  .page-inner { padding: 1.25rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-title  { font-size: 1.3rem; }

  .grid-2, .grid-3, .grid-4, .grid-stats { grid-template-columns: 1fr; }

  .card { padding: 1.1rem; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.6rem; }

  .table th, .table td { padding: .65rem .75rem; font-size: .85rem; }
  .btn-lg { padding: .75rem 1.5rem; font-size: .95rem; }
  .table .hide-mobile { display: none; }
}

/* ---------- MÓVIL (< 576px) ---------- */
@media (max-width: 575.98px) {
  :root {
    --navbar-h: 56px;
    --radius-md: 10px;
    --radius-lg: 14px;
  }

  .navbar { height: 56px; padding: 0 1rem; }
  .navbar-brand { font-size: 1rem; }
  .page-inner { padding: 1rem; }
  .page-title  { font-size: 1.2rem; }
  .btn-full-mobile { width: 100%; }

  .auth-wrapper { padding: 0; align-items: flex-end; }
  .auth-card {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    min-height: 70vh; padding: 2rem 1.5rem;
  }

  .card { padding: 1rem; }

  /* Landing */
  .landing-hero  { padding: 3rem 1rem 2.5rem; }
  .hero-title    { font-size: 2rem; }
  .hero-sub      { font-size: 1rem; }
  .hero-stats    { gap: 1rem; margin-top: 2rem; padding-top: 1.25rem; }
  .hero-stat-num { font-size: 1.6rem; }
  .cta-card      { padding: 2.25rem 1.5rem; }
  .cta-section   { padding: 4rem 1rem; }
  .features-section { padding: 4rem 1rem; }
  .features-grid { grid-template-columns: 1fr; gap: 1rem; }

  /* Navbar landing (sin sidebar): ocultar botón "Iniciar sesión" para dar espacio al de registro */
  .navbar-actions .btn-ghost.btn-sm { display: none; }

  .table .hide-sm { display: none; }
  .form-row-2 { grid-template-columns: 1fr; }
}

/* ---------- NAVBAR (global) ---------- */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  height: var(--navbar-h); background: #fff;
  border-bottom: 1.5px solid rgba(var(--color-primary-rgb),.1);
  display: flex; align-items: center; padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 1px 12px rgba(0,0,0,.06);
  overflow: visible;
}
.navbar-hamburger {
  display: none; background: none; border: none;
  cursor: pointer; padding: .4rem; border-radius: var(--radius-sm);
  color: #6b7280; flex-shrink: 0;
}
.navbar-hamburger:hover { background: #f3f4f6; }
.navbar-hamburger svg { display: block; }
.navbar-brand {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.1rem; font-weight: 700; color: #1a1a2e;
  letter-spacing: -.02em; flex: 1; min-width: 0; text-decoration: none;
  overflow: hidden;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-brand-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.navbar-brand-text { color: #1a1a2e; }
.navbar-brand-text strong { color: var(--color-primary); font-weight: 800; }
.navbar-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }

@media (max-width: 991.98px) {
  .navbar-hamburger { display: flex; align-items: center; justify-content: center; }
}

/* ---------- SIDEBAR BRAND / NAV / FOOTER ---------- */
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
  height: var(--navbar-h); border-bottom: 1.5px solid rgba(var(--color-primary-rgb),.08);
  font-size: 1.05rem; font-weight: 800; color: #1a1a2e;
  text-decoration: none; flex-shrink: 0;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .95rem; flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #9ca3af;
  padding: .5rem 1.25rem .25rem; display: block;
}
.sidebar-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.25rem; margin: 0 .5rem;
  border-radius: var(--radius-sm); color: #1a1a2e; font-size: .9rem; font-weight: 500;
  text-decoration: none; transition: all var(--transition);
}
.sidebar-link:hover { background: rgba(var(--color-primary-rgb),.07); color: var(--color-primary); text-decoration: none; }
.sidebar-link.active {
  background: rgba(var(--color-primary-rgb),.12);
  color: var(--color-primary); font-weight: 700;
  border-left: 3px solid var(--color-primary);
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.sidebar-link.active svg { opacity: 1; }
.sidebar-footer {
  padding: .875rem 1rem; border-top: 1px solid rgba(var(--color-primary-rgb),.08);
  display: flex; flex-direction: column; gap: .5rem;
}
.sidebar-user {
  display: flex; align-items: center; gap: .75rem; padding: .625rem .75rem;
  border-radius: var(--radius-sm); background: rgba(var(--color-primary-rgb),.05);
}
.sidebar-user-name { font-size: .85rem; font-weight: 700; color: #1a1a2e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .72rem; color: #9ca3af; }
.sidebar-logout {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: #ef4444; font-size: .85rem; font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.sidebar-logout:hover { background: rgba(239,68,68,.08); text-decoration: none; }
.sidebar-logout svg { flex-shrink: 0; }

/* ---------- MAIN CONTENT offset (desktop) ---------- */
@media (min-width: 992px) {
  .main-content { margin-left: 260px; }
}

/* ---------- LANG / DARK TOGGLES ---------- */
.lang-switcher { display: flex; gap: 2px; }
.lang-btn {
  padding: .3rem .6rem; border-radius: var(--radius-sm); font-size: .8rem;
  font-weight: 600; border: 1.5px solid transparent; cursor: pointer;
  background: none; color: #9ca3af; transition: all var(--transition);
}
.lang-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.lang-btn:hover:not(.active) { background: rgba(var(--color-primary-rgb),.08); color: var(--color-primary); }

.dark-toggle-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1.5px solid #e5e7eb; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6b7280; transition: all var(--transition);
}
.dark-toggle-btn:hover { background: rgba(var(--color-primary-rgb),.08); border-color: var(--color-primary); color: var(--color-primary); }
html.dark .dark-toggle-btn { background: #1e1e2e; border-color: rgba(255,255,255,.1); color: #94a3b8; }
html.dark .dark-toggle-btn:hover { background: rgba(var(--color-primary-rgb),.2); }

/* ---------- TELÉFONO PEQUEÑO (< 400px) — gama baja ---------- */
@media (max-width: 400px) {
  .navbar { gap: .4rem; padding: 0 .75rem; }
  .navbar-actions { gap: .35rem; }

  /* Brand text se trunca en lugar de empujar los iconos */
  .navbar-brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }

  /* Botones de idioma más compactos */
  .lang-btn { padding: .25rem .4rem; font-size: .72rem; }

  /* Dark toggle más pequeño */
  .dark-toggle-btn { width: 30px; height: 30px; }
  .dark-toggle-btn [data-dark-icon] { font-size: .85rem; }

  /* Avatar e imagen de usuario más pequeños */
  .avatar { width: 30px; height: 30px; font-size: .78rem; line-height: 30px; }
  #avatar-btn img { width: 30px !important; height: 30px !important; }

  /* Landing */
  .landing-hero  { padding: 2.5rem .875rem 2rem; }
  .hero-stats    { gap: .75rem; flex-direction: column; align-items: center; }
  .hero-stat-num { font-size: 1.45rem; }
  .hero-actions  { gap: .6rem; }
  .hero-actions .btn-lg { padding: .7rem 1.25rem; font-size: .9rem; }
  .cta-card      { padding: 2rem 1.25rem; }
  .cta-title     { font-size: 1.35rem; }
  .cta-actions .btn-lg { padding: .7rem 1.25rem; font-size: .9rem; }
  /* Botón registro en navbar: tamaño compacto */
  .navbar-actions .btn-primary.btn-sm { padding: .4rem .75rem; font-size: .8rem; }
}

/* ---------- TELÉFONO MUY PEQUEÑO (< 360px) — gama muy baja ---------- */
@media (max-width: 360px) {
  .navbar { padding: 0 .6rem; gap: .3rem; }
  .navbar-actions { gap: .25rem; }

  /* Ocultar texto del brand, solo icono */
  .navbar-brand-text { display: none; }
  .navbar-brand-icon { flex-shrink: 0; }

  /* Ocultar lang switcher — deja solo el idioma activo */
  .lang-btn:not(.active) { display: none; }
  .lang-btn.active { padding: .2rem .45rem; font-size: .7rem; }

  .dark-toggle-btn { width: 28px; height: 28px; }
  .avatar { width: 28px; height: 28px; font-size: .75rem; line-height: 28px; }
  #avatar-btn img { width: 28px !important; height: 28px !important; }

  /* Botón registro: solo icono / texto muy corto */
  .navbar-actions .btn-primary.btn-sm { padding: .35rem .6rem; font-size: .75rem; }

  /* Landing */
  .landing-hero  { padding: 2rem .75rem 1.75rem; }
  .hero-badge    { font-size: .72rem; padding: .3rem .75rem; }
  .hero-stats    { gap: .5rem; }
  .hero-stat-num { font-size: 1.3rem; }
  .cta-card      { padding: 1.75rem 1rem; }
}
