/* ============================================================
   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 .brand-logo { display: inline-flex; }
  .navbar .brand-megacity { font-size: 1rem; }
  .navbar .brand-id       { font-size: 1.05rem; }
  .navbar-actions .btn-text { display: none; }

  .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; }
  .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-hero { padding: 5rem 1rem 3rem; }
  .hero-title   { font-size: 2rem; }
  .hero-sub     { font-size: 1rem; }
  .features-grid { grid-template-columns: 1fr; gap: 1rem; }
  .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: .75rem; flex-wrap: nowrap; overflow: visible;
  box-shadow: 0 1px 12px rgba(0,0,0,.06);
}
.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 {
  font-size: 1.15rem; font-weight: 800; color: var(--color-primary);
  letter-spacing: -.02em; flex: 1; min-width: 0; text-decoration: none;
}
.navbar-brand:hover { text-decoration: none; }

/* === Logo MegacityID === */
.brand-logo {
  display: inline-flex; align-items: baseline; gap: 0;
  line-height: 1; white-space: nowrap;
}
.brand-megacity {
  font-weight: 800; color: var(--color-primary);
  letter-spacing: -.03em;
}
.brand-id {
  font-weight: 900; color: var(--color-accent);
  letter-spacing: -.04em;
}
.navbar .brand-megacity { font-size: 1.18rem; }
.navbar .brand-id       { font-size: 1.25rem; }
.sidebar-brand .brand-megacity { font-size: 1.05rem; }
.sidebar-brand .brand-id       { font-size: 1.1rem; }
html.dark .brand-megacity { color: #f1f5f9; }
.navbar-actions {
  display: flex; align-items: center; gap: .6rem; flex-shrink: 0;
}

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

@media (max-width: 575.98px) {
  /* En móvil ocultar lang-switcher del navbar (queda en sidebar) */
  .navbar .lang-switcher { display: none; }
  .navbar-actions { gap: .4rem; }
  .navbar { padding: 0 .75rem; gap: .4rem; }
}

/* ---------- 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: var(--color-primary);
  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: #4b5563; 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: 1rem; border-top: 1px solid rgba(var(--color-primary-rgb),.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: .75rem; padding: .75rem;
  border-radius: var(--radius-sm); background: rgba(var(--color-primary-rgb),.05);
}
.sidebar-user-name { font-size: .85rem; font-weight: 700; color: #1a1a2e; }
.sidebar-user-role { font-size: .75rem; color: #9ca3af; }

/* ---------- 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); }
