/* =============================================
   OLVISIÓN — Estilos compartidos y responsive
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: #f1f5f9;
  min-height: 100vh;
}

/* ── VARIABLES ── */
:root {
  --azul: #1E3A8A;
  --azul-claro: #93c5fd;
  --amarillo: #f9f4ab;
  --rojo: #ef4444;
  --verde: #10b981;
  --gris: #f1f5f9;
  --texto: #1e293b;
  --sub: #64748b;
  --borde: #e2e8f0;
}

/* ── LAYOUT BASE (mobile) ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main {
  padding: 16px 16px 120px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ── TOP NAV (mobile) ── */
.nav {
  background: var(--azul);
  padding: max(16px, env(safe-area-inset-top)) 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-back { color: var(--azul-claro); font-size: 22px; text-decoration: none; }
.nav-title { color: white; font-size: 18px; font-weight: 800; }
.nav-sub { color: var(--azul-claro); font-size: 12px; font-weight: 600; }
.nav-salir {
  color: var(--azul-claro); font-size: 13px; font-weight: 700;
  cursor: pointer; text-decoration: none;
  padding: 6px 14px; border: 1px solid #3b82f6; border-radius: 20px;
}

/* ── BOTTOM NAV (mobile) ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--borde);
  display: flex; padding: 8px 0 max(20px, env(safe-area-inset-bottom)); z-index: 100;
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  text-decoration: none; padding: 6px 0; cursor: pointer;
}
.bnav-icon { font-size: 22px; }
.bnav-label { font-size: 10px; font-weight: 700; color: #94a3b8; }
.bnav-item.activo .bnav-label { color: var(--azul); }

/* ── SIDEBAR (desktop — oculto en mobile) ── */
.sidebar {
  display: none;
}

/* ── CARDS Y COMPONENTES ── */
.card {
  background: white;
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.btn-primario {
  background: var(--amarillo); color: var(--azul);
  border: none; border-radius: 16px; padding: 16px;
  width: 100%; font-size: 16px; font-weight: 800;
  cursor: pointer; font-family: 'Nunito', sans-serif;
  transition: opacity 0.15s;
}
.btn-primario:active { opacity: 0.85; }

.btn-guardar {
  background: var(--azul); color: white; border: none;
  border-radius: 16px; padding: 18px; width: 100%;
  font-size: 17px; font-weight: 800; cursor: pointer;
  font-family: 'Nunito', sans-serif; margin-top: 8px;
  transition: opacity 0.15s;
}
.btn-guardar:active { opacity: 0.85; }

.btn-cancelar {
  background: var(--gris); color: var(--sub); border: none;
  border-radius: 16px; padding: 14px; width: 100%;
  font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: 'Nunito', sans-serif; margin-top: 8px;
}

.campo { margin-bottom: 14px; }
.campo label {
  display: block; font-size: 12px; font-weight: 700;
  color: #475569; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px;
}
.campo input, .campo select, .campo textarea {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--borde); border-radius: 14px;
  font-size: 16px; font-family: 'Nunito', sans-serif;
  color: var(--texto); background: white; outline: none;
  transition: border-color 0.2s; -webkit-appearance: none;
}
.campo input:focus, .campo select:focus,
.campo textarea:focus { border-color: var(--azul); }
.campo textarea { resize: none; height: 80px; }
.campos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: #f1f5f9; color: #475569;
  display: inline-block;
}
.tag.verde { background: #d1fae5; color: #065f46; }
.tag.rojo { background: #fee2e2; color: #991b1b; }
.tag.amarillo { background: var(--amarillo); color: var(--azul); }
.tag.azul { background: #dbeafe; color: #1e40af; }
.tag.cat { background: #dbeafe; color: #1e40af; }
.tag.retiro { background: var(--amarillo); color: var(--azul); }

.empty { text-align: center; padding: 40px 20px; color: #94a3b8; font-size: 14px; }
.section-title { font-size: 15px; font-weight: 800; color: var(--texto); margin-bottom: 12px; }

/* ── MODAL ── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  align-items: flex-end; justify-content: center;
}
.overlay.visible { display: flex; }
.modal {
  background: white; border-radius: 24px 24px 0 0;
  padding: 24px 20px 40px; width: 100%; max-width: 540px;
  max-height: 92vh; overflow-y: auto;
}
.modal-titulo {
  font-size: 20px; font-weight: 800; color: var(--texto);
  margin-bottom: 20px; text-align: center;
}

/* ══════════════════════════════════════════════
   DESKTOP — a partir de 768px
   ══════════════════════════════════════════════ */
@media (min-width: 768px) {

  /* Ocultar top nav y bottom nav en desktop */
  .nav { display: none; }
  .bottom-nav { display: none; }

  /* Mostrar sidebar */
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 240px;
    min-height: 100vh;
    background: var(--azul);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    padding: 32px 16px 24px;
    z-index: 50;
  }

  .sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    color: white; font-size: 20px; font-weight: 800;
    margin-bottom: 36px; padding: 0 8px;
  }
  .sidebar-brand span { font-size: 28px; }

  .sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

  .snav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 14px;
    text-decoration: none; color: var(--azul-claro);
    font-size: 15px; font-weight: 700;
    transition: background 0.15s;
  }
  .snav-item:hover { background: rgba(255,255,255,0.1); }
  .snav-item.activo { background: rgba(255,255,255,0.15); color: white; }
  .snav-icon { font-size: 20px; width: 28px; text-align: center; }

  .sidebar-footer {
    padding: 0 8px;
  }
  .btn-salir-sidebar {
    display: flex; align-items: center; gap: 10px;
    color: var(--azul-claro); font-size: 14px; font-weight: 700;
    background: none; border: none; cursor: pointer;
    font-family: 'Nunito', sans-serif; padding: 10px 6px;
    width: 100%;
  }

  /* Desplazar contenido para que no quede bajo la sidebar */
  .app-content { margin-left: 240px; }

  /* Contenido más ancho */
  .main {
    padding: 32px 32px 60px;
    max-width: 900px;
  }

  /* Modal centrado en desktop */
  .overlay { align-items: center; }
  .modal {
    border-radius: 24px;
    max-height: 85vh;
    margin: 20px;
  }

  /* Grids más amplios */
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-card.full { grid-column: 1 / -1; }
  .modulos { grid-template-columns: repeat(4, 1fr); }
  .cats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1100px) {
  .main { max-width: 1000px; }
}
