/* ==========================================================================
   NEXUSPM 360 - ENTERPRISE PROJECT MANAGEMENT DESIGN SYSTEM
   Paleta Profesional para Dirección y Control de Proyectos
   ========================================================================== */

:root {
  /* Paleta Verde Ambiental & Naturaleza */
  --color-green-900: #083B25;
  --color-green-800: #0E5A3A; /* Primario institucional */
  --color-green-700: #157347;
  --color-green-600: #1E8E5A;
  --color-green-500: #22C55E;
  --color-green-100: #DCFCE7;
  --color-green-50: #F0FDF4;

  /* Paleta Azul Petróleo & Navegación */
  --color-petroleum-950: #071826;
  --color-petroleum-900: #0B253A; /* Fondo sidebar */
  --color-petroleum-800: #143642;
  --color-petroleum-700: #1B4965;
  --color-petroleum-100: #E0F2FE;

  /* Acentos Hídricos y Conservación */
  --color-hydro-cyan: #00A896;
  --color-hydro-teal: #028090;
  --color-hydro-light: #CCFBF1;

  /* Semáforos y Estados Semánticos (WCAG AA) */
  --status-optimal-text: #166534;
  --status-optimal-bg: #DCFCE7;
  --status-optimal-border: #86EFAC;
  --status-optimal-dot: #15803D;

  --status-warning-text: #92400E;
  --status-warning-bg: #FEF3C7;
  --status-warning-border: #FDE68A;
  --status-warning-dot: #D97706;

  --status-critical-text: #991B1B;
  --status-critical-bg: #FEE2E2;
  --status-critical-border: #FECACA;
  --status-critical-dot: #DC2626;

  --status-info-text: #1E40AF;
  --status-info-bg: #DBEAFE;
  --status-info-border: #BFDBFE;
  --status-info-dot: #2563EB;

  /* Neutros y Superficies - Modo Claro */
  --bg-app: #F4F7F5;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  --bg-surface-muted: #F8FAFC;
  --bg-surface-active: #EEF2F6;
  --border-subtle: #E2E8F0;
  --border-medium: #CBD5E1;
  --border-strong: #94A3B8;

  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --text-inverse: #FFFFFF;

  /* Layout y Dimensiones */
  --sidebar-width: 280px;
  --sidebar-width-collapsed: 72px;
  --topbar-height: 70px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Sombras e Iluminación */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-drawer: -4px 0 24px rgba(7, 24, 38, 0.15);

  /* Transiciones */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Modo Oscuro (Dark Theme)
   ========================================================================== */
[data-theme="dark"] {
  --bg-app: #0B131F;
  --bg-surface: #132032;
  --bg-surface-elevated: #1B2B42;
  --bg-surface-muted: #101B2B;
  --bg-surface-active: #22354F;
  --border-subtle: #22354F;
  --border-medium: #334B6B;
  --border-strong: #47658D;

  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-light: #64748B;

  --color-green-800: #157347;
  --color-green-700: #1E8E5A;

  --status-optimal-bg: rgba(22, 101, 52, 0.25);
  --status-optimal-text: #86EFAC;
  --status-warning-bg: rgba(180, 83, 9, 0.25);
  --status-warning-text: #FDE68A;
  --status-critical-bg: rgba(185, 28, 28, 0.25);
  --status-critical-text: #FECACA;
  --status-info-bg: rgba(30, 64, 175, 0.25);
  --status-info-text: #93C5FD;
}

/* ==========================================================================
   Reset y Tipografía Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Tipografía de Encabezados */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: 1.65rem; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; letter-spacing: -0.01em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.0rem; }

p { color: var(--text-main); }
small { font-size: 0.82rem; color: var(--text-muted); }
a { color: var(--color-green-700); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-green-800); }

/* Accesibilidad y Foco */
:focus-visible {
  outline: 2px solid var(--color-green-600);
  outline-offset: 2px;
}

/* ==========================================================================
   Estructura del Layout Principal (Shell)
   ========================================================================== */
#app-root {
  display: flex;
  width: 100%;
  flex: 1;
  position: relative;
}

/* Barra Lateral (Sidebar) */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-petroleum-900);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 38px;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-normal);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 2px 0 12px rgba(7, 24, 38, 0.2);
}

.app-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

/* Header del Sidebar */
.sidebar-header {
  height: var(--topbar-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.1) 100%);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  white-space: nowrap;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--color-green-600) 0%, var(--color-green-800) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--color-hydro-cyan);
  font-weight: 500;
  display: block;
}

.btn-toggle-sidebar {
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-toggle-sidebar:hover {
  color: #FFFFFF;
  background-color: rgba(255, 255, 255, 0.1);
}

/* Navegación del Sidebar con Scrollbar estilizado */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.nav-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748B;
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  color: #CBD5E1;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.nav-item.active {
  background: linear-gradient(90deg, var(--color-green-800) 0%, rgba(14, 90, 58, 0.85) 100%);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(14, 90, 58, 0.35);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3.5px;
  background-color: var(--color-green-500);
  border-radius: 0 4px 4px 0;
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.badge-alert {
  background-color: var(--status-critical-dot);
  color: #FFFFFF;
}

.badge-warning {
  background-color: var(--status-warning-dot);
  color: #FFFFFF;
}

.badge-info {
  background-color: var(--color-hydro-teal);
  color: #FFFFFF;
}

/* Pie del Sidebar */
.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(0, 0, 0, 0.15);
  font-size: 0.75rem;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-sidebar.collapsed .nav-item-text,
.app-sidebar.collapsed .nav-item-badge,
.app-sidebar.collapsed .nav-group-label,
.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .sidebar-footer span {
  display: none;
}

.app-sidebar.collapsed .brand-wrapper {
  justify-content: center;
  width: 100%;
}

.app-sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem 0;
}

/* Contenedor Principal (Main Content Shell) */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-normal);
  background-color: var(--bg-app);
}

.app-main.sidebar-collapsed {
  margin-left: var(--sidebar-width-collapsed);
}

/* Barra Superior (Topbar) */
.app-topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 38px;
  z-index: 90;
  box-shadow: var(--shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Selector de Proyecto */
.project-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface-muted);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-selector-wrapper:hover {
  border-color: var(--color-green-700);
}

.project-select {
  background: transparent;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
}

/* Buscador Global */
.global-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.45rem 1rem;
  width: 260px;
  transition: all var(--transition-fast);
}

.global-search-box:focus-within {
  width: 340px;
  border-color: var(--color-green-700);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(14, 90, 58, 0.12);
}

.global-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  width: 100%;
  color: var(--text-main);
}

/* Controles del Lado Derecho */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Indicador En Vivo */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background-color: var(--status-optimal-bg);
  border: 1px solid var(--status-optimal-border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--status-optimal-text);
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-optimal-dot);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Selector de Periodo */
.period-selector {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-muted);
}

/* Botones de Acción Topbar */
.btn-icon-topbar {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.btn-icon-topbar:hover {
  background-color: var(--bg-surface-active);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-icon-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background-color: var(--status-critical-dot);
  color: #FFFFFF;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Perfil de Usuario */
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 0.25rem 0.65rem 0.25rem 0.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-profile-btn:hover {
  background-color: var(--bg-surface-muted);
  border-color: var(--border-subtle);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-green-700);
}

.user-info-text {
  text-align: left;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.user-role-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

/* Botón de Acción Rápida Institucional */
.btn-primary-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--color-green-700) 0%, var(--color-green-800) 100%);
  color: #FFFFFF;
  border: none;
  padding: 0.5rem 1.15rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(14, 90, 58, 0.3);
  transition: all var(--transition-fast);
}

.btn-primary-action:hover {
  background: linear-gradient(135deg, var(--color-green-600) 0%, var(--color-green-700) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 90, 58, 0.4);
}

/* ==========================================================================
   Contenido Principal y Vistas (Views)
   ========================================================================== */
.view-container {
  padding: 1.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

/* Header de la Vista (Breadcrumb + Título + Acciones) */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.breadcrumb-item a {
  color: var(--text-muted);
}

.breadcrumb-item a:hover {
  color: var(--color-green-700);
}

.view-title-group h2 {
  font-size: 1.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.view-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.view-actions-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Banner de Demostración */
.demo-disclaimer-banner {
  background-color: var(--status-warning-bg);
  border: 1px solid var(--status-warning-border);
  color: var(--status-warning-text);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ==========================================================================
   Componentes Reutilizables (Cards, Badges, Tablas, Modales)
   ========================================================================== */

/* Tarjetas (Cards) */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-medium);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Grid de Métricas (KPITiles) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--color-green-700);
}

.kpi-card.warning::before { background-color: var(--status-warning-dot); }
.kpi-card.critical::before { background-color: var(--status-critical-dot); }
.kpi-card.optimal::before { background-color: var(--status-optimal-dot); }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.kpi-subtext {
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Badges y Etiquetas de Estado */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-status-optimal {
  background-color: var(--status-optimal-bg);
  color: var(--status-optimal-text);
  border: 1px solid var(--status-optimal-border);
}
.badge-status-optimal .badge-dot { background-color: var(--status-optimal-dot); }

.badge-status-warning {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}
.badge-status-warning .badge-dot { background-color: var(--status-warning-dot); }

.badge-status-critical {
  background-color: var(--status-critical-bg);
  color: var(--status-critical-text);
  border: 1px solid var(--status-critical-border);
}
.badge-status-critical .badge-dot { background-color: var(--status-critical-dot); }

.badge-status-info {
  background-color: var(--status-info-bg);
  color: var(--status-info-text);
  border: 1px solid var(--status-info-border);
}
.badge-status-info .badge-dot { background-color: var(--status-info-dot); }

/* Tablas de Datos Enterprise */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
  background-color: var(--bg-surface);
}

.data-table th {
  background-color: var(--bg-surface-muted);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: var(--bg-surface-active);
}

/* Botones Estándar */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-secondary {
  background-color: var(--bg-surface-muted);
  border-color: var(--border-medium);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-active);
  border-color: var(--border-strong);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--color-green-700);
  color: var(--color-green-700);
}

.btn-outline:hover {
  background-color: rgba(14, 90, 58, 0.08);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

/* ==========================================================================
   Modales, Drawer Lateral y Toasts
   ========================================================================== */

/* Backdrop / Fondo Oscurecido */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(7, 24, 38, 0.6);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background-color: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  transform: translateY(15px);
  transition: transform var(--transition-normal);
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-surface-muted);
}

/* Panel Lateral Deslizante (Drawer) */
.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 95vw;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-drawer);
  z-index: 1010;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Sistema de Notificaciones Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 380px;
  width: 100%;
}

.toast {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slide-in-toast 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slide-in-toast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.optimal { border-left: 4px solid var(--status-optimal-dot); }
.toast.warning { border-left: 4px solid var(--status-warning-dot); }
.toast.critical { border-left: 4px solid var(--status-critical-dot); }
.toast.info { border-left: 4px solid var(--status-info-dot); }

/* ==========================================================================
   Pantalla de Acceso / Login Institucional
   ========================================================================== */
.login-view-wrapper {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, #143642 0%, var(--color-petroleum-900) 90%);
  padding: 1.5rem;
}

.login-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 460px;
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-medium);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand .brand-icon {
  margin: 0 auto 1rem auto;
  width: 54px;
  height: 54px;
  border-radius: var(--radius-lg);
}

.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background-color: var(--bg-surface-muted);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-green-700);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(14, 90, 58, 0.12);
}

/* Botón de Menú Hamburguesa Móvil (oculto en desktop) */
.btn-mobile-menu {
  display: none;
}

/* Backdrop para Sidebar Móvil */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(7, 24, 38, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 990;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Adaptación Responsiva Integral (Enterprise Multi-Device Support)
   ========================================================================== */

/* Breakpoint 1: Pantallas medianas / Laptops pequeñas (<= 1200px) */
@media (max-width: 1200px) {
  .global-search-box {
    width: 200px;
  }
  .global-search-box:focus-within {
    width: 260px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Breakpoint 2: Tablets Landscape & Dispositivos Medianos (<= 1024px) */
@media (max-width: 1024px) {
  .btn-mobile-menu {
    display: flex;
  }
  .btn-toggle-sidebar {
    display: none;
  }

  /* Sidebar pasa a ser Off-Canvas */
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px !important;
    max-width: 85vw;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-drawer);
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-sidebar .nav-item-text,
  .app-sidebar .nav-item-badge,
  .app-sidebar .nav-group-label,
  .app-sidebar .brand-text,
  .app-sidebar .sidebar-footer span {
    display: initial !important;
  }

  .app-sidebar .brand-wrapper {
    justify-content: flex-start !important;
  }

  .app-sidebar .nav-item {
    justify-content: flex-start !important;
    padding: 0.65rem 0.85rem !important;
  }

  /* Main Shell ocupa ancho completo */
  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .app-topbar {
    padding: 0 1.25rem;
  }

  .global-search-box {
    width: 170px;
  }

  /* Grids de Vistas: Stack a 1 Columna en Tablets */
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1.5fr 1fr"],
  div[style*="grid-template-columns: 1.2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1.5fr"],
  div[style*="grid-template-columns: 240px 1fr"],
  div[style*="grid-template-columns: 320px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  /* Mapeo GIS en Tablets */
  div[style*="height:calc(100vh - 160px)"] {
    height: auto !important;
    min-height: auto !important;
  }
  #gis-map-canvas {
    height: 480px !important;
    min-height: 400px !important;
  }
}

/* Breakpoint 3: Tablets Portrait & Móviles Grandes (<= 768px) */
@media (max-width: 768px) {
  html {
    font-size: 13.5px;
  }

  .app-topbar {
    height: auto;
    min-height: 58px;
    padding: 0.5rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .topbar-left {
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
  }

  .project-selector-wrapper {
    padding: 0.35rem 0.65rem;
    max-width: 100%;
  }

  .project-select {
    font-size: 0.82rem;
    max-width: 160px;
  }

  .global-search-box {
    display: none;
  }

  .topbar-right {
    gap: 0.4rem;
  }

  .period-selector {
    display: none;
  }

  .user-info-text {
    display: none;
  }

  .btn-primary-action {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
  }

  .btn-primary-action span {
    display: none;
  }

  .btn-primary-action i {
    margin: 0;
  }

  .view-container {
    padding: 1rem 0.75rem;
    gap: 1.15rem;
  }

  .view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .view-title-group h2 {
    font-size: 1.25rem;
  }

  .view-actions-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .view-actions-group .btn {
    flex: 1;
    min-width: 120px;
  }

  /* Todas las Grids a 1 Columna en Móvil */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: repeat(4, 1fr)"],
  div[style*="grid-template-columns: repeat(3, 1fr)"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(360px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(380px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(300px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"] {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Tarjetas y Contenedores */
  .card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* Tablas Responsivas con scroll táctil */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table th, 
  .data-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Cronograma Maestro Gantt en Móvil */
  .gantt-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modales y Paneles Deslizantes */
  .modal-dialog {
    width: 94vw;
    margin: 1rem auto;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .side-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
  }

  .drawer-header {
    padding: 1rem 1.25rem;
  }

  .drawer-body {
    padding: 1.25rem;
  }

  /* Toasts en Móvil */
  .toast-container {
    bottom: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    max-width: 100%;
  }

  /* Login Card en Móvil */
  .login-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
  }
}

/* Breakpoint 4: Teléfonos Pequeños (<= 480px) */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }

  .project-select {
    max-width: 110px;
  }

  .live-indicator span {
    display: none;
  }

  .live-indicator {
    padding: 0.35rem;
  }

  .kpi-value {
    font-size: 1.45rem;
  }

  .btn-icon-topbar {
    width: 34px;
    height: 34px;
  }

  .user-avatar {
    width: 30px;
    height: 30px;
  }
}

/* ==========================================================================
   Estilos de Impresión Oficial (@media print)
   ========================================================================== */
@media print {
  .app-sidebar,
  .app-topbar,
  .no-print,
  .modal-backdrop,
  .side-drawer,
  .toast-container,
  .btn-toggle-sidebar,
  .btn-mobile-menu,
  .sidebar-backdrop {
    display: none !important;
  }

  body, #app-root, .app-main {
    background-color: #FFFFFF !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .view-container {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .printable-report {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
}

/* ==========================================================================
   BANNER CONSTANTE: AVISO DE DATOS SIMULADOS & DEMOSTRACIÓN
   ========================================================================== */
.disclaimer-banner-sticky {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 38px;
  flex-shrink: 0;
  z-index: 1200;
  background: linear-gradient(90deg, #991B1B 0%, #D97706 40%, #D97706 60%, #991B1B 100%);
  color: #FFFFFF;
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  font-size: 0.83rem;
  font-weight: 500;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  border-bottom: 2px solid #FDE68A;
  text-align: center;
  animation: pulseDisclaimer 4s infinite ease-in-out;
}

@keyframes pulseDisclaimer {
  0%, 100% { border-bottom-color: #FDE68A; }
  50% { border-bottom-color: #F59E0B; }
}

.disclaimer-badge {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.disclaimer-text {
  line-height: 1.35;
}

.disclaimer-text strong {
  color: #FEF08A;
  font-weight: 700;
}

/* ==========================================================================
   SECCIÓN DE GENERALIDADES DEL PROGRAMA (PÁGINA PRINCIPAL)
   ========================================================================== */
.generalities-container {
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.generalities-hero {
  background: linear-gradient(135deg, var(--color-petroleum-950) 0%, var(--color-petroleum-900) 60%, var(--color-petroleum-800) 100%);
  border-radius: var(--radius-lg);
  color: #FFFFFF;
  padding: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
}

.generalities-hero::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(14, 90, 58, 0.35) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.generalities-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.generalities-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Explicación Amigable del Sistema (Hero First Card) */
.generalities-hero,
.generalities-hero p,
.generalities-hero span,
.generalities-hero h1,
.generalities-hero h4,
.generalities-hero h5 {
  color: #FFFFFF;
}

.hero-friendly-intro {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.45rem;
  margin: 0.9rem 0 1.25rem 0;
  backdrop-filter: blur(10px);
}

.hero-friendly-lead {
  font-size: 0.95rem !important;
  line-height: 1.6 !important;
  color: #F8FAFC !important;
  margin-bottom: 1.15rem !important;
}

.hero-friendly-lead strong {
  color: #38BDF8 !important;
}

.hero-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.95rem;
  width: 100%;
}

.hero-feature-item {
  background: rgba(15, 23, 42, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.hero-feature-item:hover {
  background: rgba(30, 41, 59, 0.8) !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  transform: translateY(-2px);
}

.hero-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hero-feature-content h5 {
  font-size: 0.86rem !important;
  font-weight: 700 !important;
  color: #FFFFFF !important;
  margin: 0 0 0.25rem 0 !important;
  line-height: 1.25 !important;
}

.hero-feature-content p {
  font-size: 0.78rem !important;
  color: #CBD5E1 !important;
  line-height: 1.4 !important;
  margin: 0 !important;
}

.generalities-grid-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-label {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94A3B8;
  font-weight: 600;
}

.meta-value {
  font-size: 0.92rem;
  color: #F8FAFC;
  font-weight: 600;
}

.project-generalities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.project-gen-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.project-gen-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-green-600);
}

.project-gen-top {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.project-gen-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.project-gen-info h4 {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text-main);
  font-weight: 700;
}

.project-gen-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}


