/* ============================================================
   Indicadores Macro — Estilos Frontend
   Tokens de marca: INFORMA D&B / DBK
   Navy #011E3D · Blue #1C4CDE · Red #FD1A30 · Sky #DDE5ED
   Tipografía digital: Inter
   ============================================================ */

/* ── Contenedor principal ────────────────────────────────── */
.im-wrap {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.8125rem;
    color: #2B3A4A;
    max-width: 1280px;
    margin: 2.5rem auto;
    padding: 0 32px;
    box-sizing: border-box;
}

/* ── Cabecera de tabla ───────────────────────────────────── */
.im-header {
    margin-bottom: 1.25rem;
    border-left: 3px solid #FD1A30;
    padding-left: 14px;
}
.im-brand {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #5A6C84;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}
.im-title {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: #011E3D;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

/* ── Contenedor de scroll ────────────────────────────────── */
.im-table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #DDE5ED;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(1, 30, 61, 0.07);
    background: #fff;
}

/* Scroll vertical para Observatorio (tabla larga) */
.im-observatorio .im-table-scroll {
    max-height: 560px;
    overflow-y: auto;
}

/* ── Tabla ───────────────────────────────────────────────── */
.im-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    background: #fff;
}

.im-table th,
.im-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #DDE5ED;
    border-right: 1px solid #DDE5ED;
    vertical-align: middle;
    font-size: 0.7875rem;
    line-height: 1.35;
    white-space: nowrap;
    box-sizing: border-box;
}
.im-table th:last-child,
.im-table td:last-child {
    border-right: none;
}

/* ── Cabecera ────────────────────────────────────────────── */
.im-table thead th {
    background: #011E3D;
    color: #fff;
    font-weight: 600;
    text-align: center;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
    position: sticky;
    top: 0;
    z-index: 3;
    border-bottom: 2px solid #1C4CDE;
    border-right-color: rgba(255,255,255,0.15);
}
.im-table thead th:last-child {
    border-right-color: transparent;
}

/* ── Columnas fijas — izquierda (Indicador) ──────────────── */
.im-sticky {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    width: 230px;
    min-width: 230px;
    max-width: 230px;
    white-space: nowrap; /* overridden below with higher specificity */
    border-right: 2px solid #DDE5ED !important;
    text-align: left;
}
/* Higher specificity than .im-table th/td (0,1,1) to force text wrap */
.im-table th.im-sticky,
.im-table td.im-sticky {
    white-space: normal;
    word-break: break-word;
}
.im-table thead th.im-sticky {
    z-index: 4;
    background: #011E3D;
    border-right-color: rgba(255,255,255,0.2) !important;
}

/* ── Columna fija — Unidad (segunda, izquierda) ──────────── */
.im-sticky-unit {
    position: sticky;
    left: 230px;   /* = ancho de .im-sticky */
    z-index: 2;
    background: #fff;
    width: 90px;
    min-width: 90px;
    border-right: 1px solid #DDE5ED !important;
}
.im-table thead th.im-sticky-unit {
    z-index: 4;
    background: #011E3D;
    border-right-color: rgba(255,255,255,0.15) !important;
}

/* ── Columna fija — Fuente (derecha) ─────────────────────── */
.im-sticky-right {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    width: 106px;
    min-width: 106px;
    border-left: 2px solid #DDE5ED !important;
    border-right: none !important;
    font-size: 0.72rem;
    color: #5A6C84;
    white-space: nowrap;
    text-align: left;
}
.im-table thead th.im-sticky-right {
    z-index: 4;
    background: #011E3D;
    border-left-color: rgba(255,255,255,0.2) !important;
}

/* ── Columnas de año ─────────────────────────────────────── */
.im-col-year {
    text-align: right;
    min-width: 58px;
    width: 58px;
    font-variant-numeric: tabular-nums;
}

/* ── Columna Unidad ──────────────────────────────────────── */
.im-col-unit {
    color: #5A6C84;
    font-size: 0.72rem;
    text-align: left;
}

/* ── Columna Fuente ──────────────────────────────────────── */
.im-col-fuente {
    text-align: left;
}

/* ── Columna Componente/Indicador ────────────────────────── */
.im-col-label {
    text-align: left;
}

/* ── Filas de sección ────────────────────────────────────── */
.im-row-section td {
    background: #EEF1F8;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #011E3D;
    border-bottom: 1px solid #c8d0e8;
    padding: 7px 10px;
}
.im-row-section .im-sticky {
    background: #EEF1F8;
}
.im-row-section .im-sticky-unit {
    background: #EEF1F8;
}
.im-row-section .im-sticky-right {
    background: #EEF1F8;
}

/* ── Filas de datos — zebra ──────────────────────────────── */
.im-row-data:nth-child(even) td {
    background: #F8F9FC;
}
.im-row-data:nth-child(even) .im-sticky,
.im-row-data:nth-child(even) .im-sticky-unit,
.im-row-data:nth-child(even) .im-sticky-right {
    background: #F8F9FC;
}

.im-row-data:hover td {
    background: #EDF2FF !important;
}
.im-row-data:hover .im-sticky,
.im-row-data:hover .im-sticky-unit,
.im-row-data:hover .im-sticky-right {
    background: #EDF2FF !important;
}

/* ── Indentación ─────────────────────────────────────────── */
.im-col-label.im-indent-1 { padding-left: 22px; }
.im-col-label.im-indent-2 { padding-left: 38px; }
.im-col-label.im-indent-3 { padding-left: 54px; }
.im-col-label.im-indent-4 { padding-left: 70px; }

.im-col-label.im-indent-1::before { content: ''; }
.im-col-label.im-indent-2 { font-size: 0.76rem; color: #3D4F63; }
.im-col-label.im-indent-3 { font-size: 0.74rem; color: #4A5E73; }
.im-col-label.im-indent-4 { font-size: 0.72rem; color: #5A6C84; }

/* ── Números ─────────────────────────────────────────────── */
.im-num { text-align: right; font-variant-numeric: tabular-nums; }
.im-empty { color: #C8D0DB; }
.im-na    { color: #A0ADB8; font-size: 0.68rem; }

/* ── Columnas de trimestre (PIB Trimestral) ──────────────── */
.im-col-qtr { text-align: right; min-width: 52px; width: 52px; font-variant-numeric: tabular-nums; }
.im-qtr-year { border-left: 2px solid rgba(255,255,255,0.25) !important; }

/* ── Previsiones (PIB Anual) ─────────────────────────────── */
.im-col-forecast { text-align: right; min-width: 60px; }
.im-col-forecast-sub { font-size: 0.68rem; min-width: 72px; }
.im-forecast-header { background: #0D2D5C !important; border-left: 2px solid rgba(255,255,255,0.3) !important; }

/* ── Notas al pie ────────────────────────────────────────── */
.im-notes {
    margin-top: 0.85rem;
    font-size: 0.72rem;
    color: #5A6C84;
    line-height: 1.6;
    border-top: 1px solid #DDE5ED;
    padding-top: 0.6rem;
}
.im-notes p { margin: 0.1rem 0; }

/* ── Sin datos ───────────────────────────────────────────── */
.im-no-data {
    color: #5A6C84;
    font-style: italic;
    padding: 1.5rem;
    border: 1px dashed #DDE5ED;
    border-radius: 6px;
    text-align: center;
}

/* ── Cabecera thead: segunda fila (trimestres) ───────────── */
/* Rellenar thead para evitar franja blanca entre filas sticky */
.im-pib-trimestral .im-table thead {
    background: #011E3D;
}
.im-pib-trimestral .im-table thead tr:nth-child(2) th {
    font-size: 0.7rem;
    font-weight: 500;
    background: #0A2648;
    top: 31px; /* altura real de la primera fila (padding 12px + line 17px + border 2px) */
}

/* Ajuste de scroll suave en móvil */
@media (max-width: 960px) {
    .im-wrap {
        padding: 0 16px;
    }
    .im-table th,
    .im-table td {
        font-size: 0.72rem;
        padding: 5px 7px;
    }
    .im-sticky {
        width: 160px;
        min-width: 160px;
        max-width: 160px;
    }
    .im-sticky-unit {
        left: 160px; /* .im-sticky en móvil = 160px */
        width: 72px;
        min-width: 72px;
    }
    .im-observatorio .im-table-scroll {
        max-height: 420px;
    }
    .im-title { font-size: 0.95rem; }
}
