/* ==========================================================================
   PANELES LATERALES (OFF-CANVAS DRAWERS): FICHA TÉCNICA & DRILL-DOWN KPIS
   ========================================================================== */

/* ==========================================================================
   1. PANEL LATERAL IZQUIERDO: FICHA TÉCNICA & AYUDA
   ========================================================================== */

.left-backdrop, .left-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.left-backdrop.open, .left-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.left-info-drawer, .left-help-drawer {
    position: fixed;
    top: 0;
    left: -580px;
    width: 520px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.left-backdrop.open .left-info-drawer,
.left-backdrop.open .left-help-drawer,
.left-drawer-backdrop.open .left-info-drawer,
.left-drawer-backdrop.open .left-help-drawer {
    left: 0;
}

.left-drawer-header {
    padding: 22px 26px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.left-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-right: 36px;
}

.badge-faena-status {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--status-green-bg);
    color: var(--status-green-text);
    border: 1px solid var(--status-green-border);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.left-drawer-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.left-drawer-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.left-drawer-location {
    font-size: 0.74rem;
    color: var(--text-dim);
    margin-top: 6px;
    font-weight: 600;
}

.left-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 26px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.help-section-card, .help-section {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.help-section-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
}

.tech-specs-grid, .help-specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.spec-item, .spec-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.spec-item.full-width, .spec-card.full-width {
    grid-column: 1 / -1;
}

.spec-key, .spec-lbl {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.spec-val {
    color: var(--text-main);
    font-weight: 700;
    margin-top: 2px;
}

.help-text-block, .help-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 12px;
}

.value-chain-flow {
    background: #ffffff;
    border: 1px dashed var(--border-subtle);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--cyan-accent);
    line-height: 1.4;
}

.escalation-rules-box {
    font-size: 0.76rem;
    color: #78350f;
    line-height: 1.4;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid var(--copper-primary);
    padding: 10px 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.superintendencies-list, .help-superintendencies-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.superintendencies-list li, .help-superintendencies-list li {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-main);
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
}

.left-drawer-footer {
    padding: 16px 26px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   2. PANEL LATERAL DERECHO: DESGLOSE DE KPIS (DRILL-DOWN)
   ========================================================================== */

.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.kpi-drawer {
    position: fixed;
    top: 0;
    right: -680px;
    width: 660px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.drawer-backdrop.open .kpi-drawer {
    right: 0;
}

.drawer-header {
    padding: 20px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.drawer-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: var(--transition-fast);
}

.drawer-close-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.drawer-breadcrumbs {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.drawer-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.drawer-impact-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: help;
    transition: var(--transition-fast);
}

.drawer-impact-pill:hover {
    background: #fde68a;
    color: #78350f;
    box-shadow: 0 1px 4px rgba(217, 119, 6, 0.2);
}

.node-category-tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: #e2e8f0;
    color: var(--text-muted);
}

.drawer-kpi-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 4px;
}

/* FÓRMULA MATEMÁTICA VISUAL ELEGANTE */
.drawer-formula-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin: 10px 0 14px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.formula-label {
    font-size: 0.62rem;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.formula-tokens {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.formula-term {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: var(--text-main);
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    white-space: nowrap;
}

.formula-term.constant {
    font-family: var(--font-mono);
    color: var(--copper-primary);
    background: #fffbeb;
    border-color: #fde68a;
}

.formula-op {
    color: var(--cyan-accent);
    font-weight: 800;
    font-size: 0.95rem;
    padding: 0 2px;
}

.formula-paren {
    color: var(--text-dim);
    font-weight: 700;
    font-size: 0.95rem;
}

/* Stats Cards en Drawer */
.drawer-kpi-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.drawer-stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
}

.stat-value-big {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 2px;
}

.stat-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Tabs del Drawer */
.drawer-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.drawer-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 12px 14px;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
}

.drawer-tab-btn:hover {
    color: var(--text-main);
}

.drawer-tab-btn.active {
    color: var(--cyan-accent);
}

.drawer-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--cyan-accent);
}

/* Contenido del Drawer */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #f8fafc;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Tabla de Desglose */
.table-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.breakdown-table th {
    background: #f1f5f9;
    color: var(--text-dim);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.breakdown-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.breakdown-table th.col-component,
.breakdown-table td.col-component {
    width: 44%;
    text-align: left;
}

.breakdown-table th.col-num,
.breakdown-table td.col-num {
    width: 15%;
    text-align: left;
}

.breakdown-table th.col-status,
.breakdown-table td.col-status {
    width: 15%;
    text-align: left;
}

.breakdown-table th.col-resp,
.breakdown-table td.col-resp {
    width: 26%;
    text-align: left;
}

.breakdown-table tr:hover td {
    background: #f8fafc;
}

.subkpi-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.82rem;
    line-height: 1.35;
}

.table-num {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Gráfico de Tendencia */
.trend-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.trend-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.trend-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.trend-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-line {
    width: 14px;
    height: 3px;
    border-radius: 1px;
}

.legend-line.actual { background: var(--cyan-accent); }
.legend-line.target { background: var(--copper-primary); border-top: 1px dashed var(--copper-primary); }

.trend-chart-canvas {
    width: 100%;
    height: 150px;
}

/* Acciones Correctivas */
.action-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.action-id {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--cyan-accent);
}

.action-text {
    font-size: 0.78rem;
    color: var(--text-main);
    font-weight: 500;
    margin-top: 2px;
}

.badge-priority {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.badge-priority.Alta { background: #fee2e2; color: #dc2626; }
.badge-priority.Media { background: #fef3c7; color: #d97706; }
.badge-priority.Baja { background: #dcfce7; color: #16a34a; }

/* Footer del Drawer */
.drawer-footer {
    padding: 14px 24px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
