/* ============================================================
   smgr · css/pages/viz_simulacion.css — DISEÑO DE LA TARJETA capturable
   de "Simulación Liga Regular ACB" (visualizacion_simulacion.php).
   Portado 1:1 del clásico smgr/visualizacion_simulacion.php, pero:
     · TODO lo de la tarjeta va scopeado bajo #captureArea para no colisionar
       con el chrome "Foco" (rincon.css) ni al revés.
     · El modal vive FUERA del #captureArea → sus clases llevan prefijo .sim-
       para no chocar con las clases del chrome.
     · Sin `body { background }` ni reset global `*` (los aporta el chrome/viz.css).
   El ancho fijo (1000px) lo respeta el escalador móvil (transform:scale).
   ============================================================ */

#captureArea {
    font-family: 'Inter', sans-serif;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    overflow: hidden;
    width: 1000px;
}
#captureArea * { box-sizing: border-box; }

/* ---------- Cabecera ---------- */
#captureArea .header {
    background: linear-gradient(135deg, #2c5282 0%, #2a4365 100%);
    color: #fff;
    padding: 10px 20px;
    text-align: center;
    position: relative;
}
#captureArea .header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><rect width="100" height="100" fill="%23000" opacity="0.03"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
}
#captureArea .logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: relative;
    z-index: 1;
}
#captureArea .header h1 {
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    position: relative;
    z-index: 1;
}
#captureArea .header p {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 3px;
    position: relative;
    z-index: 1;
}

/* ---------- Tabla ---------- */
#captureArea table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
#captureArea thead th {
    background: #2d3748;
    color: #fff;
    font-weight: 700;
    font-size: 10px;
    padding: 8px 6px;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.1);
}
#captureArea thead th:last-child { border-right: none; }
#captureArea thead th.col-team {
    text-align: left;
    padding-left: 8px;
}
#captureArea thead th.col-bar { width: 220px; }

#captureArea tbody td {
    padding: 5px 6px;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    text-align: center;
}
#captureArea tbody td:last-child { border-right: none; }
#captureArea tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }

/* Zone coloring for probability cells */
#captureArea .zone-top4 { color: #065f46; font-weight: 700; }
#captureArea .zone-playoff { color: #1e40af; font-weight: 700; }
#captureArea .zone-mid { color: #4a5568; font-weight: 600; }
#captureArea .zone-releg { color: #991b1b; font-weight: 700; }

/* Rank column */
#captureArea .rank {
    font-weight: 700;
    font-size: 12px;
    color: #718096;
    width: 30px;
}

/* Team cell */
#captureArea .team-cell {
    text-align: left !important;
    padding-left: 6px !important;
}
#captureArea .team-info {
    display: flex;
    align-items: center;
    gap: 5px;
}
#captureArea .team-shield {
    width: 18px;
    height: 22px;
    object-fit: contain;
    border-radius: 2px;
}
#captureArea .team-abbr {
    font-weight: 700;
    font-size: 12px;
    color: #2d3748;
}
#captureArea .team-record {
    font-size: 10px;
    color: #718096;
    font-weight: 500;
    margin-left: auto;
    padding-right: 4px;
}

/* Stacked bar */
#captureArea .stacked-bar {
    display: flex;
    height: 18px;
    border-radius: 3px;
    overflow: hidden;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
}
#captureArea .bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: #fff;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
#captureArea .bar-top4 { background: #059669; }
#captureArea .bar-playoff { background: #3b82f6; }
#captureArea .bar-mid { background: #9ca3af; }
#captureArea .bar-releg { background: #ef4444; }

/* Probability cell */
#captureArea .prob-cell {
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    width: 85px;
}
#captureArea .prob-cell.highlight { font-size: 13px; }

/* Average position */
#captureArea .avg-pos {
    font-weight: 800;
    font-size: 13px;
    color: #2d3748;
    font-variant-numeric: tabular-nums;
    width: 55px;
}
#captureArea .proj-record {
    font-weight: 600;
    font-size: 11px;
    color: #4a5568;
    font-variant-numeric: tabular-nums;
    width: 65px;
}

/* Clickable rows */
#captureArea tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}
#captureArea tbody tr:hover {
    background: rgba(44, 82, 130, 0.06) !important;
}

/* Separator rows for zones */
#captureArea tr.zone-separator td {
    border-bottom: 2.5px solid #2c5282;
    padding-bottom: 6px;
}
#captureArea tr.zone-separator + tr td { padding-top: 6px; }
#captureArea tr.releg-separator td {
    border-bottom: 2.5px solid #e53e3e;
    padding-bottom: 6px;
}
#captureArea tr.releg-separator + tr td { padding-top: 6px; }

/* Legend */
#captureArea .legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 8px 20px;
    font-size: 10px;
    color: #4a5568;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
}
#captureArea .legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}
#captureArea .legend-color {
    width: 14px;
    height: 10px;
    border-radius: 2px;
}

/* Methodology note */
#captureArea .methodology {
    padding: 10px 20px;
    font-size: 9px;
    color: #718096;
    line-height: 1.5;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
}
#captureArea .methodology strong { color: #4a5568; }

/* Footer */
#captureArea .footer {
    background: #2d3748;
    color: rgba(255,255,255,0.7);
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
}
#captureArea .footer span { display: inline-block; }

/* ============================================================
   MODAL (fuera del #captureArea) — clases con prefijo .sim-
   ============================================================ */
.sim-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
}
.sim-modal-overlay.active { display: flex; }
.sim-modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 520px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    line-height: normal;
}
.sim-modal-box * { box-sizing: border-box; }
.sim-modal-header {
    background: linear-gradient(135deg, #2c5282 0%, #2a4365 100%);
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sim-modal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sim-modal-header .sim-team-shield {
    width: 24px;
    height: 30px;
    object-fit: contain;
    display: inline;
    max-width: none;
    vertical-align: baseline;
}
.sim-modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: #fff;
}
.sim-modal-header .sim-modal-record {
    font-size: 12px;
    opacity: 0.8;
}
.sim-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    line-height: 1;
}
.sim-modal-close:hover { opacity: 1; }
.sim-modal-body { padding: 0; }
.sim-modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.sim-modal-table thead th {
    background: #2d3748;
    color: #fff;
    font-weight: 700;
    font-size: 10px;
    padding: 7px 8px;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.1);
}
.sim-modal-table thead th:last-child { border-right: none; }
.sim-modal-table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
    vertical-align: middle;
    color: #2d3748;
}
.sim-modal-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
.sim-modal-table .opp-cell { text-align: left; }
.sim-modal-table .opp-info {
    display: flex;
    align-items: center;
    gap: 5px;
}
.sim-modal-table .opp-shield {
    width: 14px;
    height: 17px;
    object-fit: contain;
    border-radius: 2px;
    display: inline;
    max-width: none;
    vertical-align: baseline;
}
.sim-modal-table .opp-name {
    font-weight: 700;
    font-size: 12px;
    color: #2d3748;
}
.sim-modal-table .opp-record {
    font-size: 10px;
    color: #718096;
}
.sim-modal-table .ha-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
}
.sim-modal-table .ha-badge.home { background: #ebf4ff; color: #2b6cb0; }
.sim-modal-table .ha-badge.away { background: #fef3e2; color: #c05621; }
.sim-modal-table .prob-bar-cell { width: 140px; }
.sim-modal-table .prob-bar-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sim-modal-table .prob-bar-bg {
    flex: 1;
    height: 14px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}
.sim-modal-table .prob-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.sim-modal-table .prob-bar-label {
    font-weight: 700;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    width: 38px;
    text-align: right;
}
.sim-modal-summary {
    padding: 10px 16px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    font-size: 11px;
    color: #4a5568;
    border-radius: 0 0 12px 12px;
}
.sim-modal-summary strong { color: #2d3748; }
