/* --- VARIABLES MODERNAS --- */
:root {
  --container: 100%;
  /* Ahora ocupamos todo el ancho disponible */
  --pri: #106942;
  --pri-dark: #0b4d30;
  --pri-light: #e6f2eb;
  --accent: #2e8c56;
  --silver: #b6b5af;
  --bg: #f4f9f4;
  --panel: rgba(255, 255, 255, 0.85);
  --txt: #106942;
  --muted: #6b7280;
  --border: rgba(16, 105, 66, 0.15);
  --radius: 16px;
  --sidebar-w: 320px;
  /* w-72 matches Tailwind's width */

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --ok-bg: #DCFCE7;
  --ok-txt: #166534;
  --warn-bg: #FEF9C3;
  --warn-txt: #854D0E;
  --err-bg: #FEE2E2;
  --err-txt: #991B1B;

  /* Premium Elevations */
  --shadow-premium: 0 10px 40px -10px rgba(0, 0, 0, 0.15);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Source Sans 3', sans-serif;
  background: url('../images/green_logos_bg.png') top left / cover no-repeat fixed #f4f9f4 !important;
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
}

/* --- LAYOUT PRINCIPAL (NUEVO) --- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- SIDEBAR PREMIUM --- */
.sidebar-premium {
  width: var(--sidebar-w) !important;
  background: rgba(255, 255, 255, 0.70) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  color: #106942 !important;
  display: none;
  /* Oculto en móviles por defecto */
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  box-shadow: 10px 0 30px rgba(16, 105, 66, 0.05);
  z-index: 50;
  border-right: 1px solid rgba(16, 105, 66, 0.15);
  overflow: hidden;
}

@media (min-width: 768px) {
  .sidebar-premium {
    display: flex !important;
  }
}



/* --- NAVBAR PREMIUM (TOP) --- */
.navbar-premium {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  padding: 12px 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 45 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02) !important;
}

.btn-premium {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 10px 20px !important;
  border-radius: 12px !important;
  font-weight: 700 !important;
  color: white !important;
  transition: all 0.2s ease-out !important;
  background: linear-gradient(135deg, #106942 0%, #10b981 100%) !important;
  box-shadow: 0 4px 12px rgba(37, 61, 91, 0.15) !important;
  border: none !important;
  cursor: pointer !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em !important;
  font-size: 11px !important;
}

.btn-premium:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25) !important;
  filter: brightness(1.05) !important;
}

.btn-premium:active {
  transform: translateY(0) scale(0.98) !important;
}

.sidebar-header {
  padding: 24px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.sidebar-logo {
  height: 40px;
  width: auto;
}

.sidebar-title {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  color: var(--txt);
}

.sidebar-premium .nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 16px;
  transition: all 0.3s ease;
  color: #475569; /* slate-600 */
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
}

.sidebar-premium .nav-link:hover {
  background-color: rgba(16, 105, 66, 0.05);
  color: #106942 !important;
}

.sidebar-premium .nav-link.active {
  background-color: rgba(16, 105, 66, 0.1) !important;
  color: #106942 !important;
  font-weight: 700;
  box-shadow: inset 0 0 20px rgba(16, 105, 66, 0.02);
  border: 1px solid rgba(16, 105, 66, 0.1);
}

.sidebar-premium .nav-link.active .material-icons {
  color: #106942 !important;
}

.sidebar-premium .nav-link.active .material-icons {
  color: #10b981 !important;
  /* institutional-blue */
}

/* Enlaces del menú (handled via tailwind @apply in HTML now) */
/* Perfil abajo del menú (handled via tailwind @apply in HTML now) */

/* Perfil abajo del menú */
/* Sidebar Footer */
.sidebar-footer {
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.main-content-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-y: auto;
}

.page-footer-unified {
  margin-top: auto;
  padding: 32px 48px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  color: var(-- institutional-gray);
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: white;
  color: var(--pri);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

/* --- CONTENIDO DERECHA --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: calc(100% - var(--sidebar-w));
  /* Evita desbordes horizontales */
}

/* Header blanco limpio */
.appbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--txt);
}

/* Contenedor interno */
.wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
  width: 100%;
}

/* --- RESTO DE ESTILOS (Paneles, Tablas, etc.) --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.panel:hover {
  box-shadow: var(--shadow-md);
}

/* ── SUBCARD ── */
.subcard {
  background: #ffffff;
  border: 1px solid #e8edf4;
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(37,61,91,0.06);
}
.subcard h3 {
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #106942;
  margin: 0 0 1rem 0;
}

/* ── GRID INTERNO ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}
.grid label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
  display: block;
  margin-bottom: 4px;
}
.grid input,
.grid select,
.grid textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  color: #334155;
  background: #f8fafc;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.grid input:focus,
.grid select:focus,
.grid textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(78,108,159,0.1);
  background: #fff;
}
.grid textarea {
  min-height: 80px;
  resize: vertical;
}

/* ── BOTONES ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 1rem;
  border-radius: 0.65rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  background: #106942;
  color: #fff;
}
.btn:hover { background: #10b981; transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: #10b981; }
.btn.no { background: #fee2e2; color: #ef4444; }
.btn.no:hover { background: #fecaca; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

input,
select,
textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--txt);
  outline: none;
  transition: border 0.2s;
}

input:focus,
select:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px var(--pri-light);
}

/* ── TABLAS INTERNAS ── */
.tablewrap { overflow-x: auto; border-radius: 1rem; }
.table-intermedy {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  color: #334155;
}
.table-intermedy thead tr {
  background: #f8fafc;
}
.table-intermedy th {
  padding: 0.6rem 0.75rem;
  font-size: 0.6rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
  white-space: nowrap;
  border-bottom: 1px solid #e8edf4;
}
.table-intermedy td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table-intermedy tbody tr:hover { background: #f8fafc; }
.table-intermedy td input,
.table-intermedy td select {
  padding: 0.3rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  font-size: 0.7rem;
  background: #fff;
  color: #334155;
  min-width: 90px;
}

.table-condensed td,
.table-condensed th {
  padding: 8px 12px;
  font-size: 13px;
}

.table-condensed input,
.table-condensed select {
  padding: 6px 10px;
  font-size: 12px;
  width: 100%;
}

tr:hover td {
  background: var(--pri-light);
}

.idlink {
  color: var(--pri);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.idlink:hover {
  text-decoration: underline;
}

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge.ok  { background: #dcfce7; color: #166534; }
.badge.no  { background: #fee2e2; color: #991b1b; }

/* ── SEMÁFORO ── */
.sem {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px currentColor;
}
.sem.g { background: #22c55e; color: #22c55e; }
.sem.y { background: #eab308; color: #eab308; }
.sem.r { background: #ef4444; color: #ef4444; }

/* ── PILLS (datos rápidos arriba) ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.65rem;
  color: #475569;
  font-weight: 600;
}
.pill b { color: #106942; }

/* ── ROW ── */
.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.row.space { justify-content: space-between; }

/* ── SMALL TEXT ── */
.small {
  font-size: 0.68rem;
  color: #94a3b8;
  margin: 4px 0 0 0;
}

/* ── NOTAS ── */
.subcard ul { margin: 6px 0 0 0; padding-left: 1rem; }
.subcard li {
  margin-bottom: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #475569;
  background: #f8fafc;
  border-left: 3px solid #10b981;
  padding: 8px 12px;
  border-radius: 0 0.5rem 0.5rem 0;
  list-style: none;
}
.subcard li b { color: #106942; font-size: 0.72rem; }

/* ── BANNER TUTELA ── */
.tutela-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #faf5ff, #ede9fe);
  border: 1px solid #c4b5fd;
  border-radius: 0.75rem;
  padding: 10px 16px;
  margin-bottom: 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6d28d9;
}
.tutela-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #7c3aed;
  flex-shrink: 0;
}

td.right { text-align: right; }

/* Modal, Toast y Avatares */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  overflow: hidden;
}

.modal.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  width: min(1200px, 95vw);
  max-height: 90vh;
  margin: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.modal-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-body {
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pri-light), #E9D5FF);
  color: var(--pri);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.role-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.role-admin {
  background: #DBEAFE;
  color: #1E40AF;
}

.role-med {
  background: #FCE7F3;
  color: #9D174D;
}

.role-enf {
  background: #FEF3C7;
  color: #92400E;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: opacity .2s ease;
}

.toast.ok {
  background: #166534;
}

.toast.err {
  background: #991B1B;
}
