/**
 * Vyftec Plotly Charts Styles
 * Professional styling for Plotly charts in WordPress
 */

/* Main chart container */
.vyftec-plotly-chart,
.plotly-chart,
.wp-plotly-chart {
    width: 100% !important;
    height: 400px !important;
    margin: 20px 0 !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    background: #fafafa !important;
    position: relative !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: box-shadow 0.3s ease !important;
}

.vyftec-plotly-chart:hover,
.plotly-chart:hover,
.wp-plotly-chart:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
}

/* Loading state */
.chart-loading {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    background: rgba(250, 250, 250, 0.95) !important;
    z-index: 10 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    color: #666 !important;
    font-size: 14px !important;
}

.loading-spinner {
    width: 40px !important;
    height: 40px !important;
    border: 3px solid #f3f3f3 !important;
    border-top: 3px solid #007cba !important;
    border-radius: 50% !important;
    animation: vyftec-spin 1s linear infinite !important;
    margin-bottom: 10px !important;
}

@keyframes vyftec-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state */
.chart-error {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    text-align: center !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    color: #dc3545 !important;
    font-size: 14px !important;
    padding: 20px !important;
    background: #fff !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* Responsive behavior */
@media (max-width: 768px) {
    .vyftec-plotly-chart,
    .plotly-chart,
    .wp-plotly-chart {
        height: 300px !important;
        margin: 15px 0 !important;
    }
}

@media (max-width: 480px) {
    .vyftec-plotly-chart,
    .plotly-chart,
    .wp-plotly-chart {
        height: 250px !important;
        margin: 10px 0 !important;
        border-radius: 4px !important;
    }

    .chart-loading {
        font-size: 12px !important;
    }

    .loading-spinner {
        width: 30px !important;
        height: 30px !important;
    }
}

/* Chart-specific styling */
.vyftec-plotly-chart[id*="venezuela"],
.vyftec-plotly-chart[id*="economic"] {
    border-color: #007cba !important;
    background: linear-gradient(135deg, #fafafa 0%, #f0f8ff 100%) !important;
}

.vyftec-plotly-chart[id*="trend"],
.vyftec-plotly-chart[id*="data"] {
    border-color: #28a745 !important;
    background: linear-gradient(135deg, #fafafa 0%, #f0fff0 100%) !important;
}

/* Plotly.js specific overrides */
.vyftec-plotly-chart .plotly,
.plotly-chart .plotly,
.wp-plotly-chart .plotly {
    width: 100% !important;
    height: 100% !important;
}

.vyftec-plotly-chart .plotly .svg-container,
.plotly-chart .plotly .svg-container,
.wp-plotly-chart .plotly .svg-container {
    width: 100% !important;
    height: 100% !important;
}

/* Hide Plotly branding/logo in free version */
.vyftec-plotly-chart .plotly a[data-title*="plotly"],
.plotly-chart .plotly a[data-title*="plotly"],
.wp-plotly-chart .plotly a[data-title*="plotly"] {
    display: none !important;
}

/* Content integration */
.entry-content .vyftec-plotly-chart,
.entry-content .plotly-chart,
.entry-content .wp-plotly-chart {
    clear: both !important;
    margin: 30px auto !important;
    max-width: 100% !important;
}

/* Block editor compatibility */
.wp-block .vyftec-plotly-chart,
.wp-block .plotly-chart,
.wp-block .wp-plotly-chart {
    margin: 20px 0 !important;
}

/* Print styles */
@media print {
    .vyftec-plotly-chart,
    .plotly-chart,
    .wp-plotly-chart {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        border: 1px solid #000 !important;
        background: #fff !important;
    }

    .chart-loading,
    .chart-error {
        display: none !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .vyftec-plotly-chart,
    .plotly-chart,
    .wp-plotly-chart {
        border-width: 0.5px !important;
    }
}

/* Accessibility */
.vyftec-plotly-chart:focus,
.plotly-chart:focus,
.wp-plotly-chart:focus {
    outline: 2px solid #007cba !important;
    outline-offset: 2px !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .vyftec-plotly-chart,
    .plotly-chart,
    .wp-plotly-chart {
        background: #2c2c2c !important;
        border-color: #555 !important;
        color: #fff !important;
    }

    .chart-loading {
        background: rgba(44, 44, 44, 0.95) !important;
        color: #ccc !important;
    }

    .loading-spinner {
        border-color: #555 !important;
        border-top-color: #007cba !important;
    }
}

/* Animation for chart appearance */
.vyftec-plotly-chart,
.plotly-chart,
.wp-plotly-chart {
    opacity: 0;
    animation: vyftec-fadein 0.5s ease-in-out forwards;
}

@keyframes vyftec-fadein {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}