/* ============================================================
   ADESCOEDO — Sistema de Gestión Hídrica
   styles.css — Hoja de estilos global
   Asociación de Desarrollo Comunal Estrellas de Oro
   Cantón Las Marías, Jocoro, Morazán
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Barlow+Condensed:wght@700;800&display=swap');

/* ── Variables de diseño ── */
:root {
  --navy:          #1a2340;
  --navy-mid:      #243055;
  --gold:          #d4a017;
  --gold-light:    #f0c040;

  --water-deep:    #0d4f6e;
  --water-mid:     #1a7fa8;
  --water-light:   #4ab0d4;
  --water-pale:    #dff3fb;
  --water-surface: #eef8fc;

  --success:       #2e8b57;
  --warning:       #d4a017;
  --danger:        #c0392b;

  --white:         #ffffff;
  --muted:         #7a8fa6;
  --border:        rgba(26, 127, 168, 0.18);

  --sidebar-w:     210px;
  --topbar-h:      56px;

  --radius-sm:     6px;
  --radius-md:     8px;
  --radius-lg:     12px;

  --font-main:    'Barlow', sans-serif;
  --font-display: 'Barlow Condensed', sans-serif;
}

/* ── Reset base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: var(--water-surface);
  color: var(--navy);
  font-size: 14px;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: var(--water-mid);
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; 
  top: 0;
  left: 0;
  width: 250px; /* Ancho fijo garantizado */
  height: 100vh; 
  z-index: 1000; 
  transition: transform 0.3s ease; /* Animación suave */
  background: var(--navy, #1a2233); /* Respaldo de color por si falla la variable */
}

.sidebar--admin     { background: var(--navy); }
.sidebar--secretary { background: var(--water-deep); }
.sidebar--tech      { background: #0d2d3e; }

/* Clases que activa el JavaScript */
.sidebar--oculto {
  transform: translateX(-100%);
}

/* Logo del sidebar */
.sidebar__logo {
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__stars {
  display: flex;
  gap: 3px;
}

.sidebar__star {
  color: var(--gold);
  font-size: 10px;
}

.sidebar__brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--gold);
}

.sidebar__tagline {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.4;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* Badge de rol */
.sidebar__role-badge {
  margin: 12px 12px 4px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.sidebar__role-badge--admin     { background: rgba(212,160,23,0.15); color: var(--gold-light); }
.sidebar__role-badge--secretary { background: rgba(74,176,212,0.2);  color: #90d8f0; }
.sidebar__role-badge--tech      { background: rgba(255,255,255,0.08); color: #b0c8d8; }

/* Sección de navegación */
.nav__section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 16px 16px 6px;
  color: rgba(255, 255, 255, 0.35);
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  color: rgba(255, 255, 255, 0.55);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav__item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav__item.is-active {
  color: #fff;
  background: rgba(74, 176, 212, 0.12);
  border-left-color: var(--water-light);
}

.nav__item.is-active--gold {
  background: rgba(212, 160, 23, 0.12);
  border-left-color: var(--gold);
}

.nav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

/* Footer del sidebar */
.sidebar__footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__user-name  { font-size: 12px; font-weight: 600; color: #fff; }
.sidebar__user-role  { font-size: 10px; color: rgba(255, 255, 255, 0.45); }

/* ── Área principal ── */
.main-content {
  margin-left: 250px; /* Empuja el contenido exactamente el ancho del sidebar */
  width: calc(100% - 250px);
  min-height: 100vh;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.main-content--expandido {
  margin-left: 0;
  width: 100%;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--navy);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__date {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Contenido scrollable ── */
.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
}

/* ============================================================
   COMPONENTES REUTILIZABLES
   ============================================================ */

/* ── Avatar ── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar--admin     { background: rgba(212,160,23,0.18); color: #8a6000; }
.avatar--secretary { background: rgba(26,127,168,0.12); color: var(--water-deep); }
.avatar--tech      { background: rgba(255,255,255,0.1);  color: #b0c8d8; }
.avatar--sidebar   { width: 32px; height: 32px; }

/* ── Botón de notificación ── */
.notif-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--water-pale);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
}

.notif-btn__dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  border: 1.5px solid white;
}

.notif-btn--danger { background: rgba(192,57,43,0.08); border-color: rgba(192,57,43,0.3); }

/* ── Grilla de KPIs ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.kpi-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  margin-bottom: 10px;
}

.kpi-card__icon--blue   { background: rgba(26,127,168,0.10); }
.kpi-card__icon--gold   { background: rgba(212,160,23,0.12); }
.kpi-card__icon--green  { background: rgba(46,139,87,0.10); }
.kpi-card__icon--red    { background: rgba(210,80,30,0.08); }

.kpi-card__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.kpi-card__value--blue   { color: var(--water-deep); }
.kpi-card__value--navy   { color: var(--navy); }
.kpi-card__value--green  { color: var(--success); }
.kpi-card__value--red    { color: var(--danger); }

.kpi-card__unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

.kpi-card__trend {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend--up   { color: var(--success); }
.trend--down { color: var(--danger); }
.trend--ok   { color: var(--water-mid); }

/* ── Grilla de secciones ── */
.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.section-card--full {
  grid-column: 1 / -1;
}

.section-card__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-card__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-card__body {
  padding: 16px;
}

.section-card__body--no-pad {
  padding: 0;
}

/* ── Badges ── */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--gold  { background: rgba(212,160,23,0.15); color: #8a6000; }
.badge--blue  { background: rgba(26,127,168,0.12); color: var(--water-deep); }
.badge--green { background: rgba(46,139,87,0.12);  color: #1a5c35; }
.badge--red   { background: rgba(210,80,30,0.10);  color: #8a3010; }

/* ── Tabla de datos ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  text-align: left;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(26, 127, 168, 0.06);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table td.is-bold {
  font-weight: 600;
}

/* ── Pills de estado ── */
.status-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill--active  { background: rgba(46,139,87,0.12);  color: #1a5c35; }
.status-pill--issue   { background: rgba(210,80,30,0.10);  color: #8a3010; }
.status-pill--pending { background: rgba(212,160,23,0.15); color: #8a6000; }

/* ── Barras de progreso ── */
.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.meter-row:last-child {
  margin-bottom: 0;
}

.meter__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  width: 80px;
  flex-shrink: 0;
}

.meter__track {
  flex: 1;
  height: 8px;
  background: var(--water-pale);
  border-radius: 4px;
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  border-radius: 4px;
}

.meter__fill--blue  { background: var(--water-mid); }
.meter__fill--green { background: var(--success); }
.meter__fill--gold  { background: var(--gold); }

.meter__value {
  font-size: 11px;
  font-weight: 700;
  width: 60px;
  text-align: right;
}

/* ── Alertas ── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border-left: 3px solid;
}

.alert-item:last-child {
  margin-bottom: 0;
}

.alert-item--error   { background: rgba(210,80,30,0.07);  border-left-color: var(--danger); }
.alert-item--warning { background: rgba(212,160,23,0.08); border-left-color: var(--gold); }
.alert-item--success { background: rgba(46,139,87,0.07);  border-left-color: var(--success); }

.alert-item__icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-item__title {
  font-size: 12px;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
  color: var(--navy);
}

.alert-item__text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Gráfico de barras CSS ── */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 90px;
  padding: 0 4px;
}

.chart-bar__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.chart-bar__bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: opacity 0.2s;
  cursor: pointer;
}

.chart-bar__bar:hover { opacity: 0.75; }

.chart-bar__bar--normal  { background: var(--water-light); }
.chart-bar__bar--current { background: var(--water-mid); border: 2px solid var(--water-deep); }
.chart-bar__bar--future  { background: rgba(26,127,168,0.2); }

.chart-bar__label {
  font-size: 9px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

.chart-bar__label--current {
  color: var(--water-deep);
  font-weight: 800;
}

.chart-summary {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

/* ── Formularios ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input,
.form-select {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--water-surface);
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--navy);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--water-mid);
  background: var(--white);
}

.form-textarea {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--water-surface);
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--navy);
  resize: vertical;
  min-height: 72px;
  outline: none;
}

.form-textarea:focus {
  border-color: var(--water-mid);
  background: var(--white);
}

/* ── Botones ── */
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover   { opacity: 0.88; }
.btn:active  { transform: scale(0.98); }

.btn--primary { background: var(--water-mid); color: #fff; }
.btn--gold    { background: var(--gold);      color: var(--navy); }
.btn--danger  { background: var(--danger);    color: #fff; }
.btn--success { background: var(--success);   color: #fff; }

.btn--outline {
  background: transparent;
  border: 1.5px solid var(--water-mid);
  color: var(--water-mid);
}

.btn--full { width: 100%; }

/* ── Card de lectura (Técnico) ── */
.reading-card {
  background: var(--water-deep);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: #fff;
  margin-bottom: 14px;
}

.reading-card__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-bottom: 6px;
}

.reading-card__value {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
}

.reading-card__unit {
  font-size: 14px;
  opacity: 0.65;
  margin-top: 4px;
}

/* ── Items de agenda (Técnico) ── */
.schedule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.schedule-item:last-child {
  border-bottom: none;
}

.schedule-item__time {
  font-weight: 700;
  color: var(--water-deep);
  width: 52px;
  flex-shrink: 0;
  padding-top: 1px;
}

.schedule-item__task   { font-weight: 600; color: var(--navy); }
.schedule-item__task--urgent { color: var(--danger); }
.schedule-item__location { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Mapa placeholder (Técnico) ── */
.map-placeholder {
  background: linear-gradient(135deg, #c8e6f5, #a8d4e8 50%, #88bfd8);
  border-radius: var(--radius-md);
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.map-dot {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.map-dot--green  { background: var(--success); }
.map-dot--red    { background: var(--danger); box-shadow: 0 0 0 5px rgba(192,57,43,0.25); }
.map-dot--blue   { background: var(--water-mid); }

.map-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--water-deep);
  background: rgba(255, 255, 255, 0.88);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.map-legend {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Card de campo técnico ── */
.field-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-card:last-child {
  margin-bottom: 0;
}

.field-card__name   { font-size: 13px; font-weight: 700; color: var(--navy); }
.field-card__detail { font-size: 11px; color: var(--muted); margin-top: 2px; }

.field-card__actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--water-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--water-light);
}

/* ============================================================
   RESPONSIVE — tablet / móvil básico
   ============================================================ */

@media (max-width: 1024px) {
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/*@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
  position: fixed; 
  top: 0;
  left: 0;
  height: 100vh; 
  z-index: 1000; 
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15);
  background: var(--navy); 
  }

  .section-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-field--full {
    grid-column: 1;
  }
}*/

@media screen and (max-width: 768px) {
  
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5); /* Sombra para que resalte al salir */
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .sidebar:not(.sidebar--oculto) {
    transform: translateX(0);
  }
}

/* =========================================
   ANIMACIONES DEL MENÚ LATERAL (JAVASCRIPT)
   ========================================= */

.sidebar, .main-content {
  transition: transform 0.3s ease, margin-left 0.3s ease, width 0.3s ease;
}

.sidebar--oculto {
  transform: translateX(-100%); /* Lo mueve hacia la izquierda fuera de la pantalla */
}

.main-content--expandido {
  margin-left: 0;
  width: 100%;
}

/* =========================================
   VENTANAS MODALES
   ========================================= */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 2000; /* Por encima del sidebar */
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Oculto por defecto */
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.modal--active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: white;
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal-overlay.modal--active .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
}

.btn-close {
  background: none; border: none; font-size: 20px; cursor: pointer; color: #888;
}
.btn-close:hover { color: var(--danger); }

/* =========================================
   DISEÑO DE TABLAS (UX)
   ========================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  font-size: 0.95rem;
  background-color: white;
}

.table th {
  background-color: #f4f6f8; /* Gris muy suave para el encabezado */
  color: #333;
  text-align: left;
  padding: 14px 15px;
  border-bottom: 2px solid #e0e0e0;
  font-weight: 600;
}

.table td {
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  color: #555;
  vertical-align: middle;
}

/* Efecto al pasar el mouse sobre una fila */
.table tbody tr:hover {
  background-color: #f9fbfd;
  transition: background-color 0.2s ease;
}

/* Contenedor para alinear los botones de acción */
.acciones-td {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Estilo para los botones de íconos (Imprimir, Eliminar) */
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-icon:hover { background: #e9ecef; }
.btn-print:hover { background: #e0f0ff; /* Azul claro */ }
.btn-delete:hover { background: #ffe6e6; /* Rojo claro */ }
.btn-edit:hover { background: #fff4cc; /* Amarillo pastel suave */ }