/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #103273;
    --primary-lt: #1a4a9e;
    --accent:     #db6a02;
    --success:    #16a34a;
    --warning:    #d97706;
    --danger:     #dc2626;
    --neutral:    #6b7280;
    --bg:         #f3f4f8;
    --surface:    #ffffff;
    --border:     #e5e7eb;
    --text:       #111827;
    --text-soft:  #6b7280;
    --radius:     8px;
    --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,.1);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--primary); color: #fff;
    padding: .75rem 1.5rem; position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-md);
}
.navbar-brand { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.brand-icon { font-size: 1.3rem; }
.navbar-menu { display: flex; gap: .25rem; flex: 1; }
.nav-link { color: rgba(255,255,255,.75); padding: .4rem .8rem; border-radius: var(--radius); font-size: .9rem; transition: all .15s; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.15); text-decoration: none; }
.navbar-user { display: flex; align-items: center; gap: .75rem; }
.username { color: rgba(255,255,255,.9); font-size: .9rem; }
.btn-logout { background: rgba(255,255,255,.15); color: #fff; padding: .35rem .8rem; border-radius: var(--radius); font-size: .85rem; border: 1px solid rgba(255,255,255,.2); }
.btn-logout:hover { background: rgba(255,255,255,.25); text-decoration: none; }

    .dropdown { position: relative; }
    .dropdown-toggle { cursor: pointer; display: flex; align-items: center; gap: .3rem; user-select: none; }
    .dropdown-toggle::after { content: '▾'; font-size: .7rem; opacity: .7; }
    .dropdown-menu {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        background: #fff;
        border: 1px solid #e2e4e7;
        border-radius: 6px;
        box-shadow: 0 4px 16px rgba(0,0,0,.12);
        min-width: 230px;
        z-index: 1000;
        padding: .3rem 0;
    }
    .dropdown-menu.open { display: block; }
    .dropdown-menu a {
        display: block;
        padding: .5rem 1rem;
        color: #1d2327;
        text-decoration: none;
        font-size: .875rem;
        white-space: nowrap;
    }
    .dropdown-menu a:hover { background: #f0f0f1; }
    .dropdown-menu a.active { background: #e8f0fe; color: var(--primary, #07294d); font-weight: 600; }
    .dropdown-menu .menu-divider { height: 1px; background: #e2e4e7; margin: .3rem 0; }


/* ── User badges ──────────────────────────────────────────── */
.user-badge { padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.user-badge.admin   { background: #fef3c7; color: #92400e; }
.user-badge.manager { background: #dbeafe; color: #1e40af; }
.user-badge.viewer  { background: #f3f4f6; color: #374151; }

/* ── Main ─────────────────────────────────────────────────── */
.main-content { max-width: 1680px; margin: 0 auto; padding: 1.5rem; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Page header ──────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.page-subtitle { color: var(--text-soft); margin-top: .2rem; font-size: .9rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back-link { font-size: .85rem; color: var(--text-soft); display: block; margin-bottom: .3rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; border: none; cursor: pointer; transition: all .15s; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(.92); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-secondary{ background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost    { background: transparent; color: var(--text-soft); border: 1px solid var(--border); }
.btn-danger   { background: #fee2e2; color: var(--danger); }
.btn-sm       { padding: .3rem .65rem; font-size: .8rem; }
.btn-block    { width: 100%; justify-content: center; }

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.stat-card.stat-success { border-color: var(--success); }
.stat-card.stat-warning { border-color: var(--warning); }
.stat-card.stat-neutral { border-color: var(--neutral); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: .85rem; color: var(--text-soft); margin-top: .4rem; }

/* ── Progress bar stacked ─────────────────────────────────── */
.progress-overview { background: var(--surface); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.progress-overview h3 { font-size: 1rem; margin-bottom: 1rem; color: var(--text); }
.progress-bar-stacked { display: flex; height: 20px; border-radius: 10px; overflow: hidden; background: var(--border); }
.bar-segment { transition: width .3s; }
.bar-success { background: var(--success); }
.bar-warning { background: var(--warning); }
.bar-neutral { background: #d1d5db; }
.progress-legend { margin-top: .75rem; display: flex; gap: 1.5rem; font-size: .82rem; color: var(--text-soft); flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; }
.legend-dot.success { background: var(--success); }
.legend-dot.warning { background: var(--warning); }
.legend-dot.neutral { background: #d1d5db; }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; background: var(--surface); padding: .75rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.filter-bar select, .filter-bar input[type=search] { padding: .4rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; color: var(--text); background: var(--bg); min-width: 160px; }
.filter-bar select:focus, .filter-bar input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.company-badge { background: #dbeafe; color: var(--primary); padding: .3rem .7rem; border-radius: 20px; font-size: .85rem; font-weight: 600; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrapper { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { background: #f9fafb; color: var(--text-soft); font-weight: 600; text-transform: uppercase; font-size: .75rem; letter-spacing: .05em; padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.student-name { font-weight: 600; color: var(--text); }
.student-email { font-size: .8rem; color: var(--text-soft); margin-top: .1rem; }
.course-name { max-width: 280px; }
.text-muted { color: var(--text-soft); }
.cert-number { font-family: monospace; font-size: .8rem; background: #f3f4f6; padding: .2rem .4rem; border-radius: 4px; }

/* ── Mini progress ────────────────────────────────────────── */
.mini-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; width: 80px; margin-bottom: 2px; }
.mini-bar { height: 100%; background: var(--primary); border-radius: 3px; }
.pct-label { font-size: .78rem; color: var(--text-soft); }

/* ── Badges ───────────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-neutral { background: #f3f4f6; color: var(--neutral); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.page-link { padding: .4rem .75rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .875rem; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link:hover:not(.active) { background: var(--bg); text-decoration: none; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-soft); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── Cards & forms ────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--primary); }
.two-col { display: grid; grid-template-columns: 380px 1fr; gap: 1.5rem; align-items: start; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .875rem; }
.form-group input, .form-group select { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; color: var(--text); background: var(--bg); }
.form-group input:focus, .form-group select:focus { outline: 2px solid var(--primary); border-color: transparent; background: #fff; }
.hint { font-size: .78rem; color: var(--text-soft); margin-top: .3rem; display: block; }
.info-list { display: grid; grid-template-columns: 130px 1fr; gap: .5rem 1rem; font-size: .875rem; }
.info-list dt { font-weight: 600; color: var(--text-soft); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 700; color: var(--primary); margin-bottom: 1rem; }
.quick-links { margin-top: 1rem; }

/* ── Lignes de devis (blocs sans scroll horizontal) ─────────── */
.lignes-container { }
.ligne-row { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.ligne-row:last-child { border-bottom: none; }
.ligne-row:hover { background: #f9fafb; }
.ligne-top { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: .75rem; }
.ligne-bottom { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.ligne-field { display: flex; flex-direction: column; gap: .3rem; }
.ligne-field label { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); font-weight: 600; }
.ligne-field input, .ligne-field select { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; color: var(--text); background: var(--bg); }
.ligne-field input:focus, .ligne-field select:focus { outline: 2px solid var(--primary); border-color: transparent; background: #fff; }
.field-formation { flex: 2 1 240px; min-width: 200px; }
.field-formation select { width: 100%; }
.field-stagiaire { flex: 1 1 170px; min-width: 150px; }
.field-stagiaire select { width: 100%; }
.field-jours, .field-heures { width: 64px; }
.field-jours input, .field-heures input { width: 100%; text-align: center; }
.field-debut { width: 140px; }
.field-debut input { width: 100%; }
.field-fin { width: 235px; }
.ligne-fin-group { display: flex; gap: .3rem; }
.ligne-fin-group select { width: 100px; }
.ligne-fin-group input { flex: 1; min-width: 0; }
.field-prix-public { width: 110px; }
.field-prix-public .input-prix-public { padding: .5rem 0; font-size: .85rem; text-align: right; }
.field-prix-applique { width: 135px; }
.field-prix-applique input { width: 100%; text-align: right; }
.field-prix-applique .info-remise { color: #16a34a; font-size: .72rem; line-height: 1.2; }
.ligne-top .btn-suppr-ligne { margin-left: auto; }

/* ── Login ────────────────────────────────────────────────── */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--primary) 0%, #1a4a9e 100%); }
.login-container { background: var(--surface); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { font-size: 3rem; margin-bottom: .75rem; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.login-header p { color: var(--text-soft); font-size: .9rem; margin-top: .3rem; }
.login-form .btn-primary { margin-top: .5rem; font-size: 1rem; padding: .75rem; }

/* ── Footer ───────────────────────────────────────────────── */
.footer { text-align: center; padding: 1rem; color: var(--text-soft); font-size: .8rem; border-top: 1px solid var(--border); margin-top: 2rem; display: flex; justify-content: space-between; max-width: 1280px; margin: 2rem auto 0; padding: 1rem 1.5rem; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar { flex-wrap: wrap; gap: .5rem; }
    .navbar-menu { order: 3; width: 100%; }
    .two-col { grid-template-columns: 1fr; }
    .data-table { font-size: .8rem; }
    .data-table th, .data-table td { padding: .5rem .6rem; }
    .course-name { max-width: 160px; }
}

/* ── Hint text ────────────────────────────────────────────── */
.hint-text { font-size: .85rem; color: var(--text-soft); margin-top: .5rem; }
.hint-text code { background: #f3f4f6; padding: .1rem .4rem; border-radius: 4px; font-size: .82rem; }

/* ── Input avec bouton œil ────────────────────────────────── */
.input-eye { position: relative; display: flex; }
.input-eye input { flex: 1; padding-right: 2.5rem; }
.eye-btn { position: absolute; right: 0; top: 0; height: 100%; padding: 0 .6rem; background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-soft); }
.eye-btn:hover { color: var(--text); }

/* ── Actions btns ─────────────────────────────────────────── */
.action-btns { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Modale ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-soft); padding: .2rem .4rem; border-radius: var(--radius); }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 1.5rem; }
.modal-subtitle { font-size: .9rem; color: var(--text-soft); margin-bottom: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: #f9fafb; }

/* ── Company tags ─────────────────────────────────────────── */
.company-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.company-tag { background: #dbeafe; color: #1e40af; padding: .15rem .5rem; border-radius: 20px; font-size: .75rem; font-weight: 500; }

/* ── Checkboxes sociétés ──────────────────────────────────── */
.companies-checkboxes { display: flex; flex-direction: column; gap: .4rem; max-height: 200px; overflow-y: auto; padding: .5rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; padding: .2rem .4rem; border-radius: 4px; }
.checkbox-label:hover { background: #e0e7ff; }
.checkbox-label input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* ── Modale large ─────────────────────────────────────────── */
.modal-lg { max-width: 560px; }
.modal-lg .companies-checkboxes { max-height: 300px; }

/* ── Tag input autocomplete ───────────────────────────────── */
.tag-input-wrapper { position: relative; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); padding: .4rem; min-height: 40px; cursor: text; }
.tag-list { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.tag-item { display: inline-flex; align-items: center; gap: .3rem; background: #dbeafe; color: #1e40af; padding: .2rem .5rem; border-radius: 20px; font-size: .8rem; font-weight: 500; }
.tag-remove { background: none; border: none; cursor: pointer; color: #1e40af; font-size: .75rem; padding: 0; line-height: 1; }
.tag-remove:hover { color: var(--danger); }
.tag-search { border: none; outline: none; background: transparent; font-size: .875rem; width: 100%; padding: .2rem .3rem; }
.tag-dropdown { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 50; max-height: 200px; overflow-y: auto; display: none; }
.tag-option { padding: .5rem .75rem; cursor: pointer; font-size: .875rem; }
.tag-option:hover { background: #eff6ff; color: var(--primary); }

.data-table th a {
    text-decoration: none;
    color: inherit;
    font-weight: 600;
}

.data-table th a:hover {
    color: #2563eb;
}

.data-table th a {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

/* ── LIGHTBOX IMAGE (CLEAN VERSION) ───────────────────────────────────────────── */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    object-fit: contain;
}

/* bouton fermer */
.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 26px;
    line-height: 42px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: 0.2s;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ── Badge info ───────────────────────────────────────────── */
.badge-info { background: #dbeafe; color: #1e40af; }

/* ── Cloche notifications ─────────────────────────────────── */
.notif-bell {
    position: relative;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    padding: .25rem .4rem;
    border-radius: 6px;
    color: rgba(255,255,255,.85);
    display: flex;
    align-items: center;
    transition: background .15s;
}
.notif-bell:hover { background: rgba(255,255,255,.15); }
.notif-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: #dc2626;
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: .65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 0 3px;
    pointer-events: none;
}
.notif-dropdown {
    right: 0;
    left: auto;
    min-width: 270px;
}
.notif-dropdown-header {
    padding: .5rem 1rem .3rem;
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.notif-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 1rem;
    color: #1d2327;
    text-decoration: none;
    font-size: .875rem;
    white-space: nowrap;
}
.notif-row:hover { background: #f0f0f1; text-decoration: none; }
.notif-count-pill {
    border-radius: 9999px;
    padding: .1rem .5rem;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}
.notif-count-pill.red    { background: #fee2e2; color: #dc2626; }
.notif-count-pill.yellow { background: #fef9c3; color: #b45309; }
.notif-count-pill.purple { background: #ede9fe; color: #7c3aed; }
.notif-ok { color: #16a34a; font-size: .8rem; }
.notif-all-ok {
    padding: .5rem 1rem;
    font-size: .85rem;
    color: #16a34a;
    text-align: center;
}