/**
 * ====================================================================
 * ALPHAVAULT AI — ECONOMIC DASHBOARD CSS
 * Adapted to Drive structure (drive.css base)
 * ====================================================================
 * drive.css gère le layout, la sidebar, le header, les variables AVD.
 * Ce fichier surcharge et complète pour le contenu économique.
 */

/* ════════════════════════════════════════════════════════════
   1. OVERRIDES LAYOUT — avDriveContent scrollable
════════════════════════════════════════════════════════════ */

/* Permettre le scroll vertical dans le content (override drive) */
html, body.avd-page {
    overflow: hidden; /* Le scroll est géré par #avDriveContent */
}

#avDriveContent {
    padding: 22px 26px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ════════════════════════════════════════════════════════════
   2. ECO VARIABLES (palette économique, hérite de --avd-*)
════════════════════════════════════════════════════════════ */
:root {
    --eco-primary:        #3b82f6;
    --eco-secondary:      #8b5cf6;
    --eco-gradient:       linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --eco-gradient-soft:  linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    --eco-success:        #10b981;
    --eco-danger:         #ef4444;
    --eco-warning:        #f59e0b;
    --eco-info:           #3b82f6;
    --eco-transition:     all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --eco-radius:         16px;
    --eco-radius-lg:      24px;
}

/* ════════════════════════════════════════════════════════════
   3. GRADIENT TITLES
════════════════════════════════════════════════════════════ */
.gradient-title {
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-title i {
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chart-title {
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ════════════════════════════════════════════════════════════
   4. ECO SECTIONS (remplace .section du dashboard original)
════════════════════════════════════════════════════════════ */
.eco-section {
    background: var(--avd-card);
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius);
    padding: 28px;
    margin-bottom: 22px;
    transition: var(--eco-transition);
}

.eco-section:hover {
    border-color: var(--avd-border-hover);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.12);
}

/* ════════════════════════════════════════════════════════════
   5. HEADER EXPORT BUTTON (dans avDriveHeader)
════════════════════════════════════════════════════════════ */
.eco-export-btn {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #fff !important;
    border-color: transparent !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.eco-export-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5) !important;
    background: linear-gradient(135deg, #059669, #047857) !important;
}

/* ════════════════════════════════════════════════════════════
   6. TOOLBAR (dans avDriveContent)
════════════════════════════════════════════════════════════ */
.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--avd-card);
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius);
    margin-bottom: 20px;
    transition: var(--eco-transition);
}

.dashboard-toolbar:hover {
    border-color: var(--avd-border-hover);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dashboard-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--avd-text-muted);
}

.dashboard-subtitle i {
    color: var(--eco-primary);
    font-size: 12px;
}

/* ════════════════════════════════════════════════════════════
   7. ECONOMIC CARDS
════════════════════════════════════════════════════════════ */
.eco-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-bottom: 8px;
}

.eco-card {
    background: var(--avd-card);
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius);
    padding: 24px;
    transition: var(--eco-transition);
    position: relative;
    overflow: hidden;
}

.eco-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--eco-gradient);
    opacity: 0;
    transition: var(--eco-transition);
}

.eco-card:hover {
    transform: translateY(-4px);
    border-color: rgba(102, 126, 234, 0.35);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.2);
}

.eco-card:hover::before {
    opacity: 1;
}

.eco-card.us-card {
    border-left: 3px solid #3b82f6;
}

.eco-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.eco-card-title-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.eco-card-icon {
    font-size: 1.3rem;
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.eco-card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--avd-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.eco-card-btn-info {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--avd-input-bg);
    border: 1px solid var(--avd-border);
    color: var(--avd-text-muted);
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--eco-transition);
    flex-shrink: 0;
}

.eco-card-btn-info:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: transparent;
    transform: scale(1.1);
}

.eco-value {
    font-size: 2.2rem;
    font-weight: 900;
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    line-height: 1.2;
}

.eco-sublabel {
    font-size: 11px;
    color: var(--avd-text-dim);
    font-weight: 600;
}

.eco-change {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    margin-top: 10px;
}

.eco-change.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--eco-success);
}

.eco-change.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--eco-danger);
}

/* ════════════════════════════════════════════════════════════
   8. METRICS SUMMARY
════════════════════════════════════════════════════════════ */
.metrics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.metric-card {
    background: var(--eco-gradient-soft);
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius);
    padding: 22px;
    transition: var(--eco-transition);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.08) 0%, transparent 70%);
    opacity: 0;
    transition: var(--eco-transition);
}

.metric-card:hover::before {
    opacity: 1;
    animation: ecoRotate 10s linear infinite;
}

@keyframes ecoRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.metric-card:hover {
    transform: translateY(-3px);
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.15);
}

.metric-card h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--avd-text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 7px;
    position: relative;
    z-index: 1;
}

.metric-card h4 i {
    color: var(--eco-primary);
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.metric-description {
    font-size: 11px;
    color: var(--avd-text-dim);
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

/* ════════════════════════════════════════════════════════════
   9. TIME RANGE SELECTOR
════════════════════════════════════════════════════════════ */
.section-header-with-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 14px;
}

.time-range-selector {
    display: flex;
    gap: 4px;
    background: var(--avd-input-bg);
    border: 1px solid var(--avd-border);
    padding: 5px;
    border-radius: 10px;
}

.time-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    color: var(--avd-text-muted);
    cursor: pointer;
    transition: var(--eco-transition);
    font-family: inherit;
}

.time-btn:hover {
    color: var(--avd-text);
    border-color: var(--avd-border);
    background: rgba(255, 255, 255, 0.05);
}

body.light-mode .time-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.time-btn.active {
    background: var(--eco-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
}

/* ════════════════════════════════════════════════════════════
   10. CHARTS GRID
════════════════════════════════════════════════════════════ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
}

.chart-card {
    background: var(--avd-card);
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius);
    padding: 22px;
    transition: var(--eco-transition);
}

.chart-card:hover {
    border-color: var(--avd-border-hover);
    box-shadow: 0 6px 28px rgba(102, 126, 234, 0.15);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.chart-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-btn-info,
.chart-btn-fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--avd-input-bg);
    border: 1px solid var(--avd-border);
    color: var(--avd-text-muted);
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--eco-transition);
    font-family: inherit;
}

.chart-btn-info:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: transparent;
    transform: scale(1.08);
}

.chart-btn-fullscreen:hover {
    background: var(--eco-gradient);
    color: #fff;
    border-color: transparent;
    transform: scale(1.08);
}

.chart {
    height: 380px;
    border-radius: 10px;
}

/* ════════════════════════════════════════════════════════════
   11. FOOTER
════════════════════════════════════════════════════════════ */
.eco-footer {
    text-align: center;
    padding: 20px;
    color: var(--avd-text-dim);
    font-size: 11px;
    font-weight: 600;
    border-top: 1px solid var(--avd-border);
    margin-top: 8px;
}

.eco-footer i {
    color: var(--eco-primary);
    margin-right: 6px;
}

/* ════════════════════════════════════════════════════════════
   12. ECO MODALS (préfixe eco- pour ne pas conflicder avec avd-)
════════════════════════════════════════════════════════════ */
.eco-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    animation: ecoFadeIn 0.3s ease;
}

.eco-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes ecoFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.eco-modal-content {
    background: #1a2235;
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius-lg);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: ecoSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode .eco-modal-content {
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
}

.eco-modal-content.eco-modal-large {
    max-width: 900px;
}

@keyframes ecoSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.eco-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 26px;
    border-bottom: 1px solid var(--avd-border);
    background: var(--eco-gradient-soft);
}

.eco-modal-header h2 {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.eco-modal-close {
    background: var(--avd-input-bg);
    border: 1px solid var(--avd-border);
    color: var(--avd-text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--eco-transition);
    font-family: inherit;
    line-height: 1;
}

.eco-modal-close:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--eco-danger);
    border-color: rgba(239, 68, 68, 0.3);
    transform: rotate(90deg);
}

.eco-modal-body {
    padding: 28px;
}

/* Export Options */
.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.export-btn {
    background: var(--avd-card);
    border: 1px solid var(--avd-border);
    border-radius: var(--eco-radius);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--eco-transition);
    color: var(--avd-text-muted);
    font-family: inherit;
}

.export-btn:hover {
    background: var(--eco-gradient);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(102, 126, 234, 0.4);
}

.export-btn i {
    font-size: 2rem;
}

.export-btn span {
    font-weight: 700;
    font-size: 12px;
}

.export-btn small {
    font-size: 10px;
    opacity: 0.75;
}

/* Trends Content */
.trends-content { padding: 10px 0; }

.trend-item {
    background: var(--eco-gradient-soft);
    border-left: 3px solid var(--eco-primary);
    padding: 18px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.trend-item h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--eco-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.trend-item p {
    color: var(--avd-text-muted);
    line-height: 1.6;
    font-size: 13px;
}

/* ════════════════════════════════════════════════════════════
   13. LOADING & ERROR
════════════════════════════════════════════════════════════ */
.eco-loading {
    text-align: center;
    padding: 50px 20px;
    color: var(--avd-text-muted);
}

.eco-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border: 3px solid var(--avd-border);
    border-top-color: var(--eco-primary);
    border-radius: 50%;
    animation: ecoSpin 1s linear infinite;
}

@keyframes ecoSpin {
    to { transform: rotate(360deg); }
}

.eco-loading p {
    font-size: 13px;
    font-weight: 600;
    color: var(--avd-text-dim);
}

.eco-error {
    text-align: center;
    padding: 50px 20px;
}

.eco-error i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--eco-danger);
    display: block;
}

/* ════════════════════════════════════════════════════════════
   14. LIGHT MODE ADJUSTMENTS
════════════════════════════════════════════════════════════ */
body.light-mode .eco-section {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

body.light-mode .chart-card {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

body.light-mode .eco-card {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

body.light-mode .metric-card {
    border-color: rgba(102, 126, 234, 0.15);
}

body.light-mode .dashboard-toolbar {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

body.light-mode .eco-modal-content {
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .export-btn {
    color: #475569;
}

body.light-mode .time-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* ════════════════════════════════════════════════════════════
   15. RESPONSIVE
════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .eco-dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .metrics-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #avDriveContent {
        padding: 14px;
    }

    .dashboard-toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }

    .eco-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .metrics-summary {
        grid-template-columns: 1fr;
    }

    .section-header-with-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .time-range-selector {
        width: 100%;
        justify-content: space-between;
    }

    .time-btn {
        flex: 1;
        text-align: center;
    }

    .eco-modal-content {
        width: 95%;
    }

    .export-options {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .eco-section {
        padding: 18px 16px;
    }
}

@media (max-width: 480px) {
    .eco-value {
        font-size: 1.8rem;
    }

    .chart {
        height: 280px;
    }

    .time-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* ════════════════════════════════════════════════════════════
   16. ACCESSIBILITY — Reduced Motion
════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}