/**
 * Charts Standard Dimensions
 * Uniform sizing for ALL charts across SempiPlancia®©
 * Ensures consistent appearance in dashboards and reports
 */

/* ===== STANDARD CHART CONTAINER ===== */
.chart-container,
.chart-wrapper,
.sempi-chart-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(241, 105, 38, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* ===== STANDARD CHART CANVAS ===== */
.chart-container canvas,
.chart-wrapper canvas,
.sempi-chart-container canvas {
    width: 100% !important;
    height: 400px !important;
    display: block;
    border-radius: 8px;
}

/* ===== CHART HEADER (optional title/legend) ===== */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(241, 105, 38, 0.3);
}

.chart-title {
    color: #F16926;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    font-size: 1.6rem;
}

.chart-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== CHART ZOOM BUTTON (icon overlay) ===== */
.chart-zoom-btn-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: linear-gradient(45deg, #F16926, #ff8447);
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 10px 14px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(241, 105, 38, 0.4);
    transition: all 0.3s ease;
    opacity: 0.7;
}

.chart-zoom-btn-overlay:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(241, 105, 38, 0.6);
}

.chart-zoom-btn-overlay i {
    font-size: 1.2rem;
}

/* ===== CHART FOOTER (optional info) ===== */
.chart-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ccc;
    font-size: 0.85rem;
}

.chart-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-info i {
    color: #F16926;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

/* Tablets (768px - 1199px) */
@media (max-width: 1199px) and (min-width: 768px) {
    .chart-container canvas,
    .chart-wrapper canvas,
    .sempi-chart-container canvas {
        height: 350px !important;
    }

    .chart-container,
    .chart-wrapper,
    .sempi-chart-container {
        padding: 1.25rem;
    }

    .chart-title {
        font-size: 1.2rem;
    }

    .chart-zoom-btn-overlay {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* Mobile (below 768px) */
@media (max-width: 767px) {
    .chart-container canvas,
    .chart-wrapper canvas,
    .sempi-chart-container canvas {
        height: 300px !important;
    }

    .chart-container,
    .chart-wrapper,
    .sempi-chart-container {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .chart-title {
        font-size: 1.1rem;
    }

    .chart-title i {
        font-size: 1.3rem;
    }

    .chart-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .chart-zoom-btn-overlay {
        top: 15px;
        right: 15px;
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .chart-footer {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* Small mobile (below 480px) */
@media (max-width: 479px) {
    .chart-container canvas,
    .chart-wrapper canvas,
    .sempi-chart-container canvas {
        height: 250px !important;
    }

    .chart-container,
    .chart-wrapper,
    .sempi-chart-container {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .chart-title {
        font-size: 1rem;
    }

    .chart-zoom-btn-overlay {
        padding: 6px 8px;
        font-size: 0.8rem;
    }
}

/* ===== CHART LOADING STATE ===== */
.chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    z-index: 5;
}

.chart-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(241, 105, 38, 0.2);
    border-top: 3px solid #F16926;
    border-radius: 50%;
    animation: chartSpinnerRotate 1s linear infinite;
}

@keyframes chartSpinnerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chart-loading-text {
    margin-top: 15px;
    color: #F16926;
    font-weight: 600;
    font-size: 1rem;
}

/* ===== CHART ERROR STATE ===== */
.chart-error {
    padding: 2rem;
    text-align: center;
    background: rgba(231, 76, 60, 0.1);
    border: 2px solid rgba(231, 76, 60, 0.3);
    border-radius: 12px;
    color: #e74c3c;
}

.chart-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.chart-error h3 {
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.chart-error p {
    color: #ccc;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ===== SPECIFIC CHART TYPES (optional overrides) ===== */

/* Dashboard KPI Charts (smaller, inline) */
.kpi-chart-container {
    max-width: 400px;
    padding: 1rem;
}

.kpi-chart-container canvas {
    height: 250px !important;
}

/* Full-width report charts */
.report-chart-container {
    max-width: 1400px;
}

.report-chart-container canvas {
    height: 500px !important;
}

@media (max-width: 767px) {
    .kpi-chart-container canvas {
        height: 200px !important;
    }

    .report-chart-container canvas {
        height: 300px !important;
    }
}

/* ===== MULTI-CHART GRID ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

@media (max-width: 767px) {
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* ===== CHART ACCESSIBILITY ===== */
.chart-container:focus-within,
.chart-wrapper:focus-within,
.sempi-chart-container:focus-within {
    outline: 3px solid #F16926;
    outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
    .chart-container,
    .chart-wrapper,
    .sempi-chart-container {
        page-break-inside: avoid;
        background: #fff;
        border: 1px solid #000;
    }

    .chart-zoom-btn-overlay,
    .chart-actions {
        display: none;
    }

    .chart-container canvas,
    .chart-wrapper canvas,
    .sempi-chart-container canvas {
        height: 400px !important;
    }
}
