/**
 * Centro de Estudios - Estilos
 * 
 * Diseñados para integrarse con el theme de Empresa Actual.
 * Paleta basada en los tonos rojos corporativos + grises neutros.
 */

/* ── Contenedor principal ────────────────────────────────── */

.ce-container {
    max-width: 100%;
    margin: 0 auto 2rem;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ce-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #C8392B;
}

/* ── Área del gráfico ────────────────────────────────────── */

.ce-chart-wrapper {
    position: relative;
    width: 100%;
    background: #fff;
    border-radius: 4px;
    padding: 1rem 0.5rem;
}

.ce-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Loading spinner ─────────────────────────────────────── */

.ce-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    color: #888;
    font-size: 0.95rem;
}

.ce-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #eee;
    border-top-color: #C8392B;
    border-radius: 50%;
    animation: ce-spin 0.8s linear infinite;
}

@keyframes ce-spin {
    to { transform: rotate(360deg); }
}

/* ── Error ────────────────────────────────────────────────── */

.ce-error {
    text-align: center;
    padding: 2rem;
    color: #C8392B;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
}

.ce-error p {
    margin: 0;
    font-size: 0.95rem;
}

/* ── Panel de filtros ────────────────────────────────────── */

.ce-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
    padding: 1rem;
    background: #f8f8f8;
    border-radius: 4px;
    border: 1px solid #e8e8e8;
}

.ce-filter-group {
    flex: 1 1 auto;
    min-width: 200px;
}

.ce-filter-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #C8392B;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.6rem;
    font-style: italic;
}

.ce-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* ── Botones ─────────────────────────────────────────────── */

.ce-btn {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 600;
    color: #fff;
    background: #C8392B;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    line-height: 1.4;
    white-space: nowrap;
}

.ce-btn:hover {
    background: #a52d22;
}

.ce-btn:focus-visible {
    outline: 2px solid #C8392B;
    outline-offset: 2px;
}

/* Estado inactivo (indicador desactivado) */
.ce-btn-indicador:not(.active) {
    background: #d4d4d4;
    color: #666;
}

.ce-btn-indicador:not(.active):hover {
    background: #bbb;
    color: #333;
}

/* Botones de periodo/tipo: estilo más suave cuando no están activos */
.ce-btn-periodo:not(.active),
.ce-btn-tipo:not(.active),
.ce-btn-toggle-legend:not(.active) {
    background: #e8e8e8;
    color: #555;
}

.ce-btn-periodo:not(.active):hover,
.ce-btn-tipo:not(.active):hover,
.ce-btn-toggle-legend:not(.active):hover {
    background: #d0d0d0;
    color: #333;
}

/* ── Controles de visualización ──────────────────────────── */

.ce-viz-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 140px;
    flex: 0 0 auto;
}

.ce-viz-controls .ce-filter-label {
    display: none; /* No necesita etiqueta */
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .ce-filters {
        flex-direction: column;
    }

    .ce-filter-group {
        min-width: 100%;
    }

    .ce-viz-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .ce-chart-wrapper {
        padding: 0.5rem 0;
    }

    .ce-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .ce-title {
        font-size: 1.15rem;
    }

    .ce-filter-buttons {
        gap: 0.3rem;
    }

    .ce-btn {
        padding: 0.3rem 0.55rem;
        font-size: 0.75rem;
    }
}

/* ── Adaptación al theme de EmpresaActual ────────────────── */

/* Si el theme usa .entry-content, heredar márgenes */
.entry-content .ce-container {
    margin-left: 0;
    margin-right: 0;
}

/* Asegurar que el canvas no se desborda en sidebars */
.widget .ce-container .ce-chart-wrapper {
    height: 300px !important;
}

.widget .ce-container .ce-btn {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
}

/* ── Pestañas de grupo ────────────────────────────────────── */

.ce-tabs-container {
    max-width: 100%;
    margin: 0 auto 2rem;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ce-tabs-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 0;
}

.ce-tab-btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: #777;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: -1px;
    position: relative;
}

.ce-tab-btn:hover {
    color: #333;
    background: #eee;
}

.ce-tab-btn.active {
    color: #C8392B;
    background: #fff;
    border-color: #C8392B;
    border-bottom: 2px solid #fff;
    margin-bottom: -2px;
    z-index: 1;
}

.ce-tabs-container .ce-chart-wrapper {
    border: 2px solid #C8392B;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 1rem 0.5rem;
    background: #fff;
}

.ce-tabs-container .ce-filters {
    margin-top: 0.75rem;
}

@media (max-width: 600px) {
    .ce-tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.78rem;
    }
}

/* ── Dashboard ───────────────────────────────────────────── */

.ce-dashboard {
    max-width: 100%;
    margin: 0 auto 2rem;
}

.ce-dashboard-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0 0 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #C8392B;
}

.ce-dashboard-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.ce-dashboard-panel {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 1rem;
    box-sizing: border-box;
}

.ce-panel-full {
    flex: 0 0 100%;
    width: 100%;
}

.ce-panel-half {
    flex: 0 0 calc(50% - 0.625rem);
    width: calc(50% - 0.625rem);
}

/* Dentro del dashboard, los títulos de panel son más discretos */
.ce-dashboard-panel .ce-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: #C8392B;
    margin: 0 0 0.75rem;
    padding: 0;
    border: none;
}

/* Dentro del dashboard, la barra de título principal no necesita borde */
.ce-dashboard-panel .ce-title {
    display: none;
}

/* Filtros más compactos en dashboard */
.ce-dashboard-panel .ce-filters {
    padding: 0.6rem 0.8rem;
    margin-top: 0.75rem;
    gap: 0.6rem;
}

.ce-dashboard-panel .ce-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.ce-dashboard-panel .ce-filter-label {
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
}

/* Responsive: paneles a full width en móvil */
@media (max-width: 900px) {
    .ce-panel-half {
        flex: 0 0 100%;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .ce-dashboard-panel {
        padding: 0.6rem;
    }

    .ce-dashboard-panel .ce-btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.7rem;
    }
}
