/* ===== Audiencia Estimada Dashboard - Slide Panel ===== */
/* Prefijo: aud- */

/* Panel lateral derecho (slide desde la derecha) */
.aud-panel {
    width: 35%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    flex-shrink: 0;
    position: relative;
    transform: translateX(100%);
    transition: transform 0.3s ease, width 0.3s ease;
    /* Oculto por defecto: ancho 0 para que no ocupe espacio */
    width: 0;
    min-width: 0;
}

.aud-panel.aud-open {
    transform: translateX(0);
    width: 35%;
}

/* Gradient top accent */
.aud-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #F07400, #00b4ff);
    z-index: 1;
}

/* Wrapper flex row para camara-body + panel */
.camara-body-wrapper {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.camara-body-wrapper > .camara-body {
    flex: 1;
    min-width: 0;
    transition: flex 0.3s ease;
}

/* Header */
.aud-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 16px 10px;
}

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

.aud-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #F07400, #00b4ff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.aud-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.aud-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(240, 116, 0, 0.15);
    color: #F07400;
    letter-spacing: 0.5px;
}

.aud-gradient-line {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 0 16px 12px;
}

/* KPI Grid - 5 columnas para 10 KPIs (2 filas parejas) */
.aud-kpi-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 0 14px 12px;
}

.aud-kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.aud-kpi-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.aud-kpi-card:hover::before {
    opacity: 1;
}

.aud-kpi-card:hover {
    border-color: rgba(240, 116, 0, 0.3);
    box-shadow: 0 0 15px rgba(240, 116, 0, 0.08);
}

.aud-kpi-label {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aud-kpi-value {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aud-kpi-value.aud-orange {
    color: #F07400;
}

.aud-kpi-value.aud-cyan {
    color: #00b4ff;
}

/* Score bar */
.aud-score-bar {
    margin-top: 6px;
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.aud-score-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #F07400, #00b4ff);
    transition: width 0.6s ease;
}

/* Charts Grid - 1 columna apilada para caber en 35% */
.aud-charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0 16px 16px;
}

/* Row de 2 charts lado a lado (Sexo + Res/Trans) */
.aud-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.aud-chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.aud-chart-header {
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.aud-chart-header svg {
    color: #F07400;
    flex-shrink: 0;
}

.aud-chart-body {
    padding: 4px 12px 12px;
    position: relative;
    min-height: 140px;
}

.aud-chart-body-tall {
    padding: 4px 12px 12px;
    position: relative;
    height: 320px;
}

.aud-chart-body-tall canvas {
    max-height: none;
    width: 100% !important;
    height: 100% !important;
}

.aud-chart-body canvas {
    max-height: 160px;
}

/* Close button inside panel */
.aud-panel .ft-close-x {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.aud-panel .ft-close-x:hover {
    background: rgba(255, 61, 113, 0.3);
    border-color: rgba(255, 61, 113, 0.5);
    color: #ff3d71;
    transform: scale(1.1);
}

/* Ficha Tecnica audiencia fields */
.ft-aud-section {
    margin-top: 4px;
    padding-top: 8px;
}

.ft-aud-gradient {
    height: 1px;
    background: linear-gradient(90deg, transparent, #00b4ff, transparent);
    margin-bottom: 10px;
}

.ft-aud-title {
    font-size: 11px;
    font-weight: 700;
    color: #00b4ff;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Ficha Tecnica audiencia KPI cards */
.ft-aud-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ft-aud-kpi {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 90px;
    background: rgba(0, 180, 255, 0.06);
    border: 1px solid rgba(0, 180, 255, 0.15);
    border-radius: 8px;
    padding: 8px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ft-aud-kpi-value {
    font-size: 14px;
    font-weight: 800;
    color: #00b4ff;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.ft-aud-kpi-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* Loading spinner for widget */
.aud-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    flex-direction: column;
    gap: 12px;
}

.aud-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(240, 116, 0, 0.2);
    border-top-color: #F07400;
    border-radius: 50%;
    animation: audSpin 0.8s linear infinite;
}

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

.aud-loading-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* En movil: panel ocupa 100% como overlay */
    .aud-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 0;
        height: 100%;
        z-index: 1000;
        border-left: none;
        border-radius: 0;
    }

    .aud-panel.aud-open {
        width: 100%;
    }

    .aud-kpi-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 12px 12px;
    }

    .aud-charts-grid {
        gap: 8px;
        padding: 0 12px 12px;
    }

    .aud-charts-row {
        grid-template-columns: 1fr;
    }

    .aud-kpi-value {
        font-size: 13px;
    }

    .aud-kpi-card {
        padding: 8px 6px;
    }
}

@media (max-width: 480px) {
    .aud-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .aud-header h3 {
        font-size: 14px;
    }
}
