/* ============================================================
   main.css — Styles globaux TCF Canada Expression Écrite
   Variables CSS, reset, layout, composants partagés
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --primary:       #2563EB;
    --primary-dark:  #1D4ED8;
    --secondary:     #64748B;
    --success:       #16A34A;
    --danger:        #DC2626;
    --warning:       #D97706;
    --purple:        #7C3AED;
    --info:          #0891B2;
    --bg:            #F1F5F9;
    --surface:       #FFFFFF;
    --border:        #E2E8F0;
    --text:          #1E293B;
    --text-muted:    #64748B;
    --sidebar-w:     260px;
    --sidebar-icon:  64px;
    --timer-h:       52px;
    --radius:        10px;
    --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:     0 4px 24px rgba(0,0,0,.12);
    --transition:    .2s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 1.4em; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--text);
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform var(--transition), width var(--transition);
    overflow: hidden;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 1.1rem;
    font-weight: 700;
    color: #FFF;
    flex-shrink: 0;
}
.sidebar-header .fa-graduation-cap,
.sidebar-header .fa-shield-halved { font-size: 1.4rem; color: var(--primary); }
.sidebar-close { display: none; background: none; border: none; color: #CBD5E1; cursor: pointer; margin-left: auto; font-size: 1.2rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.25rem;
    color: #94A3B8;
    font-size: .92rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}
.nav-item:hover { color: #FFF; background: rgba(255,255,255,.06); text-decoration: none; }
.nav-item.active { color: #FFF; border-left-color: var(--primary); background: rgba(37,99,235,.18); }
.nav-item .fa-solid { font-size: 1rem; width: 20px; text-align: center; }
.nav-item-logout { margin-top: auto; color: #F87171; }
.nav-item-logout:hover { color: #FFF; background: rgba(220,38,38,.2); }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .85rem;
    color: #94A3B8;
    flex-shrink: 0;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}
.top-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-bar h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); flex: 1; }
.top-bar-user { font-size: .85rem; color: var(--text-muted); display: flex; align-items: center; gap: .4rem; }
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem .5rem;
}
.content-body { padding: 1.5rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--primary);   color: #FFF; }
.btn-secondary { background: var(--border);    color: var(--text); }
.btn-danger    { background: var(--danger);    color: #FFF; }
.btn-success   { background: var(--success);   color: #FFF; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-purple    { background: var(--purple);    color: #FFF; }
.btn-full      { width: 100%; justify-content: center; }
.btn-sm        { padding: .35rem .75rem; font-size: .82rem; }
.btn-lg        { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-icon      { padding: .4rem .6rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field-error { font-size: .8rem; color: var(--danger); margin-top: .25rem; display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }
.input-icon-right { position: relative; }
.input-icon-right input { padding-right: 2.8rem; }
.toggle-password { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .88rem; }
.data-table thead th {
    background: var(--text);
    color: #CBD5E1;
    font-weight: 600;
    padding: .75rem 1rem;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.data-table thead th:hover { color: #FFF; }
.data-table tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table.striped tbody tr:nth-child(even) { background: #F8FAFC; }
.data-table tbody tr:hover { background: #EFF6FF; }
.actions-cell { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-pending { background: #F1F5F9; color: #64748B; }
.badge-sujet   { background: #EFF6FF; color: #1D4ED8; }

/* ── Cards ──────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    position: relative;
}
.modal-box.modal-lg  { max-width: 780px; }
.modal-box.modal-sm  { max-width: 380px; }
.modal-close {
    position: absolute;
    top: .9rem; right: .9rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-header { margin-bottom: 1rem; display: flex; align-items: center; gap: .6rem; }
.modal-header h3 { font-size: 1.1rem; }
.modal-body { margin-bottom: 1rem; line-height: 1.7; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; padding-top: .75rem; border-top: 1px solid var(--border); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal-slide-up { animation: slideUp .25s ease; }

/* ── Loader / Spinner ───────────────────────────────────────── */
.loader-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1rem; gap: .75rem; color: var(--text-muted); }
.spinner {
    width: 38px; height: 38px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .88rem;
    font-weight: 500;
    min-width: 240px;
    max-width: 380px;
    animation: toastIn .3s ease;
}
.toast-success { background: #DCFCE7; color: #15803D; border-left: 4px solid #16A34A; }
.toast-error   { background: #FEE2E2; color: #B91C1C; border-left: 4px solid #DC2626; }
.toast-info    { background: #DBEAFE; color: #1D4ED8; border-left: 4px solid #2563EB; }
@keyframes toastIn { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: none; } }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; padding: 4rem 1rem; color: var(--text-muted); font-size: .95rem; }
.empty-state .fa-solid { font-size: 3rem; color: var(--border); }

/* ── Filters ────────────────────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; background: var(--surface); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.filter-group { display: flex; flex-direction: column; gap: .25rem; }
.filter-group label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.filter-group input,
.filter-group select { padding: .5rem .75rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: .88rem; color: var(--text); }

/* ── Search bar ─────────────────────────────────────────────── */
.search-bar-wrap { margin-bottom: 1rem; }
.search-input { width: 100%; max-width: 380px; padding: .55rem 1rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .9rem; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1.25rem; }
.page-btn { padding: .45rem .85rem; border-radius: 8px; border: 1.5px solid var(--border); color: var(--text); font-weight: 600; font-size: .85rem; cursor: pointer; transition: all var(--transition); }
.page-btn:hover { background: var(--primary); color: #FFF; border-color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #FFF; border-color: var(--primary); }

/* ── HTML content display ───────────────────────────────────── */
.html-content { white-space: pre-wrap; line-height: 1.8; font-size: .92rem; }

/* ── Misc ───────────────────────────────────────────────────── */
.records-count { font-size: .88rem; color: var(--text-muted); }
.section-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.ua-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Inline form card ───────────────────────────────────────── */
.form-inline-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; border-left: 4px solid var(--primary); }
.form-inline-card h3 { margin-bottom: 1rem; font-size: 1rem; color: var(--primary); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { width: var(--sidebar-icon); }
    .sidebar .sidebar-title,
    .sidebar .nav-item span,
    .sidebar-user span { display: none; }
    .nav-item { justify-content: center; padding: .75rem; border-left: none; border-bottom: 3px solid transparent; }
    .nav-item.active { border-bottom-color: var(--primary); border-left: none; }
    .main-content { margin-left: var(--sidebar-icon); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
    .sidebar .sidebar-title,
    .sidebar .nav-item span,
    .sidebar-user span { display: inline; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-close { display: block; }
    .nav-item { justify-content: flex-start; padding: .75rem 1.25rem; }
    .main-content { margin-left: 0; }
    .hamburger { display: flex; }
    .form-row { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .modal-footer { flex-direction: column; }
}
