/**
 * BKS Formations — style sobre et moderne
 */

:root {
    --max: 1100px;
    --pad: 24px;
    --blue: #1a73e8;
    --blue-hover: #1557b0;
    --green: #34a853;
    --red: #ea4335;
    --grey: #5f6368;
    --grey-bg: #f5f5f5;
    --grey-border: #e0e0e0;
    --text: #202124;
    --text-muted: #5f6368;
    --white: #fff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--grey-bg);
}

/* ——— Header ——— */
.main-header {
    background: var(--white);
    border-bottom: 1px solid var(--grey-border);
}

.header-container {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--pad);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 28px;
}

.logo-section {
    display: block;
    min-width: 140px;
    min-height: 36px;
}

.logo-img {
    height: 36px;
    width: auto;
    max-width: 180px;
    display: block;
    vertical-align: middle;
}

.header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
}

.nav-menu a {
    color: var(--text);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 4px;
    font-weight: 500;
}

.nav-menu a:hover,
.nav-menu a.nav-current {
    background: var(--grey-bg);
    color: var(--blue);
}

.nav-menu a i {
    margin-right: 6px;
}

.nav-menu .nav-link-disabled {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 4px;
    color: var(--grey);
    cursor: not-allowed;
    opacity: 0.7;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.header-btn-primary {
    background: var(--blue);
    color: var(--white);
}

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

.header-btn-secondary {
    background: var(--grey-bg);
    color: var(--text);
}

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

.user-menu-wrapper { position: relative; }

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--grey-border);
    border-radius: 4px;
    background: var(--white);
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.user-menu-toggle:hover {
    background: var(--grey-bg);
}

.user-arrow { font-size: 10px; color: var(--text-muted); }

.qr-session-timer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 6px;
    padding: 4px 8px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}
.qr-session-timer i { opacity: 0.9; }

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 4px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    display: none;
    z-index: 100;
}

.user-menu-dropdown.show { display: block; }

.user-menu-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--grey-bg);
}

.user-menu-dropdown .dropdown-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
}

.user-menu-dropdown .dropdown-icon svg {
    display: block;
}

.user-menu-dropdown .dropdown-icon-user,
.user-menu-dropdown .dropdown-icon-admin { color: var(--text); }

.user-menu-dropdown .dropdown-link-logout .dropdown-icon-logout,
.user-menu-dropdown .dropdown-link-logout:hover .dropdown-icon-logout { color: #c62828; }

.user-menu-dropdown .dropdown-link-logout:hover { color: var(--text); }

.user-menu-dropdown a:last-child { border-bottom: none; }

.user-menu-dropdown a:hover {
    background: var(--grey-bg);
}

.user-menu-dropdown a.admin-link { color: var(--blue); font-weight: 600; }

.btn-login {
    padding: 8px 18px;
    background: var(--blue);
    color: var(--white);
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
}

.btn-login:hover { background: var(--blue-hover); color: var(--white); }

/* ——— Main ——— */
.view-as-banner {
    background: #e3f2fd;
    color: #1565c0;
    padding: 10px var(--pad);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
}
.view-as-banner-link {
    color: #0d47a1;
    font-weight: 600;
    text-decoration: underline;
}
.view-as-banner-link:hover { color: #01579b; }

.main-content {
    max-width: var(--max);
    margin: 0 auto;
    padding: var(--pad);
    min-height: calc(100vh - 120px);
}

/* ——— Page title ——— */
.page-title-bar {
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.page-title-bar .inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title-wrap { display: flex; align-items: center; gap: 12px; }

.page-title-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--grey-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.page-title-wrap h1 { font-size: 18px; font-weight: 600; }

.page-title-wrap .subtitle {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* En-têtes uniformes (fiche client, formations, sessions, documents) : sous-titre au-dessus du titre */
.client-fiche-title-text { display: flex; flex-direction: column; }
.client-fiche-title-text .subtitle { margin-top: 0; margin-bottom: 2px; }
.client-fiche-title-text h1 { margin: 0; }

/* Icône d'en-tête sans fond, plus grande (fiche client, sessions, etc.) */
.client-fiche-title-icon { color: var(--text, #374151); }
.client-fiche-title-icon i { font-size: 32px; }

.page-title-actions {
    flex-shrink: 0;
}

.page-title-actions .btn i {
    margin-right: 6px;
}

.page-title-icon-doc {
    background: var(--color-green-light, #e8f5e9);
    color: var(--color-green, #2e7d32);
}

/* ——— Fiche client : mise en page ——— */
.client-fiche-page {
    max-width: 960px;
    margin: 0 auto;
}

.client-fiche-actions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 0;
    border-bottom: 2px solid var(--grey-border, #e2e8f0);
}

.client-fiche-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}

.client-fiche-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: var(--text-muted, #64748b);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    transition: color 0.2s, background 0.2s;
}

.client-fiche-tab:hover {
    color: var(--primary, #2563eb);
    background: rgba(37, 99, 235, 0.06);
}

.client-fiche-tab-primary {
    color: var(--primary, #2563eb);
    background: #fff;
    border-color: var(--grey-border, #e2e8f0);
    border-bottom-color: #fff;
}

.client-fiche-tab-primary:hover {
    color: var(--primary, #2563eb);
    background: #fff;
}

.client-fiche-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-fiche-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--grey-border, #e2e8f0);
    background: #fff;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.client-fiche-icon-btn:hover {
    background: var(--grey-bg, #f1f5f9);
    color: var(--text);
    border-color: #cbd5e1;
}

.client-fiche-actions-bar .btn { white-space: nowrap; }
.client-fiche-action-form { display: inline-block; margin: 0; }

/* Carte Informations du client : grille */
.client-fiche-page .card {
    border-radius: 12px;
    border: 1px solid var(--grey-border, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.client-fiche-page .card-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--grey-border, #e2e8f0);
}

.client-info-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0;
    margin: 0;
}

.client-info-row {
    display: contents;
}

.client-info-row .client-info-label,
.client-info-row .client-info-value {
    padding: 12px 16px;
    border-bottom: 1px solid var(--grey-border, #e2e8f0);
    font-size: 0.9rem;
}

.client-info-row .client-info-label {
    font-weight: 500;
    color: var(--text-muted, #64748b);
    background: #f8fafc;
}

.client-info-row .client-info-value {
    color: var(--text);
    background: #fff;
}

.client-info-grid .client-info-row:last-child .client-info-label,
.client-info-grid .client-info-row:last-child .client-info-value {
    border-bottom: none;
}

/* Lignes repliables : masquer les lignes 5+ par défaut */
.client-info-more {
    display: none;
}

.client-info-view-wrap.is-expanded .client-info-more {
    display: contents;
}

.client-info-toggle-wrap {
    text-align: center;
    padding: 16px;
    border-top: 1px solid var(--grey-border, #e2e8f0);
    background: #fafafa;
}

.client-info-btn-toggle {
    min-width: 140px;
}

/* Modales fiche client */
.client-fiche-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.client-fiche-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.client-fiche-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.client-fiche-modal-box-danger .client-fiche-modal-title { color: var(--red, #c5221f); }

.client-fiche-modal-title {
    margin: 0 0 8px;
    font-size: 1.1rem;
    font-weight: 600;
}

.client-fiche-modal-desc {
    margin: 0 0 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.client-fiche-modal-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.client-fiche-modal-input {
    width: 100%;
    margin-bottom: 16px;
    padding: 8px 12px;
    border: 1px solid var(--grey-border);
    border-radius: 6px;
}

.client-fiche-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ——— Summary blocks ——— */
.summary-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-block {
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    padding: 20px;
}

a.summary-block {
    text-decoration: none;
    color: inherit;
    display: block;
}

a.summary-block:hover {
    border-color: var(--blue);
}

.summary-block-blue { border-left: 4px solid var(--blue); }
.summary-block-green { border-left: 4px solid var(--green); }
.summary-block-white { }

.summary-block-content h3 { font-size: 26px; font-weight: 600; margin-bottom: 4px; }
.summary-block-content p { font-size: 13px; color: var(--text-muted); }

.summary-block-icon {
    margin-top: 8px;
    font-size: 18px;
    color: var(--text-muted);
}

/* ——— Cards ——— */
.card {
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--grey-border);
}

.card-header h2 { font-size: 16px; font-weight: 600; }

/* ——— Admin grid ——— */
.admin-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.admin-card {
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    padding: 20px;
}

.admin-card:hover { border-color: var(--blue); }

.admin-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--grey-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.admin-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.admin-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

/* ——— Filter bar ——— */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--grey-border);
    border-radius: 4px;
    font-size: 14px;
}

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--grey-border);
    border-radius: 4px;
    font-size: 14px;
}

/* ——— Tables ——— */
.table-container { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    background: var(--grey-bg);
    border-bottom: 1px solid var(--grey-border);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--grey-border);
}

.data-table tbody tr:hover { background: var(--grey-bg); }

.data-table .col-actions a {
    color: var(--blue);
    text-decoration: none;
}

.data-table .col-actions a:hover { text-decoration: underline; }

/* ——— Fiche client : bloc Infos + actions ——— */
.client-info-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--grey-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.client-info-actions-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.client-info-actions-main .btn,
.client-info-actions-danger .btn {
    white-space: nowrap;
    min-height: 38px;
    align-items: center;
}
.client-info-action-form {
    display: inline-block;
}
.client-info-actions-danger {
    flex-shrink: 0;
}
.client-info-edit-table .form-control { width: 100%; max-width: 400px; }
.client-info-edit-actions { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grey-border); display: flex; gap: 10px; }
@media (max-width: 768px) {
    .client-info-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .client-info-actions-main { justify-content: flex-start; }
    .client-info-actions-danger { border-top: 1px solid var(--grey-border); padding-top: 12px; }
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.card-block-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.table-title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ——— Badges ——— */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #e6f4ea; color: var(--green); }
.badge-warning { background: #fef7e0; color: #b06000; }
.badge-primary { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fce8e6; color: var(--red); }
.badge-info { background: #e8f0fe; color: var(--blue); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }
.badge-secondary { background: #e2e8f0; color: #475569; }

/* ——— Buttons ——— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
}

.btn, .btn-primary { background: var(--blue); color: var(--white); }
.btn:hover { background: var(--blue-hover); color: var(--white); }

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

.btn-success { background: var(--green); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-warning { background: #f29900; color: var(--white); }

.filter-bar .btn-reset { background: var(--grey-bg); color: var(--text); }
.filter-bar .btn-reset:hover { background: var(--grey-border); }

/* ——— Forms ——— */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; }
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--grey-border);
    border-radius: 4px;
    font-size: 14px;
}
.form-control:focus {
    outline: none;
    border-color: var(--blue);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}
.form-group small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.form-group-flex .form-group { margin-bottom: 8px; }

.fiche-salaries-list { list-style: none; padding: 0; margin: 0; }
.fiche-salaries-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--grey-bg);
}
.fiche-salaries-item a.fiche-salaries-item-link { color: #1a1a1a; text-decoration: none; font-weight: 500; }
.fiche-salaries-item a.fiche-salaries-item-link:hover { color: #1a1a1a; text-decoration: underline; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 4px;
    background: var(--grey-bg);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.btn-icon:hover { background: var(--blue); color: var(--white); }

/* ——— Alerts ——— */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}
.alert-success { background: #e6f4ea; color: #1e8e3e; }
.alert-error { background: #fce8e6; color: #c5221f; }
.alert-warning { background: #fef7e0; color: #b06000; }
.alert-info { background: #e8f0fe; color: var(--blue); }

/* ——— Connexion QR ——— Un seul code visible (QR ou Data Matrix), affichage propre ——— */
.qr-page-wrap {
    text-align: center;
    max-width: 320px;
    margin: 0 auto;
}
.qr-box {
    width: 260px;
    height: 260px;
    margin: 0 auto;
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 6px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qr-box.qr-box--clickable {
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.qr-box.qr-box--clickable:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
/* Overlay assombri en mode focus (clic sur le code) */
.qr-focus-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9998;
    cursor: pointer;
}
body.qr-focus-mode .qr-focus-overlay {
    display: block;
}
/* Code en avant-plan, luminosité max (fond blanc intense, centré) */
body.qr-focus-mode .qr-box {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    width: 320px;
    height: 320px;
    max-width: 92vw;
    max-height: 92vw;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 0 80px rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
}
body.qr-focus-mode .qr-box .qr-slot #qrcode img,
body.qr-focus-mode .qr-box .qr-slot #qrcode canvas,
body.qr-focus-mode .qr-box .qr-slot #datamatrix-canvas {
    filter: brightness(1.05);
}
.qr-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.qr-slot.qr-slot--hidden {
    display: none !important;
}
.qr-slot #qrcode {
    display: flex;
    align-items: center;
    justify-content: center;
}
.qr-slot #qrcode table {
    margin: 0 auto;
    border-collapse: collapse;
}
.qr-slot #qrcode img,
.qr-slot #qrcode canvas,
.qr-slot #datamatrix-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}
.qr-slot #datamatrix-canvas {
    background: var(--white);
}
.qr-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: 14px 0 16px;
}
.qr-hint i { margin-right: 6px; }
.qr-btn-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.qr-actions-wrap {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
}
.qr-action-form {
    margin: 0;
}
.qr-footer-note {
    font-size: 13px;
    color: var(--text-muted);
    margin: 12px 0 0;
}
.qr-no-code {
    margin: 0;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .qr-box { width: 240px; height: 240px; }
}

/* ——— Footer ——— */
.main-footer {
    background: var(--white);
    border-top: 1px solid var(--grey-border);
    padding: 20px var(--pad);
    margin-top: 40px;
}

.footer-container {
    max-width: var(--max);
    margin: 0 auto;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ——— Utils ——— */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
