/**
 * ESTILOS GLOBALES - GESTOR DE EVENTOS
 * MundiTrofeos S.A.
 */

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

/* --- Sistema de Diseño (Variables) --- */
:root {
  --font-title: 'Outfit', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;

  /* Escala tipográfica recomendada para Inter */
  --text-xs:   0.75rem;   /* 12px — etiquetas, badges */
  --text-sm:   0.8125rem; /* 13px — texto secundario */
  --text-base: 0.9375rem; /* 15px — cuerpo principal */
  --text-md:   1.0625rem; /* 17px — subtítulos */
  --text-lg:   1.25rem;   /* 20px — títulos de sección */
  --text-xl:   1.5rem;    /* 24px — títulos de página */
  --text-2xl:  2rem;      /* 32px — KPI grandes */

  /* Primario — Azul institucional profundo */
  --color-primary:        #2563EB;
  --color-primary-hover:  #1D4ED8;
  --color-primary-light:  #EFF6FF;
  --color-primary-rgb:    37, 99, 235;  /* Para rgba() */
  --color-primary-border: #C7D5E8;

  --color-secondary: #E85D04;
  --color-secondary-hover: #CC5200;
  
  --color-success:        #16A34A;
  --color-success-light:  #F0FDF4;
  --color-success-bg:     #F0FDF4;
  --color-success-text:   #16A34A;
  --color-warning:        #D97706;
  --color-warning-light:  #FFFBEB;
  --color-warning-bg:     #FFFBEB;
  --color-warning-text:   #D97706;
  --color-danger:         #DC2626;
  --color-danger-light:   #FEF2F2;
  --color-danger-bg:      #FEF2F2;
  --color-danger-text:    #DC2626;

  --color-info: #3B82F6;
  --color-info-bg: #EFF6FF;
  --color-info-text: #1D4ED8;

  /* Estados de evento (Kanban columns) */
  --color-estado-programado:    #2563EB; /* Azul */
  --color-estado-seguimiento:   #D97706; /* Ámbar */
  --color-estado-urgencia:      #DC2626; /* Rojo */
  --color-estado-descartado:    #6B7280; /* Gris */

  /* Superficies */
  --color-bg:             #F8FAFC;  /* Fondo global */
  --color-neutral-bg:     #F8FAFC;
  --color-surface:        #FFFFFF;  /* Cards, modales */
  --color-card-bg:        #FFFFFF;
  --color-surface-muted:  #F1F5F9;  /* Áreas secundarias */
  --color-border:         #E2E8F0;  /* Bordes finos */
  --color-border-focus:   #93C5FD;  /* Foco de inputs */

  /* Texto */
  --color-text:           #0F172A;  /* Primario */
  --text-primary:         #0F172A;
  --color-text-secondary: #475569;  /* Secundario */
  --text-secondary:       #475569;
  --color-text-muted:     #94A3B8;  /* Terciario / placeholder */
  --text-muted:           #94A3B8;

  /* Elevación — tres niveles estandarizados */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --shadow-xl:  0 24px 48px rgba(0,0,0,.14), 0 8px 16px rgba(0,0,0,.06);
  --shadow-premium: 0 20px 25px -5px rgba(37, 99, 235, 0.1), 0 10px 10px -5px rgba(37, 99, 235, 0.04);

  /* Radios — sistema consistente */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Transiciones */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast:   120ms var(--ease-out);
  --transition-normal: 220ms var(--ease-out);
  --transition-slow:   360ms var(--ease-out);
}

/* --- Reset & Base --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--text-base);
  font-feature-settings: "tnum" 1, "cv02" 1, "cv03" 1, "cv04" 1;
  background-color: var(--color-neutral-bg);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-title); font-weight: 600; }
h4, h5, h6 { font-family: var(--font-title); font-weight: 500; }
.label, .badge, th { font-weight: 500; letter-spacing: 0.01em; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
  transition: all var(--transition-fast);
}

input, select, textarea {
  font-family: inherit;
  outline: none;
}

/* --- Custom Scrollbar --- */
.sidebar-scroll::-webkit-scrollbar,
.main-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.sidebar-scroll::-webkit-scrollbar-track,
.main-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-scroll::-webkit-scrollbar-thumb,
.main-scroll::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: var(--radius-full);
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover,
.main-scroll::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* --- Layout Principal --- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 64px;
  background-color: var(--color-card-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 20;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-badge {
  width: 38px;
  height: 38px;
  background-color: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
}

.logo-container {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.logo-text h1 {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.1;
}

.logo-text p {
  font-size: 10px;
  color: var(--text-muted);
}

/* Selector de Año */
.year-selector-container {
  position: relative;
}

.year-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
}

.year-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-premium);
  min-width: 100px;
  overflow: hidden;
  display: none;
  z-index: 50;
}

.year-dropdown.active {
  display: block;
}

.year-option {
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
}
.year-option:hover {
  background-color: #F8FAFC;
}
.year-option.selected {
  background-color: var(--color-primary);
  color: #FFF;
}

/* Barra de Búsqueda */
.search-container {
  flex: 1;
  max-width: 440px;
  margin: 0 24px;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 38px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}
.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.15);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-muted);
}
.clear-search-btn:hover {
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Panel de Alertas Dropdown */
.alerts-container {
  position: relative;
}

.alerts-bell-btn {
  position: relative;
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.alerts-bell-btn:hover {
  background-color: #F1F5F9;
  color: var(--text-primary);
}

.alerts-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: var(--color-danger);
  color: #FFF;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alerts-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 10px;
  width: 380px;
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  display: none;
  z-index: 50;
  max-height: 520px;
  overflow: hidden;
  flex-direction: column;
}

.alerts-dropdown.active {
  display: flex;
}

.alerts-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to right, rgba(30,58,95,0.03), transparent);
}

.alerts-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 700;
}

.alerts-new-badge {
  background-color: var(--color-danger);
  color: #FFF;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.alerts-close-btn {
  font-size: 18px;
  color: var(--text-muted);
}
.alerts-close-btn:hover {
  color: var(--text-secondary);
}

.alerts-list {
  overflow-y: auto;
  flex: 1;
}

.alerts-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.alerts-empty ion-icon {
  font-size: 38px;
  opacity: 0.25;
  margin-bottom: 8px;
}

.alerts-category-header {
  position: sticky;
  top: 0;
  padding: 6px 16px;
  background-color: #F8FAFC;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 10;
}

.alerts-category-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}
.dot-comercial { background-color: var(--color-warning); }
.dot-cotizacion { background-color: var(--color-secondary); }
.dot-produccion { background-color: #8B5CF6; }

.alerts-category-count {
  margin-left: auto;
  color: var(--text-muted);
  text-transform: none;
  font-weight: 500;
}

.alert-item {
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  gap: 12px;
  transition: background-color var(--transition-fast);
}
.alert-item:hover {
  background-color: #F8FAFC;
}
.alert-item.unread {
  background-color: rgba(59, 130, 246, 0.04);
}

.alert-icon-wrapper {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.alert-icon-wrapper.comercial { background-color: var(--color-warning-bg); color: var(--color-warning-text); }
.alert-icon-wrapper.cotizacion { background-color: rgba(232, 93, 4, 0.1); color: var(--color-secondary); }
.alert-icon-wrapper.produccion { background-color: rgba(139, 92, 246, 0.1); color: #8B5CF6; }

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.alert-type-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.alert-mark-read-btn {
  font-size: 10px;
  color: var(--color-info-text);
  font-weight: 600;
}
.alert-mark-read-btn:hover {
  text-decoration: underline;
}

.alert-message {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.alert-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Perfil Usuario Header */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: #F1F5F9;
  border-radius: var(--radius-md);
  cursor: default;
}

.user-profile-avatar {
  font-size: 16px;
  color: var(--text-secondary);
}

.user-profile-name {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

/* --- Wrapper Principal (Sidebar + Main) --- */
.main-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --- SIDEBAR --- */
.app-sidebar {
  width: 288px;
  background-color: var(--color-card-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 16px;
  margin-bottom: 8px;
}

/* Acordeón de Países */
.countries-list {
  padding: 0 8px;
  margin-bottom: 20px;
}

.country-item {
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.country-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-md);
}
.country-row:hover {
  background-color: #F8FAFC;
}
.country-row.selected {
  background-color: var(--color-primary-light);
}

.country-toggle-btn {
  font-size: 14px;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  margin-right: 4px;
}
.country-toggle-btn:hover {
  background-color: rgba(0,0,0,0.05);
  color: var(--text-secondary);
}

.country-main-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  text-align: left;
}

.country-code-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  background-color: #F1F5F9;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}
.country-row.selected .country-code-badge {
  background-color: var(--color-primary);
  color: #FFF;
}

.country-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.country-row.selected .country-name {
  color: var(--color-primary);
}

.country-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 20px;
  text-align: center;
}
.country-row.selected .country-count {
  color: var(--color-primary);
}

/* Meses dentro de País */
.country-months {
  margin-left: 24px;
  margin-right: 8px;
  margin-top: 4px;
  border: 1px solid #F1F5F9;
  border-radius: var(--radius-md);
  background-color: rgba(248, 250, 252, 0.6);
  overflow: hidden;
  display: none;
}
.country-months.active {
  display: block;
}

.month-row {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
}
.month-row:not(:disabled):hover {
  background-color: #F1F5F9;
}
.month-row.active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}
.month-row.current-month {
  border-left-color: var(--color-secondary);
}

.month-toggle-icon {
  font-size: 8px;
  color: var(--text-muted);
  margin-right: 6px;
  transition: transform var(--transition-fast);
}
.month-row.open .month-toggle-icon {
  transform: rotate(90deg);
}

.month-name {
  flex: 1;
}
.month-row:disabled .month-name {
  color: var(--text-muted);
  opacity: 0.5;
}

.month-count {
  font-size: 9px;
  font-weight: 700;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* Eventos dentro de Mes */
.month-events-list {
  display: none;
  padding: 4px;
}
.month-events-list.active {
  display: block;
}

.sidebar-event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-event-item:hover {
  background-color: #E2E8F0;
}

.sidebar-event-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidebar-event-name {
  font-size: 11px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar-event-status-badge {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* Bloque Estadísticas en Sidebar */
.sidebar-stats-card {
  margin: 0 12px 16px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.stats-card-header {
  padding: 10px 12px;
  background-color: #F8FAFC;
  border-bottom: 1px solid var(--color-border);
}

.stats-card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stats-card-body {
  padding: 12px;
}

.kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.kpi-mini-item {
  padding: 8px;
  border-radius: var(--radius-md);
  text-align: center;
}

.kpi-mini-val {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.kpi-mini-label {
  font-size: 9px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
  line-height: 1;
}

/* Gráfico Mensual Sidebar */
.sidebar-chart-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.sidebar-chart-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid #F1F5F9;
  padding-bottom: 12px;
}

.sidebar-chart-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.sidebar-chart-row.disabled {
  opacity: 0.35;
}

.sidebar-chart-label {
  width: 28px;
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  font-weight: 500;
}
.sidebar-chart-row.current .sidebar-chart-label {
  color: var(--color-primary);
  font-weight: 700;
}

.sidebar-chart-bar-bg {
  flex: 1;
  height: 6px;
  background-color: #F1F5F9;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.sidebar-chart-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.sidebar-chart-val {
  width: 16px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: right;
}

.sidebar-chart-indicator {
  font-size: 8px;
  color: var(--color-secondary);
}

/* KPIs de Alertas y Próximo Evento en Sidebar */
.sidebar-next-event-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.sidebar-next-event-title ion-icon {
  font-size: 12px;
}

.sidebar-next-event-name {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-next-event-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sidebar-alert-indicator-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.sidebar-alert-indicator-row ion-icon {
  font-size: 16px;
}
.sidebar-alert-indicator-row.active {
  color: var(--text-primary);
}
.sidebar-alert-indicator-row.danger ion-icon { color: var(--color-danger); }
.sidebar-alert-indicator-row.danger .val { color: var(--color-danger); }
.sidebar-alert-indicator-row.warning ion-icon { color: var(--color-warning); }
.sidebar-alert-indicator-row.warning .val { color: var(--color-warning); }

.sidebar-alert-indicator-row .label {
  flex: 1;
}

.sidebar-alert-indicator-row .val {
  font-weight: 700;
}

/* Botón Nuevo Evento en Sidebar */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.new-event-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background-color: var(--color-secondary);
  color: #FFF;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.new-event-btn:hover {
  background-color: var(--color-secondary-hover);
}

/* --- PANEL PRINCIPAL --- */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Navegación de Módulos */
.modules-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 4px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.module-nav-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}
.module-nav-btn:hover {
  background-color: #F8FAFC;
}
.module-nav-btn.active {
  background-color: var(--color-primary);
  color: #FFF;
}

/* --- COMPONENTES COMUNES DE INTERFAZ --- */

/* Notificaciones Toast */
/* ── Toast notifications ───────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  pointer-events: all;
  animation: toast-in var(--transition-normal) forwards;
}

.toast--success { border-left: 3px solid var(--color-success); }
.toast--error   { border-left: 3px solid var(--color-danger); }
.toast--warning { border-left: 3px solid var(--color-warning); }

.toast__icon { flex-shrink: 0; font-size: 18px; margin-top: 1px; }
.toast--success .toast__icon { color: var(--color-success); }
.toast--error   .toast__icon { color: var(--color-danger); }

.toast__message {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.45;
}

.toast.toast--exit {
  animation: toast-out var(--transition-normal) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(1.5rem); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  to   { opacity: 0; transform: translateX(1.5rem); }
}

/* Modales Nativo <dialog> */
dialog.custom-dialog {
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  align-items: center;
  justify-content: center;
  display: none;
}

dialog.custom-dialog[open] {
  display: flex;
}

dialog.custom-dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(4px);
  animation: backdrop-fade 0.2s ease forwards;
}

.dialog-card {
  background-color: var(--color-card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
  animation: dialog-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.dialog-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.dialog-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}

.dialog-close-btn {
  font-size: 22px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
}
.dialog-close-btn:hover {
  background-color: #F1F5F9;
  color: var(--text-secondary);
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.dialog-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  background-color: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@keyframes backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialog-pop {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Formularios */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  background-color: #FFF;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-family: var(--font-family-base);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  padding: 0.5625rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow   var(--transition-fast),
              transform    var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.975); }

.btn:focus-visible {
  outline: 2.5px solid var(--color-border-focus);
  outline-offset: 2px;
}

/* Variantes */
.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:hover { background: var(--color-primary-hover); }

.btn--ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}
.btn--ghost:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-text-muted);
}

.btn--danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border-color: transparent;
}
.btn--danger:hover { background: #FEE2E2; }

/* Aliases de compatibilidad */
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-secondary:hover { background: var(--color-secondary-hover); }
.btn-light { background: transparent; border-color: var(--color-border); color: var(--color-text-secondary); }
.btn-light:hover { background: var(--color-surface-muted); border-color: var(--color-text-muted); }

/* Tamaños */
.btn--sm { padding: 0.375rem 0.75rem; font-size: var(--text-xs); }
.btn--lg { padding: 0.75rem 1.375rem; font-size: var(--text-base); }

/* Estado cargando */
.btn--loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn--loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 0.375rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Inputs y Selects ──────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.field__label--required::after {
  content: ' *';
  color: var(--color-danger);
}

.field__input,
.field__select,
.field__textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-family: var(--font-family-base);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast),
              box-shadow   var(--transition-fast);
  outline: none;
}

.field__input:hover,
.field__select:hover {
  border-color: var(--color-text-muted);
}

.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.field__helper {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
}

.field--error .field__input,
.field--error .field__select {
  border-color: var(--color-danger);
}

.field--error .field__helper {
  color: var(--color-danger);
}

/* Badges / Tags */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Indicadores de KPI */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 768px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.kpi-val {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

/* Tablas Reutilizables */
.table-card {
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrapper {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.custom-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  background-color: #F8FAFC;
  border-bottom: 1px solid var(--color-border);
  letter-spacing: 0.05em;
}

.custom-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.custom-table tr:hover {
  background-color: rgba(248, 250, 252, 0.5);
}

.table-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.table-empty ion-icon {
  font-size: 44px;
  opacity: 0.2;
  margin-bottom: 8px;
}

/* Lightbox de Póster */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

.lightbox-title {
  color: #FFF;
  margin-top: 12px;
  font-size: 16px;
  text-align: center;
  font-weight: 600;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  color: #FFF;
  font-size: 28px;
}

/* Image Uploader Component Style */
.image-uploader-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.uploader-preview-wrapper {
  position: relative;
  border: 1px solid var(--color-border);
  background-color: #F8FAFC;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.uploader-preview-wrapper.landscape { width: 100%; height: 160px; }
.uploader-preview-wrapper.square { width: 80px; height: 80px; }

.uploader-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.uploader-hover-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.uploader-preview-wrapper:hover .uploader-hover-overlay {
  opacity: 1;
}

.uploader-change-btn {
  background-color: #FFF;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.uploader-change-btn:hover { background-color: #E2E8F0; }

.uploader-focus-btn {
  background-color: #FFF;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.uploader-focus-btn:hover { background-color: #E2E8F0; }

.uploader-delete-btn {
  background-color: var(--color-danger);
  color: #FFF;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.uploader-delete-btn:hover { background-color: var(--color-danger-hover); }

.uploader-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-border);
  background-color: #F8FAFC;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.uploader-dropzone.landscape { width: 100%; height: 130px; gap: 8px; }
.uploader-dropzone.square { width: 80px; height: 80px; }

.uploader-dropzone:hover {
  border-color: var(--color-primary);
  background-color: rgba(30, 58, 95, 0.02);
}

.uploader-dropzone ion-icon {
  font-size: 24px;
  color: var(--text-muted);
}
.uploader-dropzone.square ion-icon {
  font-size: 20px;
}

.uploader-dropzone-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.uploader-dropzone-hint {
  font-size: 9px;
  color: var(--text-muted);
}

/* =========================================================================
   UI/UX IMPROVEMENTS (mejorasV3.md)
   ========================================================================= */

/* --- Combobox Autocomplete Search --- */
.select-search-container {
  position: relative;
}
.combobox-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.combobox-search-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--text-muted);
}
.combobox-search-input {
  padding-left: 36px !important;
  padding-right: 36px !important;
}
.combobox-clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.combobox-clear-btn:hover {
  color: var(--text-secondary);
}
.combobox-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 4px;
  padding: 4px 0;
}
.combobox-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.combobox-item:hover, .combobox-item.highlighted {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
}
.combobox-item small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.combobox-item:hover small, .combobox-item.highlighted small {
  color: rgba(37, 99, 235, 0.7);
}
.combobox-empty-state {
  padding: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: center;
}
.btn-register-link {
  display: block;
  margin: 6px auto 0 auto;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
}

/* --- Mini Form Inline Collapse --- */
.mini-form-collapse {
  margin-top: 10px;
  border: 1px dashed var(--color-primary-border);
  background-color: rgba(37, 99, 235, 0.01);
  padding: 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  animation: slideDown 0.25s var(--ease-out);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.mini-form-header {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}
.mini-form-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
}

/* --- Input Critical fields highlight --- */
.form-input--critical:not(.input-error) {
  background-color: rgba(30, 58, 95, 0.02) !important;
  border-left: 3px solid var(--color-primary) !important;
}

/* --- Reclated Required Asterisk --- */
.required-asterisk {
  color: var(--color-danger);
  font-weight: bold;
  margin-left: 2px;
}

/* --- Validation Errors Styling --- */
.input-error {
  border-color: var(--color-danger) !important;
  background-color: rgba(239, 68, 68, 0.01) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1) !important;
}
.mensaje-error-campo {
  color: var(--color-danger-text) !important;
  font-size: 11.5px !important;
  margin-top: 4px !important;
  display: flex !important;
  align-items: center;
  gap: 4px;
  font-weight: 500 !important;
}
.mensaje-error-campo ion-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* --- Year Stepper Selector --- */
.year-stepper-container {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px 6px;
  box-shadow: var(--shadow-sm);
  height: 32px;
}
.btn-year-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
}
.btn-year-step:hover {
  background-color: var(--color-surface-muted);
  color: var(--text-primary);
}
.year-current-val {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  min-width: 44px;
  text-align: center;
  user-select: none;
}

/* Cuando el selector de año es un input[type=number] */
input.year-current-val {
  border: none;
  background: transparent;
  outline: none;
  padding: 0 2px;
  cursor: text;
  /* Eliminar flechas nativas de spinners en todos los navegadores */
  -moz-appearance: textfield;
  appearance: textfield;
  user-select: auto;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}
input.year-current-val::-webkit-outer-spin-button,
input.year-current-val::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input.year-current-val:focus {
  background-color: var(--color-surface-muted);
  outline: none;
}


/* --- Tools dropdown menu in sidebar --- */
.tools-dropdown-container {
  position: relative;
}
.tools-dropdown-menu {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 180px;
  padding: 4px 0;
  animation: slideDown 0.2s var(--ease-out);
}
.dropdown-item {
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 12.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.dropdown-item:hover {
  background-color: var(--color-surface-muted);
}
.dropdown-item ion-icon {
  font-size: 16px;
}
.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}
.danger-zone-title {
  font-size: 9px;
  font-weight: bold;
  color: var(--color-danger);
  padding: 4px 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}
.dropdown-item.btn-danger {
  color: var(--color-danger);
}
.dropdown-item.btn-danger:hover {
  background-color: var(--color-danger-light);
}
