/* css/style.css */

/* =========================================
   1. VARIABLES & DESIGN TOKENS
   ========================================= */
:root {
    --cpw-primary: #007bff;
    --cpw-primary-rgb: 0, 123, 255;
    --cpw-secondary: #6f42c1;
    --cpw-bg: #f8f9fa;
    --cpw-card-bg: #ffffff;
    --cpw-text: #1a1d23;
    --cpw-text-muted: #64748b;
    --cpw-border-color: #e2e8f0;
    --cpw-glass-border: rgba(255, 255, 255, 0.8);
    --cpw-glass-bg: rgba(255, 255, 255, 0.95);
    --cpw-shadow-lg: 0 10px 40px -10px rgba(0,0,0,0.08);
    --cpw-radius: 20px;
    --cpw-container: 1400px;
    --header-height: 80px; 
}

[data-theme="dark"] {
    --cpw-bg: #0f172a;
    --cpw-card-bg: #1e293b;
    --cpw-text: #f1f5f9;
    --cpw-text-muted: #94a3b8;
    --cpw-border-color: rgba(255, 255, 255, 0.1);
    --cpw-glass-border: rgba(255, 255, 255, 0.1);
    --cpw-glass-bg: rgba(30, 41, 59, 0.98);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--cpw-bg);
    color: var(--cpw-text);
    min-height: 100vh;
    display: flex; flex-direction: column;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }

.cpw-container {
    max-width: var(--cpw-container);
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
.cpw-header {
    height: var(--header-height);
    position: sticky; 
    top: 0; 
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--cpw-border-color);
    display: flex;
    align-items: center;
}
[data-theme="dark"] .cpw-header {
    background: rgba(15, 23, 42, 0.9);
}

.cpw-navbar {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
}

/* Logo */
.cpw-logo {
    font-size: 1.5rem; font-weight: 800; color: var(--cpw-primary);
    display: flex; align-items: center; z-index: 1002;
}
.cpw-logo span { color: var(--cpw-text); margin-left: 4px; }

/* Menu Desktop */
.cpw-nav-desktop {
    display: flex; align-items: center; gap: 2rem;
}
.cpw-nav-link {
    font-weight: 500; font-size: 0.95rem; color: var(--cpw-text-muted); padding: 0.5rem;
}
.cpw-nav-link:hover, .cpw-nav-link.active { color: var(--cpw-primary); font-weight: 600; }

/* Actions Header */
.cpw-actions {
    display: flex; align-items: center; gap: 0.8rem; z-index: 1002;
}

.cpw-btn-icon {
    width: 42px; height: 42px; border-radius: 50%;
    background: transparent;
    border: 1px solid var(--cpw-border-color);
    color: var(--cpw-text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; position: relative;
}
.cpw-btn-icon:hover { background: var(--cpw-border-color); transform: translateY(-2px); }

/* Avatar (Correction : plus de bordure carrée) */
.profile-btn {
    background: none; border: none; padding: 0; cursor: pointer; display: flex;
    border-radius: 50%; /* Force le rond */
}
.header-avatar {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--cpw-border-color);
    display: block;
}
.header-avatar:hover { border-color: var(--cpw-primary); }

/* =========================================
   3. MENU MOBILE
   ========================================= */
.cpw-burger { 
    display: none; 
    border: 1px solid var(--cpw-border-color); 
    border-radius: 50%; 
    width: 42px; height: 42px; 
    background: transparent; 
    color: var(--cpw-text); 
    font-size: 1.2rem;
    align-items: center; justify-content: center;
    cursor: pointer;
}

.cpw-mobile-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: var(--cpw-card-bg);
    z-index: 2000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.cpw-mobile-overlay.active { opacity: 1; visibility: visible; }

.cpw-mobile-nav { display: flex; flex-direction: column; gap: 2rem; text-align: center; font-size: 1.2rem; }
.cpw-mobile-nav a { font-weight: 600; color: var(--cpw-text); }
.cpw-mobile-nav a.active { color: var(--cpw-primary); }

.cpw-close-btn {
    position: absolute; top: 20px; right: 20px;
    background: var(--cpw-bg); 
    width: 45px; height: 45px; border-radius: 50%;
    border: 1px solid var(--cpw-border-color); 
    font-size: 1.5rem; color: var(--cpw-text); 
    cursor: pointer; z-index: 2001;
    display: flex; align-items: center; justify-content: center;
}

@media (max-width: 992px) {
    .cpw-nav-desktop { display: none; }
    .cpw-burger { display: flex; }
}

/* =========================================
   4. DROPDOWNS (STYLE & NOTIFS)
   ========================================= */
.dropdown-menu {
    position: absolute; top: 60px; right: 0; width: 300px;
    background: var(--cpw-card-bg);
    border: 1px solid var(--cpw-border-color);
    border-radius: 16px;
    box-shadow: 0 15px 50px -10px rgba(0,0,0,0.2);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 1500;
    overflow: hidden;
}
.dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown-header {
    padding: 1.2rem; background: var(--cpw-bg); 
    border-bottom: 1px solid var(--cpw-border-color);
    text-align: left;
}
.dropdown-header h5 { margin: 0; font-size: 1rem; color: var(--cpw-text); font-weight: 700; }
.dropdown-header span { font-size: 0.85rem; color: var(--cpw-text-muted); display: block; margin-top: 2px;}

/* Liste Profil */
.dropdown-list { padding: 0.5rem; }
.dropdown-list li a {
    display: flex; align-items: center; gap: 12px; padding: 0.8rem 1rem;
    border-radius: 8px; font-size: 0.95rem; color: var(--cpw-text);
    font-weight: 500; text-decoration: none;
}
.dropdown-list li a:hover { background: rgba(0, 123, 255, 0.08); color: var(--cpw-primary); }
.dropdown-list li a i { width: 20px; text-align: center; color: var(--cpw-text-muted); }
.dropdown-list li a:hover i { color: var(--cpw-primary); }

.dropdown-list li.divider { height: 1px; background: var(--cpw-border-color); margin: 0.5rem 0; }
.text-danger { color: #dc3545 !important; }
.text-danger:hover { background: rgba(220, 53, 69, 0.08) !important; color: #dc3545 !important; }
.text-danger i { color: #dc3545 !important; }

/* Liste Notifications */
.dropdown-body { max-height: 320px; overflow-y: auto; }
.empty-text { padding: 2rem; text-align: center; color: var(--cpw-text-muted); font-style: italic; }

.dropdown-item {
    padding: 1rem; border-bottom: 1px solid var(--cpw-border-color);
    display: flex; gap: 1rem; transition: 0.2s; text-decoration: none; align-items: flex-start;
}
.dropdown-item:hover { background: var(--cpw-bg); }
.dropdown-item i { margin-top: 3px; color: var(--cpw-primary); font-size: 1.1rem; }
.dropdown-item span { font-size: 0.9rem; line-height: 1.4; color: var(--cpw-text); }
.dropdown-item.unread { background: rgba(0, 123, 255, 0.05); border-left: 3px solid var(--cpw-primary); }

/* Bouton Voir tout (Style Bouton) */
.dropdown-footer { padding: 1rem; text-align: center; background: var(--cpw-bg); border-top: 1px solid var(--cpw-border-color); }
.dropdown-footer a {
    display: block; width: 100%; padding: 0.7rem;
    background: var(--cpw-card-bg); border: 1px solid var(--cpw-border-color);
    border-radius: 10px; color: var(--cpw-text); font-weight: 600; font-size: 0.9rem;
    transition: 0.2s; text-decoration: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.dropdown-footer a:hover {
    background: var(--cpw-primary); color: white; border-color: var(--cpw-primary);
    transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}

/* =========================================
   5. PAGES AUTH & FORMULAIRES
   ========================================= */
/* Centrage Vertical */
.auth-layout {
    padding: 4rem 1.5rem; 
    min-height: calc(100vh - 250px); 
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
}

/* Application Layout (Dashboard) */
.app-layout { 
    padding-top: 2rem; /* Espace après le header */
    padding-bottom: 4rem; /* Espace avant le footer */
    min-height: calc(100vh - var(--header-height));
}

/* Formulaires */
.cpw-form-group { margin-bottom: 1.5rem; width: 100%; text-align: left; }
.cpw-form-group label {
    display: block; font-weight: 600; margin-bottom: 0.5rem;
    font-size: 0.9rem; color: var(--cpw-text);
}

.input-wrapper { position: relative; width: 100%; }

/* Input - Forcer le style pour les pages Auth */
.cpw-form-control, 
.input-wrapper input {
    width: 100%; 
    padding: 0.9rem 1rem 0.9rem 2.8rem; /* Place pour l'icône */
    border: 1px solid var(--cpw-border-color);
    border-radius: 12px;
    font-size: 0.95rem; 
    font-family: 'Inter', sans-serif;
    background: var(--cpw-card-bg);
    color: var(--cpw-text);
    transition: all 0.3s;
    appearance: none;
}

.cpw-form-control:focus,
.input-wrapper input:focus {
    border-color: var(--cpw-primary); 
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--cpw-primary-rgb), 0.15);
}

/* Icônes Inputs */
.input-icon {
    position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
    color: var(--cpw-text-muted); font-size: 1rem; pointer-events: none; z-index: 2;
}

/* Boutons */
.cpw-btn-primary {
    width: 100%; display: flex; align-items: center; justify-content: center;
    padding: 0.9rem; border-radius: 50px; border: none;
    background: linear-gradient(135deg, var(--cpw-primary) 0%, #6f42c1 100%);
    color: white; font-weight: 600; font-size: 1rem; cursor: pointer;
    box-shadow: 0 4px 15px rgba(var(--cpw-primary-rgb), 0.3);
    transition: 0.3s; text-decoration: none;
}
.cpw-btn-primary:hover { transform: translateY(-2px); filter: brightness(1.1); color: white; }

.secondary-btn {
    padding: 0.5rem 1rem; border-radius: 8px; background: rgba(0, 123, 255, 0.1); 
    color: var(--cpw-primary); font-weight: 600; font-size: 0.9rem; border: none; transition: 0.2s;
}
.secondary-btn:hover { background: var(--cpw-primary); color: white; }

/* =========================================
   6. FOOTER
   ========================================= */
.cpw-footer {
    width: 100%;
    padding: 2rem 0;
    margin-top: auto; /* Pousse le footer en bas */
    border-top: 1px solid var(--cpw-border-color);
    background: var(--cpw-bg); /* Couleur unie pour cacher le contenu qui défile */
}

.cpw-footer-container {
    display: flex; flex-direction: column; align-items: center; gap: 1rem;
    text-align: center;
}

.cpw-footer p { font-size: 0.9rem; color: var(--cpw-text-muted); margin: 0; }

.cpw-footer-links {
    display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: center;
}
.cpw-footer-links a {
    font-size: 0.9rem; color: var(--cpw-text); font-weight: 500;
}
.cpw-footer-links a:hover { color: var(--cpw-primary); }

/* =========================================
   7. AUTRES (Toast, Glass, etc)
   ========================================= */
.glass-panel, .cpw-card {
    background: var(--cpw-card-bg);
    border: 1px solid var(--cpw-border-color);
    border-radius: var(--cpw-radius);
    padding: 2.5rem;
    box-shadow: var(--cpw-shadow-lg);
}

.reveal { opacity: 0; transform: translateY(20px); animation: fadeUp 0.6s forwards; }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

/* Badge Notification */
.notification-badge {
    position: absolute; top: -2px; right: -2px;
    background: #dc3545; color: white;
    font-size: 0.65rem; font-weight: 700;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--cpw-card-bg);
}

/* Toast (Correction Z-INDEX pour apparaître sur Auth) */
#toast-container {
    position: fixed; top: 20px; right: 20px; 
    z-index: 999999; /* Z-Index maximum pour passer au-dessus de tout */
    display: flex; flex-direction: column; gap: 10px;
}

.cpw-toast {
    background: var(--cpw-card-bg); color: var(--cpw-text);
    padding: 1rem 1.5rem; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); /* Ombre plus forte */
    border-left: 4px solid var(--cpw-primary);
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 10px; animation: slideIn 0.3s;
    min-width: 300px;
}
.cpw-toast.success { border-color: #28a745; }
.cpw-toast.error { border-color: #dc3545; }
.cpw-toast i { font-size: 1.2rem; }
.cpw-toast.success i { color: #28a745; }
.cpw-toast.error i { color: #dc3545; }

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Erreurs Formulaire */
.error-msg { color: #dc3545; font-size: 0.85rem; margin-top: 5px; display: block; }
.input-wrapper input.error { border-color: #dc3545; background: rgba(220, 53, 69, 0.05); }

/* Responsive adjustments */
@media (max-width: 768px) {
    .glass-panel { padding: 1.5rem; width: 100%; }
    .cpw-row-2 { grid-template-columns: 1fr !important; }
}

/* =========================================
   8. MOBILE RESPONSIVE FIXES 
   ========================================= */
@media (max-width: 768px) {
    
    /* 1. HEADER COMPACT */
    .cpw-header {
        height: 65px; 
        padding: 0.5rem 0;
    }
    
    /* Logo réduit et collé */
    .cpw-logo { 
        font-size: 1.2rem; 
        margin-right: auto; 
    }
    .cpw-logo span { margin-left: 2px; }

    /* Actions serrées */
    .cpw-actions { gap: 0.4rem; }

    /* Boutons plus petits sur mobile */
    .cpw-btn-icon, .header-avatar, .cpw-burger {
        width: 36px; height: 36px;
        font-size: 1rem;
    }
    
    /* Cacher le sélecteur de thème du header (on le met dans le burger) */
    .desktop-only-action { display: none !important; }

    /* 2.DROPDOWN */
    .notification-dropdown, 
    .profile-dropdown {
        position: static !important; 
    }

    .dropdown-menu {
        width: 94vw !important; 
        left: 3vw !important;   
        right: auto !important;
        top: 60px !important;   
        max-width: none !important;
    }

    /* 3. MENU BURGER AJUSTEMENTS */
    .cpw-mobile-nav {
        gap: 1.5rem;
        width: 100%;
        padding: 0 2rem;
    }
    
    /* Style du bouton thème dans le menu mobile */
    .mobile-theme-btn {
        margin-top: 1rem;
        padding: 0.8rem;
        border: 1px solid var(--cpw-border-color);
        border-radius: 12px;
        background: var(--cpw-bg);
        color: var(--cpw-text);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        font-weight: 500;
        width: 100%;
        cursor: pointer;
    }
}

@media (max-width: 768px) {
    
    /* 1. FORCE LES GRILLES EN UNE SEULE COLONNE */
    .cpw-row-2, 
    .creaplusweb-grid-responsive-split,
    .form-row,
    .creaplusweb-grid { 
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    /* 2. REGLAGE DES PADDINGS ET LARGEURS */
    .cpw-container {
        padding: 0 1rem;
    }

    .glass-panel, .cpw-card { 
        padding: 1.5rem !important; 
    }
    
    /* 3. INPUTS PLEINE LARGEUR */
    .input-wrapper {
        width: 100% !important;
    }
    
    .input-wrapper input, 
    .cpw-form-control {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box !important;
    }

    /* 4. HEADER MOBILE COMPACT */
    .cpw-header { height: 70px; padding: 0.5rem 0; }
    .cpw-logo { font-size: 1.3rem; }
    .cpw-actions { gap: 0.5rem; }
    
    .cpw-btn-icon, .header-avatar, .cpw-burger {
        width: 38px; height: 38px; font-size: 1.1rem;
    }
    
    /* Cacher le sélecteur de thème desktop */
    #themeToggleDesktop { display: none !important; }
}

/* Jauge de force mot de passe */
.password-strength {
    margin-top: 8px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}
.password-strength-bar {
    height: 100%;
    width: 0;
    background: #dc3545; 
    transition: width 0.3s, background 0.3s;
}
.strength-text {
    font-size: 0.75rem;
    margin-top: 4px;
    display: block;
    text-align: right;
    font-weight: 600;
}

/* --- MODALES (Popup) --- */
.cpw-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6); /* Fond sombre flouté */
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.cpw-modal-overlay.active { opacity: 1; visibility: visible; }

.cpw-modal {
    background: var(--cpw-card-bg);
    width: 90%; max-width: 400px;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    border: 1px solid var(--cpw-border-color);
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    transform: translateY(20px); transition: all 0.3s ease;
}
.cpw-modal-overlay.active .cpw-modal { transform: translateY(0); }

.cpw-modal-icon {
    width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 1.5rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
}
.cpw-modal-icon.danger { background: rgba(220, 53, 69, 0.1); color: #dc3545; }
.cpw-modal-icon.warning { background: rgba(255, 193, 7, 0.1); color: #ffc107; }

.cpw-modal h3 { margin-bottom: 0.5rem; color: var(--cpw-text); }
.cpw-modal p { color: var(--cpw-text-muted); margin-bottom: 1.5rem; font-size: 0.95rem; }

.cpw-modal-actions { display: flex; gap: 1rem; justify-content: center; }
.cpw-modal-actions button { flex: 1; padding: 0.8rem; border-radius: 12px; font-weight: 600; cursor: pointer; border: none; }
.btn-cancel { background: var(--cpw-bg); color: var(--cpw-text); border: 1px solid var(--cpw-border-color) !important; }
.btn-danger { background: #dc3545; color: white; box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3); }

/* =========================================
   BADGE NOTIFICATION
   ========================================= */

/* 1. Sécurité : On s'assure que le bouton parent retient le badge */
.cpw-btn-icon {
    position: relative !important; 
    overflow: visible !important; /* Important pour ne pas couper le badge */
}

/* 2. Le Badge Rouge Peps */
.notification-badge {
    position: absolute;
    top: -2px;        /* Un peu plus haut que l'icône */
    right: -2px;      /* Un peu plus à droite */
    
    background: #ff3b30; /* Rouge vibrant style iOS */
    color: white;
    
    /* Forme parfaite */
    min-width: 18px;
    height: 18px;
    border-radius: 10px; /* Forme pilule */
    padding: 0 4px;
    
    /* Texte centré */
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 18px; /* Centrage vertical précis */
    text-align: center;
    
    /* Finitions */
    border: 2px solid #ffffff; /* Contour blanc pour détacher */
    box-shadow: 0 2px 5px rgba(255, 59, 48, 0.4); /* Légère lueur rouge */
    
    /* Animation */
    transform-origin: center;
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 99;
    pointer-events: none; /* Le clic traverse le badge pour cliquer sur la cloche */
}

/* 3. Ajustement Mode Sombre */
[data-theme="dark"] .notification-badge {
    border-color: #1e293b; /* Le contour s'adapte au fond sombre */
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* 4. Animation d'apparition */
@keyframes badgePop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- STYLE DES TITRES DE PAGE (Global) --- */
.page-header { 
    margin-bottom: 2rem;
    padding-bottom: 1rem;
}

.page-header h1 { 
    font-size: 1.8rem; 
    font-weight: 800; 
    margin-bottom: 0.5rem; 
    color: var(--cpw-text);
    line-height: 1.2;
}

.page-header p {
    color: var(--cpw-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* Le dégradé Bleu (Highlight) */
.cpw-highlight {
    background: linear-gradient(135deg, #007bff 0%, #00d2ff 100%);
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent;
    display: inline-block; /* Assure que le dégradé s'applique correctement */
}
