body {
    font-family: 'Space Grotesk', sans-serif;
    padding-bottom: 3rem;
}

/* Champs requis */
label.required::after,
span.required::after {
    content: ' *';
    color: #dc3545;
}

/* Navigation */
.navbar-nav .nav-item {
    margin-right: 0.5rem;
}

.navbar-toggler {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
}

/* Navigation mobile */
.mobile-nav {
    padding-bottom: 0.5rem;
}

.mobile-nav-user {
    border-bottom: 1px solid #e9ecef;
}

.mobile-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    padding: 0.75rem 0.75rem 0.25rem;
}

.mobile-nav-section {
    display: flex;
    flex-direction: column;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    color: #212529;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 0.375rem;
    margin: 0 0.25rem;
    transition: background-color 0.15s;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
    background-color: #f0f6ff;
    color: #0d6efd;
}

.mobile-nav-link i {
    font-size: 1.1rem;
    width: 1.4rem;
    text-align: center;
    color: #6c757d;
}

.mobile-nav-link:hover i {
    color: #0d6efd;
}

.mobile-nav-link.text-danger i {
    color: #dc3545;
}

/* DataTables */
.datatable td,
.datatable-filterable td {
    vertical-align: middle;
}

.datatable th,
.datatable td,
.datatable-filterable th,
.datatable-filterable td {
    text-align: left !important;
    white-space: nowrap;
}

.datatable td:last-child,
.datatable th:last-child,
.datatable-filterable td:last-child,
.datatable-filterable th:last-child {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}


/* Dropzone */
.dropzone-area {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background-color 0.2s;
}

.dropzone-content {
    padding: 1rem 0;
}

#dropzone-preview canvas {
    display: block;
    max-height: 400px;
    object-fit: contain;
}

.dropzone-area:hover,
.dropzone-area.dragover {
    border-color: #0d6efd;
    background-color: #f0f6ff;
}

.dropzone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-filename {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Prévisionnel — vue par équipe */
.forecast-summary-card {
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    cursor: pointer;
}

.forecast-summary-card:hover {
    border-color: var(--bs-primary);
    transform: translateY(-1px);
}

.forecast-month-card {
    transition: border-color 0.15s, box-shadow 0.15s;
}

.forecast-month-card:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, .15);
}

.forecast-month-card h6 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
}

.forecast-total-card {
    border-color: var(--bs-primary);
    border-width: 1px;
}

/* Form errors — Tom Select + visibility */
.is-invalid > .form-label,
.mb-3.is-invalid > .form-label {
    color: var(--bs-danger);
}

.is-invalid .ts-wrapper .ts-control,
.mb-3.is-invalid .ts-wrapper .ts-control {
    border-color: var(--bs-danger);
}

.is-invalid .ts-wrapper.focus .ts-control,
.mb-3.is-invalid .ts-wrapper.focus .ts-control {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, .25);
    border-color: var(--bs-danger);
}

/* Ensure inline error messages are always visible (Symfony already adds d-block but be safe) */
.invalid-feedback { display: block; }

/* Batch upload (multi-fichiers) */
.batch-dropzone {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem 1rem;
    text-align: center;
    transition: border-color 0.2s, background-color 0.2s;
}

.batch-dropzone.dragover {
    border-color: #0d6efd;
    background-color: #f0f6ff;
}

.batch-dropzone-content { padding: 1rem 0; }

.batch-pdf-wrapper {
    height: calc(100vh - 260px);
    min-height: 480px;
}

.batch-pdf-frame {
    width: 100%;
    height: 100%;
    border: 0;
}

.batch-thumbs { gap: 0.25rem; }

.batch-thumb {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #495057;
    background: #fff;
    transition: border-color 0.15s, background-color 0.15s;
}

.batch-thumb:hover { border-color: #0d6efd; background-color: #f0f6ff; }
.batch-thumb.active { border-color: #0d6efd; background-color: #e7f0ff; box-shadow: 0 0 0 2px rgba(13, 110, 253, .15); }
.batch-thumb .badge { line-height: 1; padding: 0.15rem 0.3rem; font-size: 0.65rem; }
.batch-thumb .small { font-size: 0.7rem; margin-top: 1px; }

/* Batch selection */
.batch-checkbox-col {
    width: 1% !important;
    text-align: center !important;
}

.batch-toolbar {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.batch-toolbar form .ts-wrapper {
    width: auto;
    min-width: 180px;
    max-width: 320px;
    margin: 0;
    flex: 0 1 auto;
}

.batch-toolbar form .ts-wrapper .ts-control {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.1rem 0.5rem;
    font-size: 0.875rem;
}

/* Password toggle */
.password-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid #dee2e6;
    border-left: none;
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Tom Select */
.ts-wrapper .ts-control {
    font-size: 0.875rem;
}

/* Focus visible pour accessibilité clavier */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Skip to content (accessibilité) */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: #0d6efd;
    color: #fff;
    text-decoration: none;
}

.skip-to-content:focus {
    top: 0;
}


/* Mode démo — bannière */
.demo-banner {
    background: linear-gradient(135deg, #ff9f43, #f39c12);
    color: #fff;
    font-size: 0.8rem;
    padding: 0.35rem 1rem;
    text-align: center;
    position: relative;
    margin-bottom: 1rem;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.demo-banner i {
    font-size: 0.85rem;
}

.demo-banner-close {
    color: rgba(255, 255, 255, 0.8);
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    text-decoration: none;
    transition: color 0.15s;
}

.demo-banner-close:hover {
    color: #fff;
}

/* Mode démo — switch navbar */
.demo-switch-link {
    cursor: pointer;
}

.demo-switch-link:hover {
    background: none;
}

.demo-switch-link .form-check-input {
    pointer-events: none;
    cursor: pointer;
}

/* Filtres mobile — collapse chevron */
#mobile-filters .ts-wrapper .ts-control {
    font-size: 0.8rem;
}

[data-bs-target="#mobile-filters"] .bi-chevron-down {
    transition: transform 0.2s;
}

[data-bs-target="#mobile-filters"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Montants KPI dashboard — taille adaptative */
.fs-mob-amount {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Quote form — select client */
.client-select-wrapper {
    width: 280px;
    max-width: 100%;
}

/* Navbar logo responsive */
@media (max-width: 991.98px) {
    .navbar-logo {
        height: 45px !important;
    }
}

/* Login */
.login-logo {
    height: 40px;
}

/* Tables — wrapper responsive global */
.dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tableau mensuel dashboard */
.monthly-table td,
.monthly-table th {
    font-size: 0.85rem;
}

/* ===== Tablette (< 992px) ===== */
@media (max-width: 991.98px) {
    /* Sidebar formulaires factures et devis pleine largeur */
    .invoice-form .col-md-8,
    .invoice-form .col-md-4 {
        width: 100%;
    }

    /* Dashboard bottom row pleine largeur */
    #dashboard-bottom-row .col-md-7,
    #dashboard-bottom-row .col-md-5 {
        width: 100%;
    }
}

/* ===== Mobile (< 768px) ===== */
@media (max-width: 767.98px) {
    body {
        padding-bottom: 1.5rem;
    }

    .batch-toolbar {
        flex-wrap: wrap;
    }

    .batch-toolbar form {
        width: 100%;
        justify-content: flex-end;
    }

    /* KPI montants plus petits */
    .fs-mob-amount {
        font-size: 1.1rem;
    }

    /* Tableau mensuel compact */
    .monthly-table td,
    .monthly-table th {
        font-size: 0.75rem;
        padding: 0.3rem 0.4rem;
    }

    /* Tables — font compact */
    .datatable td,
    .datatable th,
    .datatable-filterable td,
    .datatable-filterable th {
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
    }

    .datatable td:last-child,
    .datatable-filterable td:last-child {
        white-space: nowrap;
    }

    /* Chart plus compact */
    #marginChart {
        min-height: 200px;
    }

    /* Quote client select pleine largeur */
    .client-select-wrapper {
        width: 100%;
    }
}

/* ===== Petit mobile (< 576px) ===== */
@media (max-width: 575.98px) {
    h1 {
        font-size: 1.3rem;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    /* Filtres dashboard pleine largeur */
    #dashboard-filters .col-md-2 {
        width: 100%;
    }

    /* KPI encore plus compact */
    .fs-mob-amount {
        font-size: 0.95rem;
    }

    /* Cards padding réduit */
    .card-body {
        padding: 0.75rem;
    }

    /* Login centré avec padding */
    .login-logo {
        height: 32px;
    }

    /* Dropzone compact */
    .dropzone-content {
        padding: 0.5rem 0;
    }

    .dropzone-content .fs-1 {
        font-size: 1.5rem !important;
    }

    /* Receipt scan — boutons empilés */
    #capture-buttons .btn {
        width: 100%;
    }

    /* Demo banner compact */
    .demo-banner {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}
