/* ==========================================================================
   LES VOIX CLAIRES 92 — CLEAN DESIGN SYSTEM & FIXES
   ========================================================================== */

:root {
    --primary: #1e3a8a;
    --primary-dark: #0f172a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--accent);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    z-index: 1000;
    transition: top 0.2s ease;
}
.skip-link:focus { top: 16px; }

/* --------------------------------------------------------------------------
   HEADER BLEU PROFOND
   -------------------------------------------------------------------------- */
.main-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important;
    border-bottom: 3px solid #f59e0b;
    padding: 12px 24px;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-wordmark {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.75rem;
    font-weight: 800;
    color: #1e3a8a;
    background: #f59e0b;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mobile-toggle-btn {
    display: none;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-menu a {
    color: #e2e8f0 !important;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.nav-menu a:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.12) !important;
}

.nav-menu a.active {
    color: #ffffff !important;
    background: var(--accent) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-menu a.admin-link {
    color: #fcd34d !important;
}

.nav-menu a.admin-link:hover {
    background: rgba(252, 211, 77, 0.15) !important;
}

.nav-menu a.admin-link.active {
    color: #ffffff !important;
    background: #d97706 !important;
}

.mobile-user-block {
    display: none !important;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #93c5fd;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

/* --------------------------------------------------------------------------
   STRUCTURE DE PAGE ET REFRESH GENERAL
   -------------------------------------------------------------------------- */
.app-container {
    flex: 1;
    width: 100%;
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    text-align: left !important;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    text-align: left !important;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-align: left !important;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 1px 2px 0 rgb(37 99 235 / 0.2);
    transition: background 0.15s ease;
    display: inline-block;
    border: none;
    cursor: pointer;
}

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

/* --------------------------------------------------------------------------
   CORRECTIF ADMIN : GRILLE DE CARTES EN HAUT
   -------------------------------------------------------------------------- */
.grid-stats,
.stats-grid,
.dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 16px !important;
    margin-bottom: 28px !important;
    width: 100% !important;
    text-align: left !important;
}

.stat-card,
.card {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 20px 16px !important;
    box-shadow: var(--shadow-sm) !important;
    text-align: center !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
}

.stat-card .num,
.stat-number {
    font-size: 2.2rem !important;
    font-weight: 800 !important;
    color: var(--primary) !important;
    line-height: 1 !important;
    margin-bottom: 6px !important;
}

.stat-card .label,
.stat-label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    color: var(--muted) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

/* Blocs d'action Admin */
.admin-sections,
.admin-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)) !important;
    gap: 20px !important;
    margin-top: 24px !important;
    text-align: left !important;
}

.admin-block,
.admin-card {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 24px !important;
    box-shadow: var(--shadow-sm) !important;
    text-align: left !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.admin-block h3,
.admin-card h3 {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: var(--primary-dark) !important;
    margin-bottom: 8px !important;
    text-align: left !important;
}

.admin-block p,
.admin-card p {
    font-size: 0.88rem !important;
    color: var(--muted) !important;
    margin-bottom: 16px !important;
    text-align: left !important;
}

.action-buttons-list,
.admin-actions-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-top: 12px !important;
    justify-content: flex-start !important;
}

.action-buttons-list a,
.admin-actions-group a,
.btn-action-link,
.admin-block a,
.admin-card a {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
    display: inline-flex !important;
    align-items: center !important;
}

.action-buttons-list a:hover,
.admin-actions-group a:hover,
.btn-action-link:hover,
.admin-block a:hover,
.admin-card a:hover {
    background: var(--accent) !important;
    color: #ffffff !important;
    border-color: var(--accent) !important;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2) !important;
}

/* --------------------------------------------------------------------------
   CORRECTIF PROCEDURES : ALIGNEMENT A GAUCHE PROPRE
   -------------------------------------------------------------------------- */
.main-content h1,
.main-content h2,
.main-content h3,
.main-content p,
.main-content ul,
.main-content ol,
.main-content li,
.main-content div {
    text-align: left !important;
}

.procedure-card,
.protocol-card,
.main-content > div {
    text-align: left !important;
}

.main-content ul, 
.main-content ol {
    padding-left: 20px !important;
    margin: 16px 0 !important;
}

.main-content li {
    margin-bottom: 8px !important;
    line-height: 1.6 !important;
    color: var(--text) !important;
}

/* --------------------------------------------------------------------------
   TABLEAUX & BADGES
   -------------------------------------------------------------------------- */
.filter-bar {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
}

.filter-bar select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

.table-container {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-faible { background: #dcfce7; color: #15803d; }
.badge-moyen { background: #fef3c7; color: #b45309; }
.badge-eleve { background: #ffedd5; color: #c2410c; }
.badge-critique { background: #fee2e2; color: #b91c1c; }

.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: auto;
}

/* --------------------------------------------------------------------------
   FORMULAIRES & PAGES D'AUTHENTIFICATION (LOGIN / CREATE / FORGOT)
   -------------------------------------------------------------------------- */
.auth-wrapper {
    min-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 440px;
    padding: 32px;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 0.85rem;
    color: var(--muted);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    background: #ffffff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.danger-box {
    background: #fef2f2;
    border: 2px solid #fca5a5;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.danger-box input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--danger);
    cursor: pointer;
}

.danger-box label {
    font-weight: 700;
    color: #b91c1c;
    cursor: pointer;
    font-size: 0.9rem;
}

.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 6px;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tag-checkbox:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.tag-checkbox input {
    accent-color: var(--accent);
}

/* --------------------------------------------------------------------------
   DESIGN TCHAT INTERNE & ANIMATIONS
   -------------------------------------------------------------------------- */
.chat-discord-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 680px;
    overflow: hidden;
}

.chat-messages-scroll {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.chat-message-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeInMsg 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInMsg {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(30, 58, 138, 0.2);
}

.chat-message-item.me .msg-avatar {
    background: var(--accent);
}

.msg-body {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    max-width: 80%;
    transition: box-shadow 0.2s ease;
}

.msg-body:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-message-item.me .msg-body {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.msg-author {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.msg-date {
    font-size: 0.72rem;
    color: var(--muted);
}

.msg-text {
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.45;
    word-break: break-word;
}

.typing-indicator {
    padding: 8px 20px;
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}

.typing-indicator .dots span {
    animation: blinkDots 1.4s infinite fill-mode: both;
    font-weight: bold;
}
.typing-indicator .dots span:nth-child(2) { animation-delay: .2s; }
.typing-indicator .dots span:nth-child(3) { animation-delay: .4s; }

@keyframes blinkDots {
    0% { opacity: .2; transform: translateY(0); }
    20% { opacity: 1; transform: translateY(-2px); }
    100% { opacity: .2; transform: translateY(0); }
}

.chat-discord-form {
    background: #ffffff;
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}

.editor-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.editor-toolbar button {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #334155;
    transition: all 0.15s ease;
}

.editor-toolbar button:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    outline: none;
    resize: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-row textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-send-discord {
    background: var(--accent);
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-send-discord:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-send-discord:active,
.btn-send-discord.sending-anim {
    transform: scale(0.95);
    opacity: 0.9;
}

/* --------------------------------------------------------------------------
   VERSION MOBILE (ÉCRANS <= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .main-header {
        padding: 12px 16px;
    }

    .nav-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .brand-row {
        width: 100%;
        justify-content: space-between;
    }

    .mobile-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        cursor: pointer;
    }

    .hamburger-icon, 
    .hamburger-icon::before, 
    .hamburger-icon::after {
        content: '';
        display: block;
        width: 20px;
        height: 2px;
        background: #ffffff;
        border-radius: 2px;
        transition: all 0.2s ease;
        position: relative;
    }
    .hamburger-icon::before { top: -6px; position: absolute; }
    .hamburger-icon::after { top: 6px; position: absolute; }

    .mobile-toggle-btn.is-active .hamburger-icon { background: transparent; }
    .mobile-toggle-btn.is-active .hamburger-icon::before { transform: rotate(45deg); top: 0; }
    .mobile-toggle-btn.is-active .hamburger-icon::after { transform: rotate(-45deg); top: 0; }

    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        padding-top: 12px;
        margin-top: 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        gap: 6px;
    }

    .nav-menu.nav-open {
        display: flex;
    }

    .nav-menu a {
        padding: 12px 16px;
        font-size: 0.95rem;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.1);
        width: 100%;
    }

    .mobile-user-block {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        margin-top: 8px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 8px;
    }

    .mobile-user-block .user-name {
        color: #ffffff;
    }

    .main-content {
        padding: 16px 12px;
    }

    .content-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .btn-primary {
        width: 100%;
        text-align: center;
        padding: 12px;
        font-size: 0.95rem;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .table-container {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead {
        display: none;
    }

    tbody tr {
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 14px;
        box-shadow: var(--shadow-sm);
    }

    td {
        border-bottom: 1px dashed #f1f5f9;
        padding: 8px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    td:last-child {
        border-bottom: none;
        padding-top: 12px;
    }
}