/* =========================================
   VARIABLES & RESET
   ========================================= */
:root {
    --bg-color: #f0f2f5;
    --text-color: #2c3e50;
    --white: #ffffff;
    --blue-accent: #4a90e2;
    --green-accent: #50e3c2;
    --orange-accent: #ff9f43;
    --purple-accent: #9b59b6;
    --red-accent: #e74c3c;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

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

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

/* =========================================
   NAVIGATION
   ========================================= */
.navbar {
    background-color: var(--white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--blue-accent);
}

.user-profile {
    font-size: 0.9rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 20px;
    background-color: #f0f2f5;
    white-space: nowrap;
}

/* =========================================
   LAYOUT GÉNÉRAL
   ========================================= */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.dashboard-header p {
    color: #7f8c8d;
}

.back-link {
    display: inline-flex;
    align-items: center;
    margin-bottom: 20px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--blue-accent);
}

.back-link span {
    margin-right: 5px;
    font-size: 1.2rem;
}

/* =========================================
   COMPOSANT : ASTUCE DU JOUR
   ========================================= */
.daily-tip-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    position: relative;
}

.tip-content h3 {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tip-content p {
    font-size: 1.1rem;
    font-weight: 500;
    padding-right: 30px;
}

.refresh-tip {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-tip:hover {
    transform: rotate(180deg);
    background: rgba(255,255,255,0.3);
}

/* =========================================
   COMPOSANT : GRILLE DASHBOARD
   ========================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.dash-card {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-top: 4px solid transparent;
    height: 100%;
}

.dash-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.dash-card .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.dash-card h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.dash-card p {
    font-size: 0.9rem;
    color: #7f8c8d;
    line-height: 1.4;
}

/* Couleurs des cartes */
.dash-card.blue { border-top-color: var(--blue-accent); }
.dash-card.blue .icon { color: var(--blue-accent); }

.dash-card.green { border-top-color: var(--green-accent); }
.dash-card.green .icon { color: var(--green-accent); }

.dash-card.orange { border-top-color: var(--orange-accent); }
.dash-card.orange .icon { color: var(--orange-accent); }

.dash-card.purple { border-top-color: var(--purple-accent); }
.dash-card.purple .icon { color: var(--purple-accent); }

/* =========================================
   COMPOSANT : TABLEAU & RECHERCHE (table.html)
   ========================================= */
.table-container {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.search-box {
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 20px;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s;
}

.search-box:focus {
    border-color: var(--blue-accent);
    outline: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-width: 800px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

th {
    background-color: #f8f9fa;
    color: var(--blue-accent);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f1f7fd;
}

/* Codes couleurs pour les catégories du tableau */
.code-g { color: var(--red-accent); font-weight: bold; }
.code-p { color: #f39c12; font-weight: bold; }
.code-s { color: #3498db; font-weight: bold; }
.code-u { color: var(--purple-accent); font-weight: bold; }
.code-v { color: #2ecc71; font-weight: bold; }

/* =========================================
   COMPOSANT : GRILLE D'ASTUCES
   ========================================= */
.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.tip-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--green-accent);
    transition: transform 0.2s, box-shadow 0.2s;
}

.tip-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.tip-card h3 {
    font-size: 1.1rem;
    color: var(--green-accent);
    margin-bottom: 0.5rem;
}

.tip-card p {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.5;
}

/* =========================================
   COMPOSANT : AUTHENTIFICATION (Login/Register)
   ========================================= */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.auth-header h2 {
    margin-bottom: 1rem;
}

.auth-header h2.login { color: var(--blue-accent); }
.auth-header h2.register { color: var(--green-accent); }
.auth-header h2.forgot { color: var(--orange-accent); }

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: 'Poppins', sans-serif;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary.login { background-color: var(--blue-accent); }
.btn-primary.login:hover { background-color: #357abd; }

.btn-primary.register { background-color: var(--green-accent); }
.btn-primary.register:hover { background-color: #3acfae; }

.btn-primary.forgot { background-color: var(--orange-accent); }
.btn-primary.forgot:hover { background-color: #e67e22; }

.auth-footer {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-footer a {
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* =========================================
   COMPOSANT : PROFIL UTILISATEUR
   ========================================= */
.profile-container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.avatar {
    width: 80px;
    height: 80px;
    background-color: var(--blue-accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    margin-right: 20px;
}

.user-info h2 {
    margin-bottom: 5px;
}

.user-info p {
    color: #7f8c8d;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--blue-accent);
    display: block;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    flex: 1;
}

.btn-edit {
    background-color: #f0f2f5;
    color: var(--text-color);
}

.btn-logout {
    background-color: #ffebee;
    color: #c62828;
}

.btn:hover {
    opacity: 0.9;
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    text-align: center;
    padding: 2rem;
    color: #95a5a6;
    font-size: 0.8rem;
    margin-top: auto;
}

/* =========================================
   QUIZ STYLES
   ========================================= */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.quiz-container .card {
    background: var(--white);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: transform 0.3s ease;
}

.quiz-container .card:hover {
    transform: translateY(-2px);
}

.progress-container {
    margin-bottom: 30px;
}

.progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-accent), #8b5cf6);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.question-container {
    display: none;
}

.question-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.question-number {
    color: var(--blue-accent);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-text {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 25px;
    line-height: 1.6;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.option:hover {
    border-color: var(--blue-accent);
    background: #f0f0ff;
}

.option.selected {
    border-color: var(--blue-accent);
    background: #e0e7ff;
}

.option.correct {
    border-color: var(--success);
    background: #d1fae5;
}

.option.incorrect {
    border-color: var(--error);
    background: #fee2e2;
}

.option-letter {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s ease;
}

.option.selected .option-letter {
    background: var(--blue-accent);
    color: white;
}

.option.correct .option-letter {
    background: var(--success);
    color: white;
}

.option.incorrect .option-letter {
    background: var(--error);
    color: white;
}

.result-container {
    display: none;
    text-align: center;
    padding: 40px;
}

.result-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.result-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 3rem;
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--blue-accent);
}

.result-level {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 10px 30px;
    background: linear-gradient(135deg, var(--secondary), #f97316);
    color: white;
    border-radius: 30px;
    display: inline-block;
}

.result-score {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 30px;
}

.result-details {
    background: var(--bg);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.result-details h3 {
    margin-bottom: 15px;
    color: var(--text);
}

.result-details p {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.result-details p:last-child {
    border-bottom: none;
}

.hidden {
    display: none !important;
}

/* =========================================
   RESPONSIVE MEDIA QUERIES
   ========================================= */

/* Tablettes (max 768px) */
@media screen and (max-width: 768px) {
    .navbar { padding: 1rem; }
    .main-container { padding: 1rem; }
    .dashboard-header h1 { font-size: 1.5rem; }
    .daily-tip-banner { padding: 1.2rem; }
    .tip-content p { font-size: 1rem; }
    .dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* Mobiles (max 480px) */
@media screen and (max-width: 480px) {
    .navbar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .dashboard-header { text-align: center; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dash-card {
        align-items: center;
        text-align: center;
        padding: 1.5rem;
    }
    .table-container { padding: 1rem; }
    th, td { padding: 10px; font-size: 0.9rem; }
}