/* ============ Variables estructurales (no-colores) ============ */
:root{
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  --radius: var(--radius, 14px);
  --shadow: var(--shadow-elev, 0 8px 24px rgba(0,0,0,.25));
  --nav-height: 56px;
  --underline-h: 2px;
}

/* ============ Reset básico ============ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ Topbar fija ============ */
.topbar{
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface-1, var(--bg));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  z-index: 1000;
}

.topbar-container{
  height: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* izquierda | centro | derecha */
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  max-width: 1280px;
  margin: 0 auto;
}

/* Marca izquierda (opcional) */
.brand .brand-link{
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: .2px;
}
.brand .brand-link:hover{ color: var(--text); }

/* Menú centrado */
.nav-center{
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-link{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  height: calc(var(--nav-height) - 2px);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: .2px;
  transition: color .2s ease;
  white-space: nowrap;
}

.nav-link:hover{ color: var(--text); }

/* Subrayado estilo "activo" */
.nav-link.active{
  color: var(--text);
}
.nav-link.active::after{
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--underline-h);
  background: var(--brand-gradient);
  border-radius: 2px 2px 0 0;
}

/* Acciones a la derecha */
.actions-right{
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.icon-btn{
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: 10px;
  line-height: 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .05s ease, box-shadow .15s ease;
}
.icon-btn:hover{ color: var(--text); background: var(--surface-3); }
.icon-btn:active{ transform: translateY(1px); }
.icon-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* Avatar + fallback por inicial */
.avatar{
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
  box-shadow: 0 0 0 1px var(--border);
}

.avatar-fallback{
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #0b0b0d;
  background: linear-gradient(135deg, var(--brand-3), var(--brand-1));
}

.avatar-link{ display:inline-block; line-height:0; border-radius:50%; }
.avatar-link:focus-visible, .avatar-fallback:focus-visible{ outline:none; box-shadow: 0 0 0 3px var(--ring); }
.avatar-fallback{ text-decoration:none; color:#0b0b0d; }

/* Contenido con offset por la barra fija */
.page{
  min-height: 100%;
  padding: calc(var(--nav-height) + 16px) 16px 24px;
}

/* Tipografía base y helpers */
h1,h2,h3{ margin: 0 0 8px; font-weight: 600; }
p{ color: var(--muted); line-height: 1.55; }

/* Responsivo: scroll horizontal suave si no entra todo el menú */
@media (max-width: 720px){
  .nav-center{
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .brand{ display: none; }
}

/* ============ Botones globales ============ */
.btn{
  appearance: none;
  font: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .05s ease, filter .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled{ opacity: .6; cursor: not-allowed; }

/* Variantes */
.btn-primary{
  border: 1px solid transparent;
  background: var(--brand-gradient);
  color: #fff;
}
.btn-primary:hover{ filter: brightness(1.05); }
.btn-primary:active{ transform: translateY(1px); }

.btn-ghost{
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover{ background: var(--surface-3); }

/* Utilidades */
.btn-sm{ padding: 6px 10px; border-radius: 8px; }
.btn-lg{ padding: 12px 18px; border-radius: 12px; }
.btn-block{ display: flex; width: 100%; }
.muted{ color: var(--muted); }

/* ====== Cards (global) ====== */
.card{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title{
  margin: 0 0 14px;
  font-size: 20px;
  color: var(--text);
}

/* ====== Forms (global) ====== */
.form-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label{
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

/* Controles base */
.form-grid input,
.form-grid select,
.form-grid textarea{
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  padding: 0 12px;
}
.form-grid textarea{
  min-height: 96px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus{
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

/* Acciones de formulario */
.form-actions{
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Estado readonly global, sutil */
.form-grid input[readonly],
.form-grid select[readonly],
.form-grid textarea[readonly]{
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--muted);
}
.form-grid input[readonly]:focus,
.form-grid input[readonly]:focus-visible,
.form-grid select[readonly]:focus,
.form-grid textarea[readonly]:focus{
  outline: none;
  box-shadow: none;
  border-color: var(--border);
}

/* Avatares grandes reutilizables */
.big-avatar,
.avatar-lg{
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 32px;
  color: #0b0b0d;
}
.big-avatar.fallback,
.avatar-lg.fallback{
  background: linear-gradient(135deg, var(--brand-3), var(--brand-1));
}

/* Contenedor fluido con padding adaptable */
.wrap{
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: clamp(12px, 3vw, 24px);
}

/* Tipografía fluida */
h1{ font-size: clamp(24px, 3.2vw, 40px); line-height: 1.15; }
h2{ font-size: clamp(20px, 2.6vw, 28px); line-height: 1.2; }
h3{ font-size: clamp(18px, 2.2vw, 22px); }
body, .text-base{ font-size: clamp(14px, 1.6vw, 16px); }

/* Botones: padding adaptable y opción “full width” en móvil */
.btn{ padding: clamp(10px, 1.8vw, 12px) clamp(12px, 2.8vw, 16px); }
.btn-block-sm{ width: 100%; }
@media (min-width: 768px){ .btn-block-sm{ width: auto; } }

/* Imágenes / embeds responsivos */
img, video, svg{ max-width: 100%; height: auto; }

/* Tablas, bloques anchos, etc. */
.responsive-scroll{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========= Navbar / Drawer ========= */
.nav{
  display: grid;
  grid-template-columns: auto 1fr auto; /* brand | center | right */
  align-items: center;
  gap: 16px;
}

/* Centro oculto en móvil; aparece el botón */
.nav-toggle{
  display: none; appearance: none; background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px; padding: 6px; cursor: pointer;
}
.nav-toggle:hover{ background: var(--surface-3); color: var(--text); }

/* Drawer móvil */
.nav-drawer{
  position: fixed;
  top: var(--nav-height); right: 0; bottom: 0;
  height: calc(100vh - var(--nav-height));
  width: min(50vw, 360px);
  background: var(--surface-2);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);

  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 999;

  display: grid;
  gap: 6px;
  align-content: start;
  grid-auto-rows: min-content;
  padding: 12px 16px;
  overflow-y: auto;
  --drawer-fs: clamp(16px, 4.4vw, 18px);
}
.nav-drawer.open{ transform: translateX(0); }

/* Links del drawer */
.nav-drawer .nav-item{
  display: block;
  margin: 0;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;

  font-size: var(--drawer-fs);
  font-weight: 500;
  line-height: 1.35;
  padding: 12px 14px;
}
.nav-drawer .nav-item:hover{ background: var(--surface-3); }

/* Backdrop */
.nav-drawer-backdrop{
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(1px);
  z-index: 998;
   top: var(--nav-height);
}

.nav-drawer .nav-item.active{
  background: var(--surface-3);
  font-weight: 600;
}

/* En pantallas pequeñas: escondemos centro, mostramos toggle */
@media (max-width: 768px){
  .nav-center{ display: none; }
  .nav-toggle{ display: inline-flex; }
}

/* Centro desplazable en tablets */
@media (max-width: 1024px) and (min-width: 769px){
  .nav-center{
    display: flex; gap: 16px; overflow-x: auto; padding-block: 4px;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  }
  .nav-center .nav-link{ scroll-snap-align: start; }
}

/* ========= Grillas y helpers ========= */
.grid-2{
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 900px){
  .grid-2{ grid-template-columns: 1fr; }
}

.section{
  padding-block: clamp(20px, 4vw, 40px);
}


/* ========== Notificaciones (campanita + dropdown) ========== */

.notif-wrapper {
  position: relative;
}

.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
   cursor: pointer;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #0b0b0d;
  background: var(--brand-1, gold); /* color de tu theme */
  box-shadow: 0 0 0 1px var(--border);
}

/* Dropdown */
.notif-dropdown {
  position: absolute;
  right: 0;
  margin-top: 8px;
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
  z-index: 1200;
}

.notif-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  text-align: left;
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notif-list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.notif-list li:last-child {
  border-bottom: none;
}

.notif-list li.unread {
  background: rgba(255, 215, 0, 0.1); /* leve resalto dorado */
}

.notif-empty {
  padding: 12px;
  text-align: center;
  color: var(--muted);
}


/* Ajustes generales: que nunca exceda el viewport */
.notif-dropdown{
  width: min(360px, 92vw);
  max-height: calc(100vh - var(--nav-height) - 24px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Móvil: usar posicionamiento fijo y ocupar el ancho visible */
@media (max-width: 768px){
  .notif-wrapper{ position: static; } /* evita recortes del contenedor */
  .notif-dropdown{
    position: fixed;
    top: calc(var(--nav-height) + 8px);
    left: 8px;
    right: 8px;
    width: auto;              /* ignora el min(360px,92vw) y respeta left/right */
    margin-top: 0;
    border-radius: 12px;
    z-index: 1200;            /* por encima del drawer/backdrop */
  }
}