/* ═══════════════════════════════════════════════════════════════
   ACES Cities Network — Layouts
   Shell, sidebar, topbar, bottom nav, contenedores de página
═══════════════════════════════════════════════════════════════ */

/* ── App Shell ── */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-mid) 0%, var(--bg) 100%);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s var(--ease);
  z-index: 50;
}

/* Logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-logo img { height: 28px; width: auto; }
.sidebar-logo-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
}

/* Nav section */
.sidebar-section {
  padding: 12px 10px 4px;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 8px;
  margin-bottom: 4px;
}

/* Nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-1);
}
.nav-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid rgba(0,207,200,0.2);
}
.nav-item.active svg { color: var(--cyan); }

/* Notification badge on nav item */
.nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  background: var(--danger);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

/* User area at bottom */
.sidebar-user {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.sidebar-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  width: 100%;
  background: none;
  border: none;
  transition: background 0.15s;
  text-align: left;
  overflow: hidden;
}
.sidebar-user-btn:hover { background: rgba(255,255,255,0.06); }
.sidebar-user-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}
.sidebar-user-chevron { color: var(--text-3); flex-shrink: 0; }
.sidebar-user-chevron svg { width: 14px; height: 14px; }

/* ── Main content area ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Top bar ── */
#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 var(--pad);
  gap: 12px;
  background: rgba(8, 15, 30, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Idioma selector en topbar */
.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover { background: rgba(255,255,255,0.10); color: var(--text-1); }
.lang-btn svg { width: 14px; height: 14px; }

/* Notif button */
.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
}
.notif-btn:hover { background: rgba(255,255,255,0.10); color: var(--text-1); }
.notif-btn svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  border-radius: 8px;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ── Page content ── */
#app-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.page {
  padding: var(--pad);
  max-width: 1200px;
}

.page-full {
  padding: var(--pad);
}

/* Columnas */
.page-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.page-cols-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* ── Bottom nav (móvil) ── */
#bottomnav {
  display: none;
  height: var(--bottomnav-h);
  background: linear-gradient(0deg, var(--bg) 0%, var(--bg-mid) 100%);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}
.bottomnav-inner {
  display: flex;
  height: 100%;
  padding: 0 4px;
}
.bottomnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: rgba(255,255,255,0.40);
  transition: color 0.15s;
  position: relative;
  border-radius: 12px;
  margin: 4px 2px;
}
.bottomnav-item svg { width: 22px; height: 22px; }
.bottomnav-item span {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}
.bottomnav-item.active {
  color: var(--cyan);
  background: rgba(0,207,200,0.08);
  border: 1px solid rgba(0,207,200,0.18);
}
.bottomnav-item .nav-badge {
  position: absolute;
  top: 4px; right: 6px;
  margin: 0;
}

/* ── Auth layout ── */
#auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg) 100%);
}

.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px var(--pad) 80px;
  min-height: 100vh;
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}
.auth-logo img { height: 60px; width: auto; }
.auth-logo-sub {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 24px;
  line-height: 1.4;
  font-weight: 300;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-3);
}
.auth-footer a {
  color: var(--cyan);
  font-weight: 600;
  text-decoration: none;
}
.auth-footer a:hover { text-decoration: underline; }

/* Auth bottom logo */
.auth-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px var(--pad);
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.auth-bottom img { height: 20px; width: auto; opacity: 0.4; }
.auth-bottom span { font-size: 11px; color: var(--text-3); }

/* ── Loading screen ── */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 1000;
}
.loading-logo { height: 56px; width: auto; opacity: 0.85; }
.loading-spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Responsive ── */

/* Tablet: 640–1024px */
@media (max-width: 1024px) and (min-width: 641px) {
  #sidebar {
    width: var(--sidebar-w-tablet);
  }
  .sidebar-logo-text,
  .nav-item span,
  .sidebar-section-label,
  .sidebar-user-info { display: none; }
  .sidebar-logo { justify-content: center; padding: 16px 12px; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-user-btn { justify-content: center; }
  .sidebar-section { padding: 8px 6px 4px; }
  .nav-badge { position: absolute; top: 2px; right: 2px; }
  .sidebar-user-chevron { display: none; }

  .page-cols   { grid-template-columns: 1fr; }
  .page-cols-3 { grid-template-columns: 1fr 1fr; }
}

/* Móvil: < 641px */
@media (max-width: 640px) {
  #sidebar { display: none; }
  #bottomnav { display: flex; }

  #main { padding-bottom: 0; }
  #topbar { padding: 0 14px; }
  .topbar-title { font-size: 16px; }

  .page, .page-full { padding: 14px; }
  .page-cols, .page-cols-3 { grid-template-columns: 1fr; }
  .access-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .auth-container { padding: 20px 16px 80px; justify-content: flex-start; padding-top: 40px; }
  .auth-card { padding: 20px 18px; }
  .modal { margin: auto; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 85vh; }
}

/* ── User menu dropdown ── */
.user-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px; right: 8px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px;
  z-index: 200;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
}
.user-menu-item:hover { background: rgba(255,255,255,0.07); color: var(--text-1); }
.user-menu-item.danger { color: var(--danger); }
.user-menu-item.danger:hover { background: rgba(239,68,68,0.1); }
.user-menu-item svg { width: 16px; height: 16px; }
.user-menu-sep { height: 1px; background: var(--border-soft); margin: 4px 0; }
