/* ============================================================
   DASHBOARD — Digital Cleanup Day
   ============================================================ */

/* ===== VARIABLES ===== */
:root {
    --pink: #9d174d;
    --pink-m: #ec4899;
    --pink-l: #fdf2f8;
    --purple: #6b21a8;
    --purple-m: #a855f7;
    --rose: #be185d;
    --coral: #9f1239;
    --gray-100: #f9f7f8;
    --gray-200: #f3eef1;
    --gray-300: #e8dde4;
    --gray-400: #d4b8c9;
    --gray-500: #a87d96;
    --gray-600: #7d5570;
    --gray-700: #4a2d40;
    --gray-800: #2d1a26;
    --shadow: 0 4px 12px rgba(157, 23, 77, 0.1);
    --radius: 12px;
    --transition: all 0.25s ease;
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Segoe UI", system-ui, sans-serif;
    background: linear-gradient(160deg, #fdf2f8 0%, #faf5ff 50%, #fff1f2 100%);
    background-attachment: fixed;
    color: var(--gray-800);
    min-height: 100vh;
}

/* ===== LOADER ===== */
#loader-dash {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(131, 24, 67, 0.45);
    backdrop-filter: blur(4px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loader-box {
    background: white;
    padding: 36px 52px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 20px 60px rgba(157, 23, 77, 0.25);
}

.loader-box p {
    margin-top: 16px;
    font-weight: 600;
    color: var(--gray-700);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--gray-200);
    border-top-color: var(--pink);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, #831843 0%, #9d174d 40%, #ec4899 100%);
    color: white;
    padding: 0;
    box-shadow: 0 4px 20px rgba(157, 23, 77, 0.3);
}

.header-content {
    padding: 24px 24px 20px;
}

.header-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.header-title-logo {
    height: 56px;
    width: auto;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
}

.header-title-text {
    text-align: left;
}

.header-title-text h1 {
    font-size: 1.7rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-title-text p {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-top: 3px;
}

/* ===== MAIN ===== */
main {
    max-width: 1200px;
    margin: 28px auto;
    padding: 0 16px 80px;
}

/* ===== FILTRES ===== */
.filters-bar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 180px;
}

.filter-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
}

.filter-group select {
    padding: 9px 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.88rem;
    background: var(--gray-100);
    color: var(--gray-800);
    cursor: pointer;
    transition: var(--transition);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--pink-m);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

/* ===== BOUTONS ===== */
.btn {
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #831843, #ec4899);
    color: white;
    box-shadow: 0 4px 14px rgba(157, 23, 77, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

.btn-secondary:hover {
    border-color: var(--pink-m);
    color: var(--pink);
    transform: translateY(-1px);
}

/* ===== TITRES DE SECTION ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 0 16px;
}

.section-icon {
    font-size: 1.4rem;
}

.section-title h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-800);
}

/* ===== KPI GRID ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.kpi-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border-top: 4px solid transparent;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(157, 23, 77, 0.15);
}

.kpi-card.pink {
    border-top-color: #9d174d;
}
.kpi-card.purple {
    border-top-color: #6b21a8;
}
.kpi-card.rose {
    border-top-color: #be185d;
}
.kpi-card.coral {
    border-top-color: #9f1239;
}

.kpi-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--pink);
    line-height: 1;
    margin-bottom: 6px;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ===== CO2 CARD ===== */
.co2-card {
    background: linear-gradient(135deg, #831843, #9d174d, #ec4899);
    border-radius: var(--radius);
    padding: 24px 28px;
    color: white;
    box-shadow: 0 8px 24px rgba(157, 23, 77, 0.3);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.co2-main {
    text-align: center;
}

.co2-value {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.co2-label {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 8px;
    font-weight: 600;
}

.co2-sublabel {
    font-size: 0.78rem;
    opacity: 0.7;
    margin-top: 6px;
    font-style: italic;
}

/* ===== CO2 DÉTAIL ===== */
.co2-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.co2-detail-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.co2-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    gap: 8px;
}

.co2-detail-header.green {
    background: linear-gradient(135deg, #9d174d, #ec4899);
}
.co2-detail-header.blue {
    background: linear-gradient(135deg, #6b21a8, #a855f7);
}
.co2-detail-header.orange {
    background: linear-gradient(135deg, #9f1239, #fb7185);
}

.co2-detail-total {
    background: rgba(255, 255, 255, 0.25);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 800;
    margin-left: auto;
}

.co2-detail-body {
    padding: 12px 16px;
}

.co2-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.85rem;
}

.co2-detail-row:last-child {
    border-bottom: none;
}
.co2-detail-row span {
    color: var(--gray-600);
}
.co2-detail-row strong {
    color: var(--pink);
    font-weight: 700;
}

.co2-detail-row.hint-row span {
    font-style: italic;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ===== RÉPARTITION CO2 ===== */
.co2-repartition {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.co2-repartition h4 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 14px;
}

.repartition-bar {
    display: flex;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    gap: 2px;
}

.repartition-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: white;
    transition: width 0.8s ease;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    padding: 0 8px;
}

.repartition-segment.donnees {
    background: linear-gradient(135deg, #9d174d, #ec4899);
}
.repartition-segment.reemploi {
    background: linear-gradient(135deg, #6b21a8, #a855f7);
}
.repartition-segment.recyclage {
    background: linear-gradient(135deg, #9f1239, #fb7185);
}

/* ===== WIDGET IMPACTCO2 ===== */
.impactco2-wrapper {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    min-height: 200px;
}

.impactco2-wrapper h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-200);
}

.impactco2-desc {
    font-size: 0.78rem;
    color: var(--gray-500);
    font-style: italic;
    margin-bottom: 16px;
}

.impactco2-desc a {
    color: var(--pink-m);
    text-decoration: none;
}

.impactco2-desc a:hover {
    color: var(--pink);
    text-decoration: underline;
}

#impactco2-container {
    width: 100%;
    min-height: 150px;
}

#impactco2-container iframe {
    width: 100% !important;
    border: none !important;
    border-radius: 8px;
}

/* ===== GRAPHIQUES ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-200);
}

.chart-card-full {
    grid-column: 1 / -1;
}

/* ===== DERNIÈRE MISE À JOUR ===== */
.last-update {
    text-align: center;
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 8px;
    margin-bottom: 40px;
}

/* ===== ERREUR ===== */
.error-banner {
    background: #fff1f2;
    border: 2px solid #fb7185;
    color: #9f1239;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 24px;
    color: var(--gray-500);
    font-size: 0.82rem;
    border-top: 1px solid var(--gray-300);
    background: white;
    margin-top: 0;
}

.footer-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    margin-bottom: 14px;
}

.footer-logo-img {
    height: 30px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    opacity: 0.45;
    transition: var(--transition);
    filter: grayscale(1);
}

.footer-logo-img:hover {
    opacity: 0.85;
    filter: grayscale(0);
}

.footer-logo-img.logo-inr {
    border-radius: 6px;
    background: white;
    padding: 3px 7px;
    border: 1px solid var(--gray-300);
}

footer a {
    color: var(--pink-m);
    text-decoration: none;
    transition: var(--transition);
}

footer a:hover {
    color: var(--pink);
    text-decoration: underline;
}

footer p + p {
    margin-top: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .co2-card {
        flex-direction: column;
        text-align: center;
    }
    .co2-main {
        width: 100%;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .filters-bar {
        flex-direction: column;
    }
    .filter-group {
        width: 100%;
    }
    .co2-detail-grid {
        grid-template-columns: 1fr;
    }
    .footer-logos {
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .kpi-value {
        font-size: 1.5rem;
    }
    .co2-value {
        font-size: 2.5rem;
    }
    .header-title-text h1 {
        font-size: 1.2rem;
    }
    .footer-logo-img {
        height: 24px;
    }
}
