/**
 * FICHE-PAIE.FR - Générateur de bulletins de paie
 *
 * @copyright 2025-2026 Purple Telecom EURL
 * @license   Proprietary - All Rights Reserved
 * @author    Équipe POLYGON
 * @link      https://fiche-paie.fr
 *
 * Modal Panier Multi-Bulletins - Styles CSS
 * Étape 3.D V3 - Migration 3NF Phase 3
 *
 * Design mobile-first avec variables CSS
 * Format 16:9 responsive avec grille
 * V3 : Prix masqués si non sélectionné, badges cohérence
 */

/* =====================================================
   VARIABLES COULEURS - CART MODAL
   Utilisation des couleurs du site fiche-paie.fr
   ===================================================== */
:root {
    /* Couleurs principales du site */
    --cart-primary: var(--gp-bleu-marine, #1e3760);
    --cart-primary-hover: var(--primary-dark, #163a75);
    --cart-accent: var(--gp-turquoise, #5ec5c8);
    --cart-accent-hover: var(--gp-bleu-moyen, #7da4d7);
    
    /* Couleurs sémantiques */
    --cart-success: var(--gp-success, #10b981);
    --cart-success-light: #d1fae5;
    --cart-error: var(--gp-error, #ef4444);
    
    /* Textes et fonds */
    --cart-text: #1f2937;
    --cart-text-muted: var(--gp-gris, #6b7280);
    --cart-border: #e5e7eb;
    --cart-border-dashed: #9ca3af;
    --cart-bg: var(--gp-blanc, #ffffff);
    --cart-bg-light: var(--gp-gris-clair, #f3f4f6);
    --cart-bg-selected: #e6eff8;
    
    /* Effets */
    --cart-shadow: rgba(30, 55, 96, 0.15);
    --cart-overlay: rgba(30, 55, 96, 0.6);
}

/* =====================================================
   OVERLAY
   ===================================================== */
.cart-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--cart-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal, 500);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cart-modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* =====================================================
   MODAL CONTAINER - FORMAT 16:9 RESPONSIVE
   ===================================================== */
.cart-modal {
    background: var(--cart-bg);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px var(--cart-shadow);
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

/* Desktop : Format 16:9, max 900px */
/* Migré de 1024px vers 992px - Étape 6 responsive */
@media (min-width: 992px) {
    .cart-modal {
        max-width: 900px;
        min-height: 500px;
    }
}

/* Tablette : max 700px */
/* Migré de 600px-1023px vers 576px-991px - Étape 6 responsive */
@media (min-width: 576px) and (max-width: 991px) {
    .cart-modal {
        max-width: 700px;
    }
}

/* Mobile : pleine largeur */
/* Migré de 599px vers 575px - Étape 6 responsive */
@media (max-width: 575px) {
    .cart-modal {
        max-width: 100%;
        margin: 10px;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
    }
}

.cart-modal-overlay.active .cart-modal {
    transform: translateY(0);
}

/* =====================================================
   HEADER
   ===================================================== */
.cart-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--cart-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cart-modal-header-icon {
    width: 32px;
    height: 32px;
    color: var(--cart-primary);
    flex-shrink: 0;
}

.cart-modal-header-text {
    flex: 1;
}

.cart-modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cart-text);
    margin: 0 0 0.25rem 0;
}

.cart-modal-header p {
    font-size: 0.875rem;
    color: var(--cart-text-muted);
    margin: 0;
}

.cart-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cart-text-muted);
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.cart-modal-close:hover {
    background: var(--cart-bg-light);
    color: var(--cart-text);
}

/* =====================================================
   BODY / LISTE BULLETINS
   ===================================================== */
.cart-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* Scrollbar brandée aux couleurs du site */
.cart-modal-body::-webkit-scrollbar {
    width: 8px;
}

.cart-modal-body::-webkit-scrollbar-track {
    background: var(--cart-bg-light);
    border-radius: 4px;
}

.cart-modal-body::-webkit-scrollbar-thumb {
    background: var(--cart-primary);
    border-radius: 4px;
}

.cart-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--cart-primary-hover);
}

/* Firefox scrollbar */
.cart-modal-body {
    scrollbar-width: thin;
    scrollbar-color: var(--cart-primary) var(--cart-bg-light);
}

.cart-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cart-text-muted);
    margin: 0 0 0.75rem 0;
}

/* =====================================================
   GRILLE DE BULLETINS - RESPONSIVE
   ===================================================== */
.cart-bulletin-list {
    display: grid;
    gap: 12px;
}

/* Desktop : 4 colonnes */
/* Migré de 1024px vers 992px - Étape 6 responsive */
@media (min-width: 992px) {
    .cart-bulletin-list {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablette : 2 colonnes */
/* Migré de 600px-1023px vers 576px-991px - Étape 6 responsive */
@media (min-width: 576px) and (max-width: 991px) {
    .cart-bulletin-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile : 1 colonne */
/* Migré de 599px vers 575px - Étape 6 responsive */
@media (max-width: 575px) {
    .cart-bulletin-list {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   BULLETIN ITEM - CARTE COMPACTE
   ===================================================== */
.cart-bulletin-item {
    border: 2px solid var(--cart-border);
    border-radius: 12px;
    padding: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 100px;
}

.cart-bulletin-item:hover {
    border-color: var(--cart-primary);
    background: var(--cart-bg-selected);
    box-shadow: 0 4px 12px rgba(30, 55, 96, 0.1);
}

.cart-bulletin-item.selected {
    border-color: var(--cart-primary);
    background: var(--cart-bg-selected);
}

.cart-bulletin-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cart-bulletin-item.not-filled {
    border-style: dashed;
    border-color: var(--cart-border-dashed);
}

.cart-bulletin-item.not-filled:hover {
    border-color: var(--cart-accent);
    background: var(--cart-bg-light);
}

/* Checkbox custom - coin supérieur droit */
.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.cart-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--cart-border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: var(--cart-bg);
    flex-shrink: 0;
}

.cart-bulletin-item.selected .cart-checkbox {
    background: var(--cart-primary);
    border-color: var(--cart-primary);
}

.cart-checkbox-icon {
    width: 12px;
    height: 12px;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
}

.cart-bulletin-item.selected .cart-checkbox-icon {
    opacity: 1;
}

/* Période et prix */
.cart-bulletin-period {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--cart-text);
    line-height: 1.2;
}

.cart-bulletin-price {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--cart-primary);
    white-space: nowrap;
}

.cart-bulletin-details {
    font-size: 0.75rem;
    color: var(--cart-text-muted);
    line-height: 1.3;
}

/* =====================================================
   V3 : MASQUER PRIX/DÉTAILS SI NON SÉLECTIONNÉ
   ===================================================== */
.cart-bulletin-item:not(.selected) .cart-bulletin-price,
.cart-bulletin-item:not(.selected) .cart-bulletin-details,
.cart-bulletin-item:not(.selected) .cart-bulletin-actions {
    display: none;
}

/* Badge "Saisi" pour mois de base */
.cart-badge-base {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--cart-bg);
    background: var(--cart-accent);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* Mois de base - style spécial */
.cart-bulletin-item.base {
    border-color: var(--cart-accent);
    background: rgba(94, 197, 200, 0.1);
}

.cart-bulletin-item.base.selected {
    border-color: var(--cart-primary);
}

/* =====================================================
   SECTION BADGES COHÉRENCE (AFFICHÉE SI >1 MOIS)
   ===================================================== */
.cart-coherence-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--cart-success-light);
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.cart-coherence-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cart-success);
    margin-bottom: 0.75rem;
}

.cart-coherence-title svg {
    width: 18px;
    height: 18px;
}

.cart-coherence-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cart-coherence-badge-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cart-success);
    background: var(--cart-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.cart-coherence-badge-item svg {
    width: 12px;
    height: 12px;
}

/* Badge cohérence sur carte - compact */
.cart-coherence-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--cart-success);
    background: var(--cart-success-light);
    padding: 0.1875rem 0.375rem;
    border-radius: 9999px;
    margin-top: 0.25rem;
}

.cart-coherence-badge svg {
    width: 12px;
    height: 12px;
}

/* Bouton Modifier - discret, petite taille */
.cart-bulletin-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: auto;
    padding-top: 0.375rem;
}

.cart-btn-edit {
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--cart-border);
    background: var(--cart-bg);
    color: var(--cart-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.1875rem;
}

.cart-btn-edit:hover {
    border-color: var(--cart-primary);
    color: var(--cart-primary);
    background: var(--cart-bg-selected);
}

.cart-btn-edit svg {
    width: 10px;
    height: 10px;
}

/* État non saisi - compact (masqué par défaut si non sélectionné) */
.cart-not-filled-text {
    font-size: 0.75rem;
    color: var(--cart-text-muted);
    font-style: italic;
}

/* =====================================================
   RÉCAPITULATIF PRIX - SIMPLIFIÉ (HT uniquement)
   ===================================================== */
.cart-summary {
    padding: 1rem 1.5rem;
    background: var(--cart-bg-light);
    border-top: 1px solid var(--cart-border);
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    font-size: 0.875rem;
    color: var(--cart-text-muted);
}

.cart-summary-row.discount {
    color: var(--cart-success);
}

.cart-summary-row.subtotal {
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px dashed var(--cart-border);
}

.cart-summary-row.total {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--cart-text);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 2px solid var(--cart-primary);
}

.cart-summary-label {
    flex: 1;
}

.cart-summary-value {
    font-weight: 500;
}

.cart-summary-row.total .cart-summary-value {
    color: var(--cart-primary);
    font-size: 1.25rem;
}

/* =====================================================
   FOOTER / ACTIONS
   ===================================================== */
.cart-modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--cart-border);
    display: flex;
    gap: 0.75rem;
}

.cart-btn-back {
    flex: 0 0 auto;
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: 1px solid var(--cart-border);
    background: var(--cart-bg);
    color: var(--cart-text-muted);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.cart-btn-back:hover {
    border-color: var(--cart-text-muted);
    color: var(--cart-text);
}

.cart-btn-pay {
    flex: 1;
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    background: var(--cart-primary);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.cart-btn-pay:hover:not(:disabled) {
    background: var(--cart-primary-hover);
}

.cart-btn-pay:disabled {
    background: var(--cart-border);
    cursor: not-allowed;
}

/* Mention sécurité avec couleur accent */
.cart-security-notice {
    padding: 0 1.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--cart-text-muted);
}

.cart-security-notice svg {
    width: 14px;
    height: 14px;
    color: var(--cart-accent);
}

/* =====================================================
   LOADING STATE
   ===================================================== */
.cart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.cart-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--cart-border);
    border-top-color: var(--cart-primary);
    border-radius: 50%;
    animation: cart-spin 0.8s linear infinite;
}

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

/* =====================================================
   RESPONSIVE - AJUSTEMENTS TABLETTE
   ===================================================== */
/* Migré de 640px-1023px vers 768px-991px - Étape 6 responsive */
@media (min-width: 768px) and (max-width: 991px) {
    .cart-modal-header {
        padding: 1.25rem 1.5rem;
    }
    
    .cart-modal-body {
        padding: 1.25rem 1.5rem;
    }
}

/* =====================================================
   RESPONSIVE - MOBILE
   ===================================================== */
/* Migré de 599px vers 575px - Étape 6 responsive */
@media (max-width: 575px) {
    .cart-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    
    .cart-modal-header {
        padding: 1.25rem 1rem;
    }
    
    .cart-modal-body {
        padding: 1rem;
    }
    
    .cart-summary {
        padding: 1rem;
    }
    
    .cart-modal-footer {
        padding: 1rem;
        flex-direction: column-reverse;
    }
    
    .cart-btn-back {
        width: 100%;
        text-align: center;
    }
    
    .cart-security-notice {
        padding: 0 1rem 1rem;
    }
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes cart-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes cart-slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cart-modal-overlay.active {
    animation: cart-fadeIn 0.25s ease;
}

.cart-modal-overlay.active .cart-modal {
    animation: cart-slideUp 0.3s ease;
}
