/* ═══════════════════════════════════════════════════════
   Dashboard Acces — Styles de base
   ═══════════════════════════════════════════════════════ */

:root {
    --color-primary: #1a3a5c;
    --color-primary-lt: #2563eb;
    --color-accent: #3b82f6;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.12);
    --font-main: 'Segoe UI', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg);
}

span[data-valmsg-for] {
    display: none;
}

    span[data-valmsg-for].field-validation-error {
        display: block;
    }

/* ── Layout ─────────────────────────────────────────── */

.layout-root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 0 32px;
    height: 60px;
    background: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.header-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 24px;
}

.app-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    background: white;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
}

.app-title {
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .3px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

    .header-nav a {
        color: rgba(255,255,255,.85);
        text-decoration: none;
        font-size: 14px;
        transition: color .15s;
    }

        .header-nav a:hover {
            color: #fff;
        }

/* ── Dropdown utilisateur ────────────────────────────── */

.user-dropdown {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    /*border: 1px solid rgba(255,255,255,.3);*/
    /*border-radius: var(--radius-sm);*/
    color: rgba(255,255,255,.9);
    font-size: 14px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

    .user-dropdown-trigger:hover {
        /*background: rgba(255,255,255,.1);*/
        /*border-color: rgba(255,255,255,.6);*/
    }

.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 210px;
    background: transparent;
    z-index: 100;
}

    /* Pont invisible entre le trigger et le menu — empêche le hover de se couper */
    .user-dropdown-menu::before {
        content: '';
        display: block;
        height: 8px;
    }

.user-dropdown-menu-inner {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* Ouverture au survol du conteneur ou focus dans le menu */
.user-dropdown:hover .user-dropdown-menu,
.user-dropdown:focus-within .user-dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--color-text) !important;
    text-decoration: none;
    transition: background .12s;
}

    .dropdown-item:hover {
        background: var(--color-bg);
    }

.dropdown-item-danger {
    color: var(--color-danger) !important;
}

    .dropdown-item-danger:hover {
        background: #fef2f2;
    }

.dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 2px 0;
}

.mt-12 {
    margin-top: 12px;
}

.app-main {
    flex: 1;
    padding: 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ── Auth pages ─────────────────────────────────────── */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a3a5c 0%, #2563eb 100%);
    padding: 24px;
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-logo {
    text-align: center;
    margin-bottom: 16px;
}

    .auth-logo img {
        height: 56px;
    }

.auth-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0 0 4px;
}

.auth-subtitle {
    text-align: center;
    font-size: 15px;
    font-weight: 400;
    color: var(--color-text-muted);
    margin: 0 0 28px;
}

.auth-hint {
    color: var(--color-text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.auth-links {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
}

    .auth-links a {
        color: var(--color-primary-lt);
        text-decoration: none;
    }

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

/* ── Forms ──────────────────────────────────────────── */

.auth-form, .form-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group-check {
    justify-content: flex-end;
}

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

.form-group .help {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 12px;
}

.form-input {
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--color-text);
    outline: none;
    transition: border-color .15s;
    background: var(--color-surface);
}

    .form-input:focus {
        border-color: var(--color-accent);
    }

.required {
    color: var(--color-danger);
}

/* ── Buttons ────────────────────────────────────────── */

.btn-primary, .btn-secondary, .btn-danger, .btn-success, .btn-excell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: filter .15s, opacity .15s;
}

.btn-primary {
    background: var(--color-primary-lt);
    color: #fff;
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

/* Couleurs officielles Excel : vert #217346 sur fond blanc, icône verte */
.btn-excell {
    background: #217346;
    color: #fff;
    border: 1px solid #1a5c38;
    font-size: 21px;
    padding: 6px 20px;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary:hover {
    filter: brightness(.95);
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-excell:hover {
    filter: brightness(1.12);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-success:disabled,
.btn-excell:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
    margin-top: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-migration {
    padding: 12px 28px;
    font-size: 15px;
}

/* ── Alerts ─────────────────────────────────────────── */

.auth-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}

/* Erreurs de validation Razor Pages — inline sous les champs */
.form-error {
    color: #b91c1c;
    font-size: 12px;
    margin-top: 2px;
}

/* Spans asp-validation-for vides — cachés par défaut */
span[data-valmsg-for] {
    display: none;
}

    span[data-valmsg-for].field-validation-error {
        display: block;
    }

.auth-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}

/* ── Tables ─────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

    .data-table th {
        background: var(--color-primary);
        color: #fff;
        text-align: left;
        padding: 6px 12px;
        font-size: 13px;
        font-weight: 600;
    }

    .data-table td {
        padding: 5px 12px;
        border-bottom: 1px solid var(--color-border);
        font-size: 13px;
        vertical-align: middle;
        white-space: nowrap;
    }

    .data-table tr:last-child td {
        border-bottom: none;
    }

    .data-table tr:hover td {
        background: #dbeafe !important;
    }

    .data-table tbody tr:nth-child(even) td {
        background: #f4f7fa;
    }

.empty-row {
    text-align: center;
    color: var(--color-text-muted);
}

/*.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}*/

/* ── Badges ─────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}

.badge-role {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ── Admin pages ────────────────────────────────────── */

.admin-page {
    padding: 0;
}

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

    .page-header h1 {
        margin: 0;
        font-size: 24px;
        color: var(--color-primary);
    }

/* ── Modals ─────────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-sm {
    max-width: 400px;
}

.modal h2 {
    margin: 0 0 24px;
    color: var(--color-primary);
}

.modal h3 {
    margin: 20px 0 10px;
    font-size: 14px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.warning-text {
    color: var(--color-warning);
    font-size: 13px;
}

/* ── Checkboxes group ───────────────────────────────── */

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

    .checkbox-group label {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        cursor: pointer;
    }

/* ── Migration page ─────────────────────────────────── */

.migration-page {
    max-width: 700px;
    margin: 60px auto;
    padding: 40px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

    .migration-page h1 {
        color: var(--color-primary);
        margin-top: 0;
    }

.migration-status {
    padding: 16px;
    border-radius: var(--radius-sm);
    margin: 20px 0;
}

    .migration-status.running {
        background: #fffbeb;
        border: 1px solid #fde68a;
        color: #92400e;
    }

    .migration-status.success {
        background: #f0fdf4;
        border: 1px solid #86efac;
        color: #166534;
    }

    .migration-status.error {
        background: #fef2f2;
        border: 1px solid #fca5a5;
        color: #991b1b;
    }

.migration-error {
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 8px;
}

.migration-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

    .migration-list li {
        padding: 6px 0;
        border-bottom: 1px solid var(--color-border);
        font-size: 13px;
        font-family: 'Cascadia Code', 'Consolas', monospace;
        color: var(--color-text-muted);
    }

/* ── Journal de migration ────────────────────────────────── */

.migration-log {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
}

    .migration-log li {
        display: flex;
        gap: 12px;
        padding: 5px 12px;
        border-bottom: 1px solid var(--color-border);
    }

        .migration-log li:last-child {
            border-bottom: none;
        }

.log-time {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.log-info {
    background: #f8fafc;
}

.log-success {
    background: #f0fdf4;
    color: #166534;
}

.log-error {
    background: #fef2f2;
    color: #991b1b;
}

/* ── Impersonate ─────────────────────────────────────── */

.impersonate-trigger {
    /*border-color: rgba(220, 38, 38, .6) !important;
    background: rgba(220, 38, 38, .15) !important;*/
}

    .impersonate-trigger:hover {
        /*background: rgba(220, 38, 38, .25) !important;
        border-color: rgba(220, 38, 38, .9) !important;*/
    }

.impersonate-name {
    color: #fca5a5 !important;
    font-weight: 700;
}

.dropdown-impersonate-info {
    padding: 10px 16px;
    font-size: 12px;
    color: var(--color-text-muted);
    background: #fef2f2;
    border-bottom: 1px solid var(--color-border);
}

.dropdown-item-warning {
    color: var(--color-warning) !important;
    font-weight: 600;
}

    .dropdown-item-warning:hover {
        background: #fffbeb;
    }

.btn-impersonate {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: #dbeafe;
    color: #1d4ed8;
    transition: filter .15s;
}

    .btn-impersonate:hover {
        filter: brightness(.92);
    }

/* ── Footer ──────────────────────────────────────────── */

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 32px;
    font-size: 10px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    letter-spacing: .15px;
    opacity: .7;
}

.footer-sep {
    opacity: .35;
}

/* ── Drop zone ───────────────────────────────────────── */

.drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 64px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    padding: 12px;
    cursor: default;
    transition: border-color .15s, background .15s;
    position: relative;
    text-align: center;
}

.drop-zone-active {
    border-color: var(--color-accent);
    background: #eff6ff;
}

.drop-zone-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.5;
}

    .drop-zone-hint small {
        font-size: 11px;
    }

.drop-zone-filename {
    font-size: 13px;
    color: var(--color-text);
    font-weight: 500;
}

.drop-zone-clear {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
}

    .drop-zone-clear:hover {
        color: var(--color-danger);
    }

.mt-4 {
    margin-top: 4px;
}

/* ── Fichier modèle ──────────────────────────────────── */

.fichier-nom {
    display: block;
    font-size: 13px;
    font-weight: 500;
}

.fichier-date {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 1px;
}

.fichier-absent {
    font-size: 11px;
    color: var(--color-warning);
}

.fichier-actuel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 13px;
}

    .fichier-actuel .fichier-date {
        display: inline;
        margin: 0;
    }

/* Drop zone avec InputFile caché derrière */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    padding: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    position: relative;
    text-align: center;
}

    .drop-zone:hover,
    .drop-zone-active {
        border-color: var(--color-accent);
        background: #eff6ff;
    }

.drop-zone-loading {
    opacity: .6;
    cursor: wait;
}

/* InputFile invisible — couvre toute la zone pour le clic et le drop */
.drop-zone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.drop-zone-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.6;
    pointer-events: none;
}

    .drop-zone-hint small {
        font-size: 11px;
    }

.form-group-wide {
    grid-column: 1 / -1;
}

.text-muted {
    color: var(--color-text-muted);
}

/* ── Recherche ───────────────────────────────────────── */

.recherche-filtres {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.filtre-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    flex-shrink: 0;
}

.filtre-recherche {
    flex: 1;
    min-width: 0;
}

    .filtre-recherche .form-input {
        width: 100%;
    }

.filtre-date {
    width: 140px;
    flex-shrink: 0;
}

.form-group-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.recherche-statut {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.recherche-loading,
.recherche-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px;
    font-size: 15px;
}

/* Colonnes triables */
.col-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

    .col-sortable:hover {
        background: #2a5a8c;
    }

.tri-icone {
    margin-left: 5px;
    font-size: 10px;
}

.tri-inactif {
    opacity: .3;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination-taille {
    margin-left: 12px;
    width: 72px;
    padding: 5px 8px;
    font-size: 13px;
}

.recherche-charger-plus {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

/* ── Header layout (grid 3 colonnes) ────────────────── */

.header-nav-center {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: flex-start;
}

    .header-nav-center a {
        color: rgba(255,255,255,.85);
        text-decoration: none;
        font-size: 14px;
        transition: color .15s;
    }

        .header-nav-center a:hover {
            color: #fff;
        }

/* ── Badge type modèle ───────────────────────────────── */

.badge-type {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    background: #dbeafe;
    color: #1d4ed8;
}
