/* ============================================
   Portail - Styles principaux + Admin
   ============================================ */

/* Variables CSS (theme par defaut : Sauge) */
:root {
    --primary: #AADBC8;
    --primary-dark: #7BC4A8;
    --background: #F5F5F0;
    --text: #4A635D;
    --text-light: #6B8A82;
    --white: #FFFFFF;
    --error: #E57373;
    --error-bg: #FFEBEE;
    --success: #81C784;
    --success-bg: #E8F5E9;
    --shadow: rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-small: 8px;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   PAGE D'ACCUEIL PORTAIL
   ============================================ */

.accueil {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.accueil header {
    margin-bottom: 50px;
}

.accueil h1 {
    font-size: 2.5rem;
    color: var(--text);
    margin-bottom: 10px;
}

.accueil .subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
}

/* Header portail avec bouton connexion */
.portail-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--white);
    box-shadow: 0 2px 8px var(--shadow);
    z-index: 100;
}

.portail-header .logo {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.portail-header .header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.portail-header .btn-admin {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: var(--radius-small);
    transition: all 0.2s;
}

.portail-header .btn-admin:hover {
    background: var(--background);
    color: var(--text);
}

.portail-header .btn-auth {
    padding: 8px 20px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.portail-header .btn-auth:hover {
    background: var(--primary);
    color: var(--white);
}

.portail-header .btn-auth.connected {
    background: var(--primary);
    color: var(--text);
}

.portail-header .btn-auth.connected:hover {
    background: var(--error);
    border-color: var(--error);
    color: var(--white);
}

/* Ajuster le contenu pour le header fixe */
.with-header {
    padding-top: 80px;
}

/* Cartes de choix */
.choix-espace {
    display: grid;
    grid-template-columns: repeat(2, 380px);
    gap: 30px;
    justify-content: center;
}

.carte {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px 35px;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 4px 15px var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 260px;
    width: 380px;
}

.carte:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow);
}

.carte-icone {
    font-size: 4rem;
    margin-bottom: 20px;
}

.carte h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text);
}

.carte p {
    color: var(--text-light);
}

.carte-objectif {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 0.85rem;
    line-height: 1.5;
    text-align: left;
    color: var(--text);
}

.carte-objectif strong {
    color: var(--text);
}

.carte-presentation {
    border-top: 4px solid #FFD54F;
}

.carte-vocabulaire {
    border-top: 4px solid #81C784;
}

.carte-conjugaison {
    border-top: 4px solid #FFAB91;
}

.carte-syntaxe {
    border-top: 4px solid var(--primary);
}

.carte-projets {
    border-top: 4px solid #64B5F6;
}

.carte-oral {
    border-top: 4px solid #CE93D8;
}

.carte .carte-badge {
    display: inline-block;
    margin-top: 15px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--success-bg);
    color: #2E7D32;
}

/* Footer */
footer {
    margin-top: auto;
    padding-top: 40px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ============================================
   PAGE DE CONNEXION
   ============================================ */

.login-container {
    justify-content: center;
    align-items: center;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 20px var(--shadow);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 30px;
}

/* Bouton Google */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    border: 1px solid #ddd;
    border-radius: var(--radius-small);
    background: var(--white);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s, box-shadow 0.3s;
}

.btn-google:hover {
    background: #f8f8f8;
    box-shadow: 0 2px 8px var(--shadow);
}

.btn-google img {
    width: 20px;
    height: 20px;
}

/* Separateur */
.separator {
    display: flex;
    align-items: center;
    margin: 25px 0;
    color: var(--text-light);
}

.separator::before,
.separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

.separator span {
    padding: 0 15px;
    font-size: 0.9rem;
}

/* Formulaire */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: var(--radius-small);
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(170, 219, 200, 0.3);
}

/* Bouton principal */
.btn-primary {
    width: 100%;
    padding: 14px 20px;
    background: var(--primary);
    color: var(--text);
    border: none;
    border-radius: var(--radius-small);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Messages d'erreur et succes */
.message {
    padding: 12px 15px;
    border-radius: var(--radius-small);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.message.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error);
}

.message.success {
    background: var(--success-bg);
    color: #2E7D32;
    border: 1px solid var(--success);
}

.message.hidden {
    display: none;
}

/* Liens login */
.login-links {
    margin-top: 20px;
    text-align: center;
}

.login-links a {
    color: var(--primary-dark);
    text-decoration: none;
    font-size: 0.9rem;
}

.login-links a:hover {
    text-decoration: underline;
}

.login-links p {
    margin-top: 15px;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Lien retour */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-light);
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

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

/* ============================================
   INTERFACE ADMIN
   ============================================ */

/* Layout admin */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 250px;
    background: var(--text);
    color: white;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar h1 {
    font-size: 1.2rem;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.admin-sidebar h1 span {
    display: block;
    font-size: 0.75rem;
    font-weight: normal;
    opacity: 0.7;
    margin-top: 5px;
}

.admin-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
}

.admin-nav li a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.admin-nav li a.active {
    background: var(--primary);
    color: var(--text);
}

/* Bouton retour */
.btn-retour {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 25px;
    background: var(--white);
    border: 2px solid var(--primary);
    box-shadow: 0 2px 6px var(--shadow);
    transition: all 0.2s;
}

.btn-retour:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateX(-3px);
}

/* Main content */
.admin-main {
    flex: 1;
    margin-left: 250px;
    padding: 30px;
    background: var(--background);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.admin-header h2 {
    font-size: 1.5rem;
    color: var(--text);
}

.admin-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.stat-card .stat-icon.users { background: #e3f2fd; }
.stat-card .stat-icon.apps { background: #e8f5e9; }
.stat-card .stat-icon.week { background: #fff3e0; }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

.stat-card .stat-trend {
    font-size: 0.8rem;
    margin-top: 10px;
}

.stat-card .stat-trend.up { color: #4caf50; }

/* Tables */
.admin-table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

.admin-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.admin-table-header h3 {
    font-size: 1rem;
    margin: 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table tr:hover {
    background: #f8f9fa;
}

.admin-table .user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-table .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.admin-table .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.admin-table .badge-admin { background: #e3f2fd; color: #1565c0; }
.admin-table .badge-enseignant { background: #f3e5f5; color: #7b1fa2; }

.admin-table .actions {
    display: flex;
    gap: 8px;
}

.admin-table .btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-small);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-table .btn-action.view { background: #e3f2fd; color: #1565c0; }
.admin-table .btn-action.view:hover { background: #bbdefb; }

.admin-table .btn-action.approve { background: #e8f5e9; color: #2e7d32; }
.admin-table .btn-action.approve:hover { background: #c8e6c9; }

.admin-table .btn-action.reject { background: #ffebee; color: #c62828; }
.admin-table .btn-action.reject:hover { background: #ffcdd2; }

/* Badges acces apps */
.app-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.app-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #e8f5e9;
    color: #2e7d32;
}

.app-badge.all {
    background: #e3f2fd;
    color: #1565c0;
}

/* Filters */
.admin-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-filters select,
.admin-filters input {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: var(--radius-small);
    font-size: 0.9rem;
}

.admin-filters select:focus,
.admin-filters input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Modal admin */
.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.admin-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.admin-modal {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.admin-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-modal-header h3 {
    margin: 0;
}

.admin-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.admin-modal-body {
    padding: 20px;
}

.admin-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Checkboxes acces apps */
.app-access-list {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.app-access-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: var(--radius-small);
    margin-bottom: 8px;
    transition: background 0.2s;
}

.app-access-list li:hover {
    background: #f8f9fa;
}

.app-access-list li label {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
}

.app-access-list li .app-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: normal;
}

.app-access-list input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    z-index: 2000;
    animation: toastIn 0.3s, toastOut 0.3s 2.7s;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ============================================
   CONDITIONS D'UTILISATION
   ============================================ */

.conditions-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
}

.conditions-header {
    text-align: center;
    margin-bottom: 40px;
}

.conditions-header h1 {
    color: var(--text);
    font-size: 2rem;
    margin-bottom: 10px;
}

.conditions-header p {
    color: #666;
}

.conditions-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px var(--shadow);
}

.conditions-section h2 {
    color: var(--text);
    font-size: 1.3rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

.conditions-section p {
    color: #444;
    line-height: 1.7;
    margin-bottom: 15px;
}

.conditions-section ul {
    color: #444;
    line-height: 1.7;
    margin-left: 20px;
    margin-bottom: 15px;
}

.conditions-section li {
    margin-bottom: 8px;
}

.highlight-box {
    background: #e3f2fd;
    padding: 15px 20px;
    border-radius: var(--radius-small);
    border-left: 4px solid #1976d2;
    margin: 20px 0;
}

.highlight-box p {
    margin: 0;
    color: #0d47a1;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 820px) {
    .accueil h1 {
        font-size: 1.8rem;
    }

    .choix-espace {
        grid-template-columns: 1fr;
        padding: 0 20px;
    }

    .carte {
        width: 100%;
        height: auto;
        min-height: 150px;
        padding: 25px 20px;
    }

    .login-box {
        padding: 25px;
        margin: 10px;
    }

    .portail-header {
        padding: 10px 15px;
    }

    .portail-header .logo {
        font-size: 1rem;
    }
}

@media (max-width: 1024px) {
    .admin-sidebar {
        width: 200px;
    }

    .admin-main {
        margin-left: 200px;
    }
}

@media (max-width: 768px) {
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .admin-main {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-table-container {
        overflow-x: auto;
    }
}
