/**
 * Météo Centre - Frontend Core CSS
 * @version 4.0.0 - Refactor complet avec unités fluides et cards unifiées
 *
 * Contenu : Variables, Composants essentiels, Messages, Modale, Cards unifiées
 * Chargé : TOUJOURS (requis par tous les blocks)
 *
 * CHANGEMENTS v4.0:
 * ✅ Cards 100% unifiées (modal + ville identiques)
 * ✅ Unités fluides (em, %, clamp) au lieu de px fixes
 * ✅ Grid robuste sans débordement
 * ✅ Code simplifié et maintenable
 */

/* ========================================================================
 * VARIABLES CSS ESSENTIELLES
 * ======================================================================== */

:root {
    /* Couleurs principales */
    --mcpg-primary: #667eea;
    --mcpg-primary-dark: #5568d3;
    --mcpg-secondary: #764ba2;

    /* Couleurs sémantiques */
    --mcpg-success: #28a745;
    --mcpg-danger: #dc3545;
    --mcpg-warning: #ffc107;

    /* Couleurs neutres (avec fallback WordPress) */
    --mcpg-light: var(--wp--preset--color--base, #f8f9fa);
    --mcpg-dark: var(--wp--preset--color--contrast, #333);
    --mcpg-border: var(--wp--preset--color--tertiary, #e9ecef);

    /* Design tokens */
    --mcpg-radius: 12px;
    --mcpg-radius-sm: 8px;
    --mcpg-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --mcpg-shadow-lg: 0 10px 40px rgba(0,0,0,0.3);
    --mcpg-transition: all 0.3s ease;

    /* ✅ NOUVEAU : Tailles de base pour les cards (en em = fluidité) */
    --mcpg-card-padding: 1em;
    --mcpg-card-gap: 1em;
    --mcpg-card-min-width: 12em; /* ~192px à 16px de base */
    --mcpg-picto-size: 3.75em; /* 60px à 16px de base */
}

/* ========================================================================
 * CONTENEURS DE BASE
 * ======================================================================== */

.mcpg-ville-wrapper,
.mcpg-carte-wrapper {
    margin: 30px 0;
    width: 100%;
    box-sizing: border-box;
    font-size: 16px; /* Base pour les calculs em */
}

.mcpg-ville-wrapper *,
.mcpg-carte-wrapper * {
    box-sizing: border-box;
}

/* ========================================================================
 * MESSAGES (Erreur, Chargement, Info)
 * ======================================================================== */

.mcpg-error,
.mcpg-loading,
.mcpg-info {
    padding: 1.25rem;
    border-radius: var(--mcpg-radius-sm);
    margin: 1.25rem 0;
}

.mcpg-error {
    background: #fee;
    border-left: 4px solid var(--mcpg-danger);
    color: var(--mcpg-danger);
}

.mcpg-loading {
    text-align: center;
    color: #999;
}

.mcpg-info {
    background: #e7f3ff;
    border-left: 4px solid #2196f3;
    color: #1976d2;
}

/* ========================================================================
 * HEADER GRADIENT (Réutilisable)
 * ======================================================================== */

.mcpg-header {
    background: linear-gradient(135deg, var(--mcpg-primary) 0%, var(--mcpg-secondary) 100%);
    padding: clamp(20px, 5vw, 40px) clamp(20px, 4vw, 30px);
    color: #fff;
    border-radius: var(--mcpg-radius) var(--mcpg-radius) 0 0;
}

.mcpg-header h1,
.mcpg-header h2,
.mcpg-header h3 {
    color: inherit;
    margin-top: 0;
}

.mcpg-header p {
    opacity: 0.9;
    margin: 0;
}

/* ========================================================================
 * MODALE (Pour affichage 7 jours depuis la carte)
 * ======================================================================== */

.mcpg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.mcpg-modal {
    background: #fff;
    border-radius: var(--mcpg-radius);
    max-width: 1000px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--mcpg-shadow-lg);
    font-size: 16px; /* ✅ Base pour les em */
}

.mcpg-modal-header {
    padding: 1.25em 1.875em;
    background: linear-gradient(135deg, var(--mcpg-primary) 0%, var(--mcpg-secondary) 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--mcpg-radius) var(--mcpg-radius) 0 0;
}

.mcpg-modal-header h2 {
    margin: 0;
    color: inherit;
    font-size: 1.5em;
}

.mcpg-modal-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 1em;
    height: 1em;
    line-height: 1;
    transition: var(--mcpg-transition);
}

.mcpg-modal-close:hover {
    transform: rotate(90deg);
}

.mcpg-modal-body {
    padding: 1.875em;
    overflow-y: auto;
}

.mcpg-modal-forecasts {
    display: flex;
    flex-direction: column;
    gap: 1.875em;
}

.mcpg-modal-day h3 {
    margin: 0 0 0.9375em;
    color: var(--mcpg-primary);
    text-transform: capitalize;
    padding-bottom: 0.625em;
    border-bottom: 2px solid var(--mcpg-border);
    font-size: 1.25em;
}

/* ========================================================================
 * ✅ FORECAST CARDS UNIFIÉES (Modal + Bloc Ville + Popup)
 * VERSION 4.0 : Fluide, robuste, maintenable
 * ======================================================================== */

/* Container grid - Scroll horizontal */
.mcpg-hours-grid {
    display: flex;
    gap: var(--mcpg-card-gap);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5em; /* Espace pour scrollbar */
    cursor: grab;
    user-select: none;
}

.mcpg-hours-grid:active {
    cursor: grabbing;
}

/* Scrollbar styling */
.mcpg-hours-grid::-webkit-scrollbar {
    height: 8px;
}

.mcpg-hours-grid::-webkit-scrollbar-track {
    background: var(--mcpg-light);
    border-radius: 4px;
}

.mcpg-hours-grid::-webkit-scrollbar-thumb {
    background: var(--mcpg-primary);
    border-radius: 4px;
}

.mcpg-hours-grid::-webkit-scrollbar-thumb:hover {
    background: var(--mcpg-primary-dark);
}

/* Card horaire individuelle - Largeur fixe pour scroll horizontal */
.mcpg-hour-card {
    background: var(--mcpg-light);
    padding: var(--mcpg-card-padding);
    border-radius: var(--mcpg-radius-sm);
    text-align: center;
    transition: var(--mcpg-transition);
    display: flex;
    flex-direction: column;
    gap: 0.75em;
    min-width: 13em; /* Largeur fixe confortable (208px à 16px) */
    flex-shrink: 0; /* Ne pas réduire */
}

.mcpg-hour-card:hover {
    background: #e3e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Heure */
.mcpg-hour-time {
    font-weight: 600;
    color: var(--mcpg-primary);
    font-size: 0.9375em; /* 15px relatif */
    cursor: help;
}

/* Container pictos principaux (météo + température) */
.mcpg-hour-main {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.875em;
}

.mcpg-hour-sky-picto {
    width: var(--mcpg-picto-size);
    height: var(--mcpg-picto-size);
    max-width: 100%; /* ✅ Sécurité responsive */
    object-fit: contain;
    cursor: help;
}

.mcpg-hour-main > div {
    cursor: help; /* Badge température */
}

/* Container détails (grille 2 colonnes par défaut) */
.mcpg-hour-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5em;
}

/* ✅ BLOC RESSENTI DÉDIÉ (mode étendu) */
.mcpg-detail-feels-block {
    grid-column: 1 / -1; /* Occupe toute la largeur */
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 6px;
    padding: 0.625em;
}

.mcpg-detail-feels-title {
    font-size: 0.6875em; /* 11px */
    font-weight: 700;
    text-transform: uppercase;
    color: var(--mcpg-primary);
    margin-bottom: 0.5em;
    text-align: center;
}

.mcpg-detail-feels-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5em;
}

.mcpg-detail-feels-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25em;
    padding: 0.375em 0.25em;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    cursor: help;
    user-select: none;
}

.mcpg-detail-feels-label {
    font-size: 0.5625em; /* 9px */
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.7;
    color: #555;
}

.mcpg-detail-feels-value {
    font-size: 1em;
    font-weight: 700;
    color: var(--mcpg-primary);
}

/* Item de détail individuel */
.mcpg-detail-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3125em;
    font-size: 0.8125em; /* 13px */
    color: #555;
    padding: 0.375em;
    background: #fff;
    border-radius: 4px;
    cursor: help;
    transition: var(--mcpg-transition);
    min-width: 0; /* Permet contraction */
    overflow: hidden; /* Empêche débordement */
}

.mcpg-detail-item:hover {
    background: #f0f4ff;
    transform: scale(1.02);
}

.mcpg-detail-emoji {
    font-size: 1.25em;
    flex-shrink: 0;
}

.mcpg-detail-picto {
    width: 1.375em; /* 18px relatif */
    height: 1.375em;
    object-fit: contain;
    flex-shrink: 0;
}

.mcpg-detail-label {
    font-size: 0.769em; /* 10px */
    opacity: 0.75;
    font-weight: 600;
    text-transform: uppercase;
}

.mcpg-detail-value {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

/* ========================================================================
 * SECTIONS & LAYOUT
 * ======================================================================== */

.mcpg-section {
    padding: 1.875em;
    background: #fff;
}

.mcpg-section h2 {
    margin-top: 0;
    color: var(--mcpg-dark);
}

/* ========================================================================
 * BOUTON TOGGLE MOBILE (Carte)
 * ======================================================================== */

.mcpg-controls-toggle {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1001;
    width: 3em;
    height: 3em;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    transition: var(--mcpg-transition);
    user-select: none;
}

.mcpg-controls-toggle:hover {
    background: #f4f4f4;
    transform: scale(1.05);
}

.mcpg-controls-toggle:active {
    transform: scale(0.95);
}

/* ========================================================================
 * ANIMATIONS GLOBALES
 * ======================================================================== */

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Appliquer les animations */
.mcpg-ville-wrapper,
.mcpg-carte-wrapper,
.mcpg-section {
    animation: fadeIn 0.5s ease;
}

.mcpg-hour-card {
    animation: fadeIn 0.3s ease;
}

.mcpg-floating-controls.is-visible {
    animation: slideIn 0.3s ease;
}
