/* Platinum OS - Dashboard Style 
    Version: 2.0 (Optimized)
    Design: Glassmorphism / Mobile-First
*/

:root {
    --accent: #6366f1;
    --bg: #0f172a;
    --card-bg: #1e293b; 
    --card-glass: rgba(30, 41, 59, 0.45);
    --border: rgba(255, 255, 255, 0.08);
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --nav-bg: #0f172a;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --nav-bg: #ffffff;
    --card-glass: rgba(255, 255, 255, 0.7);
}

/* Base Reset */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { 
    margin: 0; 
    background: var(--bg); 
    font-family: 'Inter', sans-serif; 
    color: var(--text-main); 
    transition: background var(--transition), color var(--transition);
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- NAVBAR & NAVIGATION --- */
.navbar { 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    background: var(--nav-bg); 
    border-bottom: 1px solid var(--border); 
    padding: 10px 5%; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    backdrop-filter: blur(10px); 
}

.logo-img { width: 32px; height: 32px; object-fit: contain; }
.nav-right { display: flex; align-items: center; gap: 20px; }

.theme-toggle { 
    background: none; border: none; color: var(--text-main); 
    cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; 
}

/* --- DROPDOWN SYSTEM --- */
.user-dropdown-wrapper { position: relative; }

.avatar-trigger { 
    display: flex; align-items: center; gap: 10px; 
    cursor: pointer; padding: 5px; border-radius: 14px; 
}

.dropdown-menu { 
    position: absolute; right: 0; top: calc(100% + 10px); width: 220px; 
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 18px; 
    padding: 8px; display: none; box-shadow: 0 20px 40px rgba(0,0,0,0.3); z-index: 1001;
}

.dropdown-menu.show { display: block; animation: slideUp 0.2s ease-out; }

.drop-item { 
    padding: 12px 15px; display: flex; align-items: center; gap: 10px; 
    color: var(--text-main); text-decoration: none; border-radius: 10px; 
    font-size: 0.9rem; transition: var(--transition); 
}

.drop-item:hover { background: var(--accent); color: white; }

/* --- PROFILE COMPONENTS --- */
.wrapper { max-width: 1000px; margin: 30px auto; padding: 0 20px; }

.cover-container { 
    width: 100%; height: 280px; border-radius: 32px; 
    overflow: hidden; position: relative; border: 1px solid var(--border); 
    cursor: move; background: #1a1a1a; 
}

.cover-preview { width: 100%; height: 100%; object-fit: cover; transition: 0.1s; }

.cover-upload-badge { 
    position: absolute; top: 20px; right: 20px; 
    background: rgba(0,0,0,0.5); backdrop-filter: blur(10px); 
    padding: 10px 18px; border-radius: 12px; color: white; 
    cursor: pointer; border: 1px solid rgba(255,255,255,0.1); 
    font-size: 12px; font-weight: 600; 
}

.profile-header-main { 
    position: relative; margin-top: -70px; padding: 0 40px; 
    display: flex; align-items: flex-end; gap: 25px; 
}

.avatar-box { 
    position: relative; width: 140px; height: 140px; border-radius: 40px; 
    border: 6px solid var(--bg); overflow: hidden; background: var(--card-bg); 
    box-shadow: 0 15px 35px rgba(0,0,0,0.2); 
}

.avatar-box img { width: 100%; height: 100%; object-fit: cover; }

.avatar-edit-label { 
    position: absolute; inset: 0; background: rgba(0,0,0,0.5); 
    display: flex; align-items: center; justify-content: center; 
    opacity: 0; transition: var(--transition); cursor: pointer; color: white; 
}

.avatar-box:hover .avatar-edit-label { opacity: 1; }

/* --- FORMS & GLASS CARDS --- */
.glass-card { 
    margin-top: 35px; background: var(--card-glass); 
    backdrop-filter: blur(20px); border: 1px solid var(--border); 
    border-radius: 32px; padding: 40px; 
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }

label { 
    color: var(--text-dim); font-size: 0.75rem; font-weight: 700; 
    text-transform: uppercase; letter-spacing: 0.5px; 
}

input { 
    background: rgba(255,255,255,0.05); border: 1px solid var(--border); 
    padding: 14px; border-radius: 14px; color: var(--text-main); 
    outline: none; transition: var(--transition); 
}

input:focus { border-color: var(--accent); background: rgba(255,255,255,0.08); }

/* --- PASSWORD STRENGTH METER --- */
.strength-meter { 
    height: 4px; width: 100%; background: rgba(255,255,255,0.1); 
    border-radius: 2px; margin-top: -5px; overflow: hidden; 
}

.strength-bar { height: 100%; width: 0%; transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.strength-text { font-size: 10px; font-weight: 700; text-transform: uppercase; margin-top: 2px; }

.btn-primary { 
    background: var(--accent); color: white; border: none; 
    padding: 16px; border-radius: 16px; font-weight: 700; 
    cursor: pointer; width: 100%; margin-top: 25px; transition: var(--transition); 
}

.btn-primary:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 10px 20px rgba(99,102,241,0.25); 
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }

.toast { 
    background: var(--card-bg); border: 1px solid var(--border); color: var(--text-main); 
    padding: 16px 25px; border-radius: 18px; backdrop-filter: blur(15px); 
    box-shadow: 0 15px 35px rgba(0,0,0,0.3); display: flex; align-items: center; 
    gap: 12px; transform: translateX(125%); 
    transition: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); min-width: 300px; 
}

.toast.show { transform: translateX(0); }

/* --- ANIMATIONS & MEDIA QUERIES --- */
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .profile-header-main { flex-direction: column; align-items: center; text-align: center; margin-top: -60px; }
    .avatar-box { width: 120px; height: 120px; }
    .navbar { padding: 10px 15px; }
    .toast { min-width: 260px; right: 20px; left: 20px; bottom: 20px; }
}

/* État actif du bouton favori */
.fav-btn.active i { color: #ef4444 !important; transform: scale(1.2); }
.fav-btn { transition: transform 0.2s ease; cursor: pointer; }

/* Affichage de la modale */
/* --- AMÉLIORATION QUICK VIEW --- */
.modal { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.85); 
    backdrop-filter: blur(20px); z-index: 2000; 
    display: none; opacity: 0; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    justify-content: center; align-items: flex-start; /* Permet le scroll naturel */
    overflow-y: auto; padding: 20px;
}

.modal.show { display: flex; opacity: 1; }

.modal-content { 
    background: var(--card-bg); width: 100%; max-width: 900px; 
    border-radius: 32px; overflow: hidden; position: relative;
    border: 1px solid var(--border); box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    transform: translateY(30px) scale(0.95); transition: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.show .modal-content { transform: translateY(0) scale(1); }

/* Header de l'image avec overlay */
.modal-hero { 
    width: 100%; height: 450px; background-size: cover; 
    background-position: center; position: relative; 
}

.modal-hero::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to bottom, transparent 50%, var(--card-bg));
}

/* Bouton Fermer Flottant */
.close-modal { 
    position: fixed; top: 30px; right: 30px; width: 45px; height: 45px; 
    background: rgba(255,255,255,0.1); backdrop-filter: blur(10px);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: white; cursor: pointer; z-index: 100; transition: var(--transition);
    border: 1px solid rgba(255,255,255,0.2);
}
.close-modal:hover { background: var(--accent); transform: rotate(90deg); }

/* Typographie et Corps */
.modal-body { padding: 50px 60px; }


.filter-tabs {
    display: inline-flex; /* S'adapte à la largeur du contenu */
    background: var(--card-glass);
    padding: 6px;
    border-radius: 16px;
    border: 1px solid var(--border);
    gap: 5px;
    position: relative;
    margin-bottom: 30px;
}

.filter-btn {
    position: relative;
    background: transparent !important; /* On enlève le fond par défaut */
    border: none !important;
    padding: 10px 20px;
    border-radius: 12px;
    color: var(--text-dim);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2; /* Pour rester au-dessus de l'effet glissant */
}

/* État du texte quand le bouton est actif */
.filter-btn.active {
    color: #fff;
}

/* L'indicateur glissant (L'effet "Pill") */
.filter-tabs::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    height: calc(100% - 12px);
    width: var(--active-width, 120px); /* Géré par JS */
    transform: translateX(var(--active-pos, 0px)); /* Géré par JS */
    background: var(--accent);
    border-radius: 10px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1); /* Transition fluide "Elastic" */
    z-index: 1;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.filter-tabs::-webkit-scrollbar {
    display: none; /* Cache la barre de scroll sur Chrome/Safari/iOS */
}




.modal-full-text { 
    line-height: 1.8; font-size: 1.15rem; color: var(--text-main); 
    opacity: 0.9; letter-spacing: -0.01em; 
}

/* Barre de progression de lecture */
.progress-container { 
    position: sticky; top: 0; width: 100%; height: 5px; 
    background: rgba(255,255,255,0.05); z-index: 110; 
}
.progress-bar { height: 100%; background: var(--accent); width: 0%; border-radius: 0 5px 5px 0; box-shadow: 0 0 15px var(--accent); }

/* Responsive */
@media (max-width: 768px) {
    .modal { padding: 0; }
    .modal-content { border-radius: 0; min-height: 100vh; }
    .modal-body { padding: 30px 20px; }
    #modalTitle { font-size: 2rem; }
    .close-modal { top: 20px; right: 20px; }
}
/*.modal.show { display: flex; opacity: 1; } */

.progress-container { position: sticky; top: 0; width: 100%; height: 4px; background: rgba(255,255,255,0.1); z-index: 10; }
.progress-bar { height: 100%; background: var(--accent); width: 0%; }




.modal-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.action-btn {
    background: var(--card-glass);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
}

.action-btn i { font-size: 1rem; }





/* Grille d'articles optimisée 4 colonnes */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 colonnes sur PC */
    gap: 25px;
    margin-top: 30px;
    transition: var(--transition);
}

/* Responsive */
@media (max-width: 1100px) {
    .articles-grid { grid-template-columns: repeat(3, 1fr); } /* 3 colonnes sur tablettes */
}

@media (max-width: 850px) {
    .articles-grid { grid-template-columns: repeat(2, 1fr); } /* 2 colonnes sur petits écrans */
}

@media (max-width: 550px) {
    .articles-grid { grid-template-columns: 1fr; } /* 1 colonne sur mobile */
}

/* Spinner de chargement */
#infinite-loader {
    text-align: center;
    padding: 40px;
    width: 100%;
    grid-column: 1 / -1; /* Prend toute la largeur de la grille */
    display: none;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }


/* --- NAVIGATION FILTRE ANIMÉE --- */
.filter-wrapper {
    margin-bottom: 30px;
    display: flex;
    justify-content: flex-start;
}

.filter-tabs {
    display: inline-flex;
    background: var(--card-glass);
    backdrop-filter: blur(10px);
    padding: 6px;
    border-radius: 16px;
    border: 1px solid var(--border);
    position: relative;
    gap: 5px;
    z-index: 1;
}

/* L'indicateur qui glisse */
.filter-tabs::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    height: calc(100% - 12px);
    width: var(--active-width, 140px);
    background: var(--accent);
    border-radius: 12px;
    transform: translateX(var(--active-pos, 0));
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: -1;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.filter-btn {
    background: transparent !important;
    border: none !important;
    padding: 10px 20px;
    border-radius: 12px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
    white-space: nowrap;
}

/* Couleur du texte quand actif */
.filter-btn.active {
    color: #ffffff !important;
}

/* Empêche le chevauchement sur mobile */
@media (max-width: 600px) {
    .filter-wrapper { overflow-x: auto; padding-bottom: 10px; }
    .filter-tabs { width: max-content; }
}