/* =========================================
   VARIABLES GLOBALES
   ========================================= */
:root {
  --navy:       #0d1f3c;
  --navy-2:     #162e55;
  --navy-3:     #1e3f73;
  --blue:       #1e4db7;
  --blue-l:     #3b6fd4;
  --sky:        #e8f0fc;
  --sky-2:      #d0e0f8;
  --white:      #ffffff;
  --off:        #f4f7fd;
  --border:     #d6e2f5;
  --text:       #0d1f3c;
  --muted:      #6b7c9e;
  --danger:     #c0392b;
  --r:          10px;
  --sh:         0 2px 12px rgba(13, 31, 60, .08);
  --sh-lg:      0 8px 32px rgba(13, 31, 60, .14);
}

/* =========================================
   RESETEO Y ESTILOS BASE
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--off);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* =========================================
   CABECERA (HEADER) Y NAVEGACIÓN
   ========================================= */
header {
  background: var(--navy);
  padding: 0 2rem;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 16px rgba(13, 31, 60, .3);
}

.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.02em;
}

.logo span {
  color: #7eb3ff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .8rem;
}

.h-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid rgba(255, 255, 255, .2);
}

.h-username {
  font-size: .88rem;
  color: rgba(255, 255, 255, .85);
  font-weight: 500;
}

.admin-badge {
  background: rgba(255, 215, 0, .15);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, .3);
  font-size: .68rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 99px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* =========================================
   BOTONES
   ========================================= */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: .72rem 1.5rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s, transform .15s, opacity .2s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.btn-primary:hover {
  background: var(--blue-l);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.btn-logout {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .15);
  color: rgba(255, 255, 255, .7);
  border-radius: var(--r);
  padding: .38rem .9rem;
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}

.btn-login-header {
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  color: rgba(255, 255, 255, .8);
  border-radius: var(--r);
  padding: .38rem .9rem;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
  transition: all .2s;
  letter-spacing: .02em;
}

.btn-login-header:hover {
  background: rgba(255, 255, 255, .2);
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
}

.btn-confirm-del {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: .65rem 1.5rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}

.btn-confirm-del:hover {
  background: #a93226;
}

.btn-cancel-del {
  background: var(--off);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .65rem 1.4rem;
  font-size: .9rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
}

/* =========================================
   FORMULARIOS
   ========================================= */
input[type=text],
input[type=password],
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .75rem 1rem;
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--white);
  outline: none;
  resize: none;
  display: block;
  transition: border-color .2s, box-shadow .2s;
  margin-bottom: .75rem;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 77, 183, .1);
}

textarea {
  min-height: 90px;
}

/* =========================================
   COMPONENTES (Tarjetas, Alertas, Modales)
   ========================================= */
.card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--sh);
}

.error-msg {
  background: #fdf2f2;
  border: 1.5px solid #f5c0bc;
  color: var(--danger);
  border-radius: var(--r);
  padding: .65rem 1rem;
  font-size: .85rem;
  margin-bottom: 1rem;
  display: none;
}

.error-msg.show {
  display: block;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy);
  color: #fff;
  padding: .7rem 1.5rem;
  border-radius: 99px;
  font-size: .88rem;
  font-weight: 500;
  transition: transform .3s ease;
  z-index: 999;
  box-shadow: var(--sh-lg);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(13, 31, 60, .45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-bg.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border-radius: 16px;
  padding: 2.2rem 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--sh-lg);
  transform: translateY(16px) scale(.97);
  transition: transform .25s;
}

.modal-bg.open .modal {
  transform: none;
}

.modal-icon {
  font-size: 2.2rem;
  margin-bottom: .6rem;
}

.modal h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .4rem;
}

.modal p {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 1.6rem;
}

.modal-btns {
  display: flex;
  gap: .75rem;
  justify-content: center;
}

/* =========================================
   UTILIDADES Y ESTADOS (Loading, Empty)
   ========================================= */
.loading {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem;
  font-size: .9rem;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: .5rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 4rem 1rem;
  font-size: .95rem;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .5;
}

/* =========================================
   ANIMACIONES
   ========================================= */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.fade-up {
  animation: fadeUp .35s ease both;
}

/* =========================================
   MEDIA QUERIES (Responsive)
   ========================================= */
@media(max-width: 520px) {
  header {
    padding: 0 1rem;
  }
  
  .h-username {
    display: none;
  }
}
