/* ═══════════════════════════════════════════════════════════
   Executive Center — main.css
   Sistema de estilos principal del módulo Executive Center
   Sprint 1 — Infraestructura visual
═══════════════════════════════════════════════════════════ */


/* ─── 1. Variables ────────────────────────────────────────── */
:root {
  /* Paleta principal */
  --ec-primary:        #1b4f72;
  --ec-primary-mid:    #2471a3;
  --ec-primary-hover:  #163f5c;
  --ec-primary-soft:   #d6eaf8;
  --ec-primary-xsoft:  #eaf4fc;

  /* Superficies */
  --ec-bg:             #eef2f7;
  --ec-surface:        #ffffff;
  --ec-surface-alt:    #f7fafc;

  /* Bordes */
  --ec-border:         #dce6f0;
  --ec-border-soft:    #e8eef5;

  /* Tipografía */
  --ec-text:           #1c2833;
  --ec-text-mid:       #3d5165;
  --ec-text-muted:     #626d7a;
  --ec-text-faint:     #9aaab8;

  /* Semáforo */
  --ec-success:        #1e7e48;
  --ec-success-bg:     #eafaf1;
  --ec-danger:         #b03a2e;
  --ec-danger-bg:      #fdedec;
  --ec-warning:        #b7770d;
  --ec-warning-bg:     #fef5e7;
  --ec-info:           #1b4f72;
  --ec-info-bg:        #d6eaf8;

  /* Layout */
  --ec-sidebar-w:      228px;
  --ec-topbar-h:       52px;

  /* Forma */
  --ec-radius:         6px;
  --ec-radius-sm:      4px;
  --ec-radius-lg:      8px;

  /* Sombras */
  --ec-shadow-sm:      0 1px 3px rgba(0,0,0,0.07);
  --ec-shadow:         0 1px 5px rgba(0,0,0,0.09);
  --ec-shadow-md:      0 2px 10px rgba(0,0,0,0.10);

  /* Tipografía */
  --ec-font:           'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}


/* ─── 2. Reset base ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  height: 100%;
  font-family: var(--ec-font);
  font-size: 1rem;
  color: var(--ec-text);
  background-color: var(--ec-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

img {
  display: block;
  max-width: 100%;
}


/* ─── 3. Layout principal ─────────────────────────────────── */
.ec-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Columna derecha (todo excepto sidebar) */
.ec-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--ec-sidebar-w);
}


/* ─── 4. Sidebar ──────────────────────────────────────────── */
.ec-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--ec-sidebar-w);
  background-color: var(--ec-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 300;
  box-shadow: 2px 0 8px rgba(0,0,0,0.14);
}

/* Marca */
.ec-brand {
  height: var(--ec-topbar-h);
  padding: 0 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid rgba(255,255,255,0.09);
  flex-shrink: 0;
}

.ec-brand-icon {
  width: 30px;
  height: 30px;
  background: rgba(255,255,255,0.14);
  border-radius: var(--ec-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.ec-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  overflow: hidden;
}

.ec-brand-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.ec-brand-sub {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.52);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

/* Etiqueta de sección en nav */
.ec-nav-group-label {
  padding: 1.1rem 1.1rem 0.35rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: rgba(255,255,255,0.38);
  flex-shrink: 0;
}

/* Navegación */
.ec-nav {
  flex: 1;
  padding: 0.35rem 0;
}

.ec-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.57rem 1.1rem;
  margin: 0.08rem 0.5rem;
  border-radius: var(--ec-radius-sm);
  color: rgba(255,255,255,0.72);
  font-size: 0.835rem;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  user-select: none;
  cursor: pointer;
}

.ec-nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.ec-nav-link.is-active {
  background: rgba(255,255,255,0.17);
  color: #fff;
  font-weight: 600;
}

.ec-nav-link.is-active .ec-nav-icon {
  opacity: 1;
}

.ec-nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.14s;
}

.ec-nav-link:hover .ec-nav-icon {
  opacity: 0.9;
}

.ec-nav-link.is-active .ec-nav-icon {
  opacity: 1;
}

/* Indicador de alerta en nav */
.ec-nav-badge {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 700;
  background: #e74c3c;
  color: #fff;
  border-radius: 10px;
  padding: 0.08rem 0.42rem;
  line-height: 1.4;
}

/* Pie del sidebar */
.ec-sidebar-footer {
  padding: 0.85rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.09);
  flex-shrink: 0;
}

.ec-sidebar-version {
  font-size: 0.63rem;
  color: rgba(255,255,255,0.28);
  text-align: center;
  line-height: 1.7;
}

/* Scrollbar del sidebar */
.ec-sidebar::-webkit-scrollbar { width: 3px; }
.ec-sidebar::-webkit-scrollbar-track { background: transparent; }
.ec-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
}


/* ─── 5. Barra superior ───────────────────────────────────── */
.ec-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--ec-topbar-h);
  background: var(--ec-surface);
  border-bottom: 1px solid var(--ec-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--ec-shadow-sm);
  flex-shrink: 0;
}

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

/* Breadcrumb */
.ec-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  color: var(--ec-text-muted);
}

.ec-breadcrumb a:hover {
  color: var(--ec-primary-mid);
  text-decoration: underline;
}

.ec-breadcrumb-sep {
  font-size: 0.65rem;
  opacity: 0.45;
}

.ec-breadcrumb-current {
  color: var(--ec-text);
  font-weight: 600;
}

/* Separador vertical */
.ec-topbar-divider {
  width: 1px;
  height: 18px;
  background: var(--ec-border);
}

.ec-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.ec-topbar-date {
  font-size: 0.76rem;
  color: var(--ec-text-muted);
  white-space: nowrap;
}

.ec-topbar-user {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.65rem 0.22rem 0.35rem;
  border-radius: var(--ec-radius-sm);
  border: 1px solid var(--ec-border);
  background: var(--ec-surface-alt);
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--ec-text);
}

.ec-user-avatar {
  width: 24px;
  height: 24px;
  background: var(--ec-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}


/* ─── 6. Contenido ────────────────────────────────────────── */
.ec-content {
  flex: 1;
  padding: 1.4rem 1.5rem;
}

/* Encabezado de página */
.ec-page-header {
  margin-bottom: 0.35rem;
}

.ec-page-title {
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--ec-text);
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.ec-page-subtitle {
  font-size: 0.81rem;
  color: var(--ec-text-muted);
  margin-top: 0.2rem;
}

.ec-page-divider {
  height: 1px;
  background: var(--ec-border);
  margin: 1rem 0 1.4rem;
}

/* Etiqueta de sección */
.ec-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ec-text-muted);
  margin-bottom: 0.7rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--ec-border-soft);
}


/* ─── 7. Grid de KPIs ─────────────────────────────────────── */
.ec-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}


/* ─── 8. Tarjeta KPI ──────────────────────────────────────── */
.ec-kpi-card {
  background: var(--ec-surface);
  border: 1px solid var(--ec-border);
  border-left: 4px solid var(--ec-border);
  border-radius: var(--ec-radius);
  padding: 1.05rem 1.2rem 1rem;
  box-shadow: var(--ec-shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}

.ec-kpi-card:hover {
  box-shadow: var(--ec-shadow-md);
  transform: translateY(-1px);
}

/* Variantes de color en borde izquierdo */
.ec-kpi-card--blue   { border-left-color: #2471a3; }
.ec-kpi-card--teal   { border-left-color: #1a9e81; }
.ec-kpi-card--purple { border-left-color: #7d3c98; }
.ec-kpi-card--amber  { border-left-color: #b7770d; }

/* Ícono decorativo de fondo */
.ec-kpi-bg-icon {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  opacity: 0.07;
  width: 36px;
  height: 36px;
  pointer-events: none;
}

.ec-kpi-card--blue   .ec-kpi-bg-icon { color: #2471a3; opacity: 0.12; }
.ec-kpi-card--teal   .ec-kpi-bg-icon { color: #1a9e81; opacity: 0.12; }
.ec-kpi-card--purple .ec-kpi-bg-icon { color: #7d3c98; opacity: 0.12; }
.ec-kpi-card--amber  .ec-kpi-bg-icon { color: #b7770d; opacity: 0.12; }

/* Etiqueta del KPI */
.ec-kpi-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ec-text-muted);
  margin-bottom: 0.45rem;
}

/* Valor principal */
.ec-kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ec-text);
  line-height: 1;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.ec-kpi-value--monetary {
  font-size: 1.42rem;
}

.ec-kpi-unit {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ec-text-muted);
  margin-left: 1px;
}

/* Pie del KPI */
.ec-kpi-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Badge de variación */
.ec-kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.14rem 0.42rem;
  border-radius: 3px;
  line-height: 1.4;
}

.ec-kpi-badge--up {
  background: var(--ec-success-bg);
  color: var(--ec-success);
}

.ec-kpi-badge--down {
  background: var(--ec-danger-bg);
  color: var(--ec-danger);
}

.ec-kpi-badge--flat {
  background: var(--ec-bg);
  color: var(--ec-text-muted);
}

/* Texto de período */
.ec-kpi-period {
  font-size: 0.67rem;
  color: var(--ec-text-faint);
}

/* Referencia del período anterior */
.ec-kpi-prev {
  margin-top: 0.38rem;
  font-size: 0.69rem;
  color: var(--ec-text-muted);
}


/* ─── 9. Banner de aviso ──────────────────────────────────── */
.ec-notice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: var(--ec-warning-bg);
  border: 1px solid #f5cba7;
  border-radius: var(--ec-radius-sm);
  font-size: 0.76rem;
  color: var(--ec-warning);
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.ec-notice-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}


/* ─── 10. Footer de página ────────────────────────────────── */
.ec-footer {
  background: var(--ec-surface);
  border-top: 1px solid var(--ec-border);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.69rem;
  color: var(--ec-text-faint);
  flex-shrink: 0;
}

.ec-footer-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ec-footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #27ae60;
}


/* ─── 11. Área de contenido futuro (placeholder) ─────────── */
.ec-placeholder-area {
  background: var(--ec-surface);
  border: 1.5px dashed var(--ec-border);
  border-radius: var(--ec-radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--ec-text-faint);
  margin-top: 1rem;
}

.ec-placeholder-area p {
  font-size: 0.79rem;
  margin-top: 0.35rem;
}


/* ─── 12. Responsive ──────────────────────────────────────── */
@media (max-width: 1280px) {
  .ec-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  :root { --ec-sidebar-w: 0px; }
  .ec-sidebar { display: none; }
  .ec-body  { margin-left: 0; }
}

@media (max-width: 640px) {
  .ec-kpi-grid  { grid-template-columns: 1fr; }
  .ec-content   { padding: 1rem; }
  .ec-topbar    { padding: 0 1rem; }
  .ec-topbar-date { display: none; }
}
