/* Custom styles for Garage EuroFret */

:root {
    /* Couleurs primaires */
    --primary-color: #0d6efd;
    --primary-color-dark: #1a5fc9;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;

    /* Couleurs système */
    --body-bg: #ffffff;
    --body-color: #212529;
    --card-bg: #ffffff;
    --card-border: #dee2e6;
    --table-header-bg: #f8f9fa;
    --table-border: #dee2e6;
    --navbar-bg: var(--primary-color);
    --navbar-color: #ffffff;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --input-bg: #ffffff;
    --input-border: #dee2e6;

    /* Rayons de bordure */
    --border-radius-sm: 8px;
    --border-radius-md: 10px;
    --border-radius-lg: 12px;

    /* Tailles d'icônes */
    --icon-size-sm: 1.5rem;
    --icon-size-md: 2rem;
    --icon-size-lg: 3rem;
    --icon-size-xl: 4rem;
}

/* Dark theme variables */
:root[data-theme="dark"] {
    --primary-color: #4d94ff;
    --primary-color-dark: #3b7dd8;
    --secondary-color: #9ca3af;
    --success-color: #34d399;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --info-color: #60a5fa;

    --body-bg: #1a1a1a;
    --body-color: #e5e7eb;
    --card-bg: #2d2d2d;
    --card-border: #404040;
    --table-header-bg: #404040;
    --table-border: #525252;
    --navbar-bg: #1f2937;
    --navbar-color: #f9fafb;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
    --input-bg: #374151;
    --input-border: #4b5563;
}

/* Accessibility - Larger buttons and text for elderly users */
body {
    font-size: 1.1rem;
    background-color: var(--body-bg);
    color: var(--body-color);
}

.btn {
    padding: 0.6rem 1.2rem;
    font-size: 1.05rem;
}

.btn-lg {
    padding: 0.8rem 1.5rem;
    font-size: 1.2rem;
}

.form-control, .form-select {
    font-size: 1.05rem;
    padding: 0.6rem 0.8rem;
}

.form-control-lg {
    font-size: 1.2rem;
    padding: 0.8rem 1rem;
}

/* Cards */
.card {
    border-radius: var(--border-radius-md);
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 2px solid var(--card-border);
    font-weight: 600;
}

/* Navbar */
.navbar {
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Tables */
.table {
    font-size: 1rem;
    color: var(--body-color);
}

.table thead th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    border-bottom: 2px solid var(--table-border);
}

/* Buttons with icons */
.btn i {
    margin-right: 0.3rem;
}

/* Alert badges */
.badge {
    font-size: 0.85rem;
    padding: 0.35em 0.6em;
}

/* Icon sizes - classes réutilisables */
.icon-sm {
    font-size: var(--icon-size-sm);
}

.icon-md {
    font-size: var(--icon-size-md);
}

.icon-lg {
    font-size: var(--icon-size-lg);
}

.icon-xl {
    font-size: var(--icon-size-xl);
}

.icon-xxl {
    font-size: 5rem;
}

/* Stat card icon - pour le dashboard */
.stat-icon {
    font-size: var(--icon-size-lg);
}

/* Stat card icon small - pour le dashboard compact */
.stat-icon-sm {
    font-size: 2rem;
}

/* Empty state icon - pour les listes vides */
.empty-icon {
    font-size: var(--icon-size-xl);
}

/* Loading spinner */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

/* Footer */
footer {
    margin-top: auto;
    border-top: 1px solid var(--card-border);
}

/* Image gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.photo-gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.photo-gallery img:hover {
    transform: scale(1.05);
}

/* QR Code display */
.qr-code-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: var(--border-radius-md);
}

.qr-code-container img {
    max-width: 300px;
    height: auto;
}

/* Print styles */
@media print {
    .navbar, footer, .no-print {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container-fluid {
        padding: 0.5rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .table {
        font-size: 0.9rem;
    }

    /* Stack stats cards on mobile */
    .row > [class*="col-md-3"] {
        margin-bottom: 1rem;
    }
}

/* ========================================
   VUE CARTE MOBILE POUR TABLEAUX
   Transforme les tableaux en cartes sur mobile
   ======================================== */

/* Container pour les cartes mobiles */
/* === Expandable detail row (pieces list - kilometrage) === */
.expand-toggle-btn {
    color: var(--primary-color);
    line-height: 1;
    font-size: 1.2rem;
    transition: color 0.2s;
    border: none;
    background: none;
    padding: 0.25rem;
    cursor: pointer;
}

.expand-toggle-btn:hover {
    color: var(--primary-color-dark);
}

.detail-row {
    background-color: var(--table-header-bg) !important;
}

.detail-row > td {
    padding: 0.5rem 1rem !important;
    border-top: none !important;
}

.detail-row-content {
    padding: 0.5rem 0.75rem;
    background-color: var(--card-bg);
    border-left: 3px solid var(--info-color);
    border-radius: 4px;
}

/* Prevent table-striped from overriding detail row background */
.table-striped > tbody > tr.detail-row:nth-of-type(odd) > td,
.table-striped > tbody > tr.detail-row:nth-of-type(even) > td {
    background-color: var(--table-header-bg);
}

.mobile-cards {
    display: none;
}

/* Afficher cartes sur mobile, masquer tableau */
@media (max-width: 767.98px) {
    .table-responsive.desktop-table {
        display: none !important;
    }

    .mobile-cards {
        display: block;
        padding: 0.5rem;
    }

    /* Style des cartes individuelles */
    .mobile-card {
        background-color: var(--card-bg);
        border: 1px solid var(--card-border);
        border-radius: var(--border-radius-lg);
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
        overflow: hidden;
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .mobile-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    /* Header de la carte avec référence/titre */
    .mobile-card-header {
        background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
        color: white;
        padding: 0.75rem 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-card-header .reference {
        font-weight: 700;
        font-size: 1.1rem;
    }

    .mobile-card-header .badge {
        font-size: 0.75rem;
    }

    /* Titre principal de la carte */
    .mobile-card-title {
        padding: 0.75rem 1rem 0.5rem;
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--body-color);
        border-bottom: 1px solid var(--card-border);
    }

    /* Contenu de la carte en grille */
    .mobile-card-body {
        padding: 0.75rem 1rem;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px dashed var(--card-border);
    }

    .mobile-card-row:last-child {
        border-bottom: none;
    }

    .mobile-card-label {
        font-size: 0.85rem;
        color: var(--secondary-color);
        font-weight: 500;
    }

    .mobile-card-value {
        font-size: 0.95rem;
        font-weight: 500;
        text-align: right;
        max-width: 60%;
    }

    /* Footer avec les actions */
    .mobile-card-actions {
        display: flex;
        border-top: 1px solid var(--card-border);
        background-color: var(--table-header-bg);
    }

    .mobile-card-actions a,
    .mobile-card-actions button {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem;
        border: none;
        background: transparent;
        color: var(--body-color);
        text-decoration: none;
        font-size: 0.9rem;
        transition: background-color 0.2s;
    }

    .mobile-card-actions a:not(:last-child),
    .mobile-card-actions button:not(:last-child) {
        border-right: 1px solid var(--card-border);
    }

    .mobile-card-actions a:hover,
    .mobile-card-actions button:hover {
        background-color: var(--card-border);
    }

    .mobile-card-actions .action-view {
        color: var(--primary-color);
    }

    .mobile-card-actions .action-edit {
        color: var(--warning-color);
    }

    .mobile-card-actions .action-delete {
        color: var(--danger-color);
    }

    /* Badges dans les cartes */
    .mobile-card .badge {
        font-size: 0.8rem;
        padding: 0.35em 0.65em;
    }

    /* Indicateur stock bas */
    .mobile-card .stock-alert {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        color: var(--danger-color);
        font-size: 0.85rem;
    }

    /* Grille 2 colonnes pour infos compactes */
    .mobile-card-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem 1rem;
        padding: 0.75rem 1rem;
    }

    .mobile-card-grid-item {
        display: flex;
        flex-direction: column;
    }

    .mobile-card-grid-item .label {
        font-size: 0.75rem;
        color: var(--secondary-color);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mobile-card-grid-item .value {
        font-size: 0.95rem;
        font-weight: 500;
    }

    /* Kilometrage expandable section in mobile cards */
    .mobile-km-toggle {
        border-top: 1px dashed var(--card-border);
        padding: 0;
    }

    .mobile-expand-toggle-btn {
        color: var(--primary-color);
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        width: 100%;
        border: none;
        background: none;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .mobile-expand-toggle-btn:hover {
        background-color: var(--table-header-bg);
    }

    .mobile-km-detail {
        padding: 0.5rem 1rem 0.75rem;
        background-color: var(--table-header-bg);
        border-top: 1px solid var(--card-border);
    }

    /* Message quand liste vide */
    .mobile-cards-empty {
        text-align: center;
        padding: 3rem 1rem;
        color: var(--secondary-color);
    }

    .mobile-cards-empty i {
        font-size: 3rem;
        margin-bottom: 1rem;
    }
}

/* PWA specific */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Form inputs */
.form-control,
.form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--body-color);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--primary-color);
    color: var(--body-color);
}

/* Custom animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Status badges */
.badge-en_stock {
    background-color: var(--success-color);
}

.badge-vendu {
    background-color: var(--secondary-color);
}

.badge-reserve {
    background-color: var(--warning-color);
}

/* Transitions pour changement de thème */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
    transition: background-color 0.3s ease,
                color 0.3s ease,
                border-color 0.3s ease,
                box-shadow 0.3s ease !important;
}

/* ========================================
   SPINNER DE CHARGEMENT POUR FORMULAIRES
   ======================================== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spinner 0.75s linear infinite;
}

.btn-loading .btn-text {
    visibility: hidden;
}

@keyframes btn-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Overlay de chargement pour les cards/sections */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: inherit;
}

[data-theme="dark"] .loading-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

/* ========================================
   INDICATEUR DE WORKFLOW (STEPPER)
   ======================================== */
.workflow-stepper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.workflow-step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 20px;
    left: 50%;
    width: 100%;
    height: 3px;
    background-color: var(--card-border);
    z-index: 0;
}

.workflow-step.completed:not(:last-child)::after {
    background-color: var(--success-color);
}

.workflow-step.active:not(:last-child)::after {
    background: linear-gradient(90deg, var(--success-color) 50%, var(--card-border) 50%);
}

.workflow-step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--card-border);
    color: var(--secondary-color);
    font-weight: 600;
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

.workflow-step.completed .workflow-step-icon {
    background-color: var(--success-color);
    color: white;
}

.workflow-step.active .workflow-step-icon {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

.workflow-step-label {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--secondary-color);
    text-align: center;
}

.workflow-step.completed .workflow-step-label,
.workflow-step.active .workflow-step-label {
    color: var(--body-color);
}

@media (max-width: 576px) {
    .workflow-step-label {
        font-size: 0.7rem;
    }

    .workflow-step-icon {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
}

/* États spéciaux du workflow stepper */
.workflow-stepper.workflow-cancelled {
    justify-content: center;
}

.workflow-step.cancelled .workflow-step-icon {
    background-color: var(--secondary-color);
    color: white;
}

.workflow-step.cancelled .workflow-step-label {
    color: var(--secondary-color);
    font-weight: 600;
}

.workflow-step.refused .workflow-step-icon {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.25);
}

.workflow-step.refused .workflow-step-label {
    color: var(--danger-color);
}

.workflow-step.expired .workflow-step-icon {
    background-color: var(--secondary-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(108, 117, 125, 0.25);
}

.workflow-step.expired .workflow-step-label {
    color: var(--secondary-color);
}

.workflow-step.late .workflow-step-icon {
    background-color: var(--warning-color);
    color: #212529;
    box-shadow: 0 0 0 4px rgba(255, 193, 7, 0.25);
}

.workflow-step.late .workflow-step-label {
    color: var(--warning-color);
}

.workflow-step.partial .workflow-step-icon {
    background-color: var(--info-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(23, 162, 184, 0.25);
}

.workflow-step.partial .workflow-step-label {
    color: var(--info-color);
}

/* ========================================
   TIMELINE POUR L'HISTORIQUE
   ======================================== */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--card-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 2px solid var(--card-bg);
    z-index: 1;
}

.timeline-item.timeline-success::before {
    background-color: var(--success-color);
}

.timeline-item.timeline-warning::before {
    background-color: var(--warning-color);
}

.timeline-item.timeline-danger::before {
    background-color: var(--danger-color);
}

.timeline-item.timeline-info::before {
    background-color: var(--info-color);
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

.timeline-content {
    background-color: var(--table-header-bg);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1rem;
}

.timeline-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--body-color);
}

.timeline-description {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 0;
}

.timeline-user {
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-style: italic;
}

/* ========================================
   VALIDATION FORMULAIRE AMÉLIORÉE
   ======================================== */
.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--success-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--danger-color);
}

.is-invalid ~ .invalid-feedback {
    display: block;
}

/* ========================================
   AMÉLIORATIONS TOAST
   ======================================== */
.toast {
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
}

.toast-body {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.toast-body i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */
:root {
    --sidebar-width-expanded: 260px;
    --sidebar-width-collapsed: 70px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #4b5563;
    --sidebar-text-hover: #1f2937;
    --sidebar-active-bg: rgba(0, 0, 0, 0.05);
    --sidebar-divider: rgba(0, 0, 0, 0.1);
    --sidebar-border: #e5e7eb;
    --sidebar-transition: 0.3s ease;
}

:root[data-theme="dark"] {
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);
    --sidebar-divider: rgba(255, 255, 255, 0.1);
    --sidebar-border: #374151;
}

/* Sidebar container */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width-expanded);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--sidebar-transition);
    overflow: hidden;
}

.sidebar-collapsed {
    width: var(--sidebar-width-collapsed);
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--sidebar-divider);
    min-height: 60px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    color: var(--sidebar-text-hover);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand-icon {
    font-size: 1.5rem;
    min-width: 38px;
}

.sidebar-brand-text {
    margin-left: 0.5rem;
    opacity: 1;
    transition: opacity var(--sidebar-transition);
}

.sidebar-collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Societe Indicator */
.sidebar-societe {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--sidebar-divider);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-societe-link {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sidebar-societe-link:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-societe .sidebar-icon {
    min-width: 24px;
    font-size: 1rem;
}

.sidebar-societe .sidebar-icon-small {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.6;
}

.sidebar-societe-warning {
    background-color: rgba(255, 193, 7, 0.15);
}

.sidebar-societe-warning .sidebar-societe-link {
    color: var(--warning-color);
}

.sidebar-collapsed .sidebar-societe .sidebar-text,
.sidebar-collapsed .sidebar-societe .sidebar-icon-small {
    display: none;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin: 2px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-link:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-link.active {
    background-color: var(--primary-color);
    color: #ffffff;
}

.sidebar-icon {
    font-size: 1.25rem;
    min-width: 38px;
    display: flex;
    justify-content: center;
}

.sidebar-text {
    opacity: 1;
    transition: opacity var(--sidebar-transition);
    margin-left: 0.25rem;
}

.sidebar-collapsed .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--sidebar-divider);
    margin: 0.5rem 1rem;
}

/* Section Labels */
.sidebar-section-label {
    padding: 0.25rem 1.25rem;
    margin-top: 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.5;
    list-style: none;
    white-space: nowrap;
}

.sidebar-collapsed .sidebar-section-label {
    visibility: hidden;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* Submenu Container */
.sidebar-submenu-container {
    list-style: none;
    margin: 2px 8px;
}

.sidebar-submenu-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: inherit;
    font-family: inherit;
}

.sidebar-submenu-toggle:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-submenu-toggle.active {
    color: var(--sidebar-text-hover);
}

.sidebar-submenu-chevron {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.sidebar-submenu-container.open .sidebar-submenu-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-submenu-container.open .sidebar-submenu {
    max-height: 500px;
}

.sidebar-submenu .sidebar-item {
    margin-left: 0.5rem;
}

.sidebar-submenu .sidebar-link {
    padding: 0.5rem 1rem;
    font-size: 0.9em;
}

/* Submenu in collapsed sidebar */
.sidebar-collapsed .sidebar-submenu-chevron {
    display: none;
}

.sidebar-collapsed .sidebar-submenu {
    max-height: 0 !important;
}

.sidebar-collapsed .sidebar-submenu-container.open .sidebar-submenu {
    max-height: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-divider);
    padding: 0.5rem;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar-footer-btn:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background-color: var(--sidebar-active-bg);
    margin-top: 0.5rem;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.sidebar-user-actions {
    display: flex;
    gap: 0.25rem;
}

.sidebar-collapsed .sidebar-user-actions {
    flex-direction: column;
}

.sidebar-user-btn {
    padding: 0.5rem;
    color: var(--sidebar-text);
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-user-btn:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.sidebar-user-btn.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.2);
    color: #f87171;
}

/* Main Content adjustment */
.main-content {
    margin-left: var(--sidebar-width-expanded);
    transition: margin-left var(--sidebar-transition);
    min-height: 100vh;
}

.sidebar-is-collapsed .main-content {
    margin-left: var(--sidebar-width-collapsed);
}

/* Mobile sidebar */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1050;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width-expanded);
    }

    .sidebar-collapsed {
        width: var(--sidebar-width-expanded);
    }

    .sidebar-collapsed .sidebar-text,
    .sidebar-collapsed .sidebar-brand-text {
        opacity: 1;
        width: auto;
    }

    .sidebar-toggle-btn {
        display: none;
    }

    .mobile-sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-is-collapsed .main-content {
        margin-left: 0;
    }

    /* Mobile open state */
    .sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-open .sidebar-overlay {
        display: block;
    }

    .sidebar-mobile-open .mobile-sidebar-toggle {
        display: none;
    }
}

/* ========================================
   TAB-BASED DETAIL PAGES
   ======================================== */
.detail-tabs .nav-tabs {
    border-bottom: 2px solid var(--card-border);
    margin-bottom: 1.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.detail-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--secondary-color);
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.detail-tabs .nav-link:hover {
    border-bottom-color: var(--primary-color);
    color: var(--body-color);
    background-color: transparent;
}

.detail-tabs .nav-link.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
}

.detail-tabs .tab-content {
    padding: 1rem 0;
}

.tab-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Sticky sidebar card for detail pages */
.sticky-sidebar {
    position: sticky;
    top: 1rem;
}

/* Stats grid in sidebar */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background-color: var(--table-header-bg);
    border-radius: var(--border-radius-sm);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

/* Mobile tabs - horizontal scroll */
@media (max-width: 768px) {
    .detail-tabs .nav-tabs {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .detail-tabs .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .detail-tabs .nav-link {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   MOBILE RESPONSIVE ENHANCEMENTS
   ======================================== */

/* Boutons d'action plus grands sur mobile pour meilleure accessibilité tactile */
@media (max-width: 767.98px) {
    /* Boutons dans les groupes de boutons */
    .btn-group-sm .btn {
        padding: 0.5rem 0.75rem;
        font-size: 1rem;
        min-height: 44px; /* Touch-friendly minimum */
    }

    /* Boutons d'action dans les tableaux */
    .table .btn-group .btn {
        padding: 0.5rem;
    }

    /* Boutons principaux full-width sur mobile */
    .card-footer .btn,
    .form-actions .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .form-actions {
        flex-direction: column;
    }

    /* Espacer les filtres sur mobile */
    .card-body form.row > [class*="col-md"] {
        margin-bottom: 0.75rem;
    }

    /* Header page responsive */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > .btn,
    .d-flex.justify-content-between.align-items-center.mb-4 > a.btn {
        width: 100%;
    }

    /* Pagination compacte sur mobile */
    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    /* Masquer texte pagination, garder icônes */
    .pagination .page-item:first-child .page-link,
    .pagination .page-item:last-child .page-link {
        padding: 0.5rem;
    }
}

/* Très petit écran (< 576px) */
@media (max-width: 575.98px) {
    /* Titre de page plus petit */
    h2 {
        font-size: 1.5rem;
    }

    /* Cartes mobiles - réduire padding */
    .mobile-card-grid {
        gap: 0.25rem 0.5rem;
    }

    /* Stats grid sur 2 colonnes */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Boutons d'export empilés */
    .card-header .btn-sm {
        display: block;
        width: 100%;
        margin-bottom: 0.25rem;
    }
}

/* ===========================================
   Deferred Lines - Lignes en attente (Devis/Factures)
   =========================================== */

/* Ligne marquee pour suppression */
.ligne-item[data-status="pending-delete"] {
    text-decoration: line-through;
    opacity: 0.5;
    background-color: rgba(220, 53, 69, 0.1);
    position: relative;
    transition: all 0.3s ease;
}

:root[data-theme="dark"] .ligne-item[data-status="pending-delete"] {
    background-color: rgba(248, 113, 113, 0.15);
}

/* Ligne ajoutee (non enregistree) */
.ligne-item[data-status="pending-add"] {
    background-color: rgba(25, 135, 84, 0.1);
    border-left: 3px solid #198754;
    animation: fadeInLine 0.3s ease;
}

:root[data-theme="dark"] .ligne-item[data-status="pending-add"] {
    background-color: rgba(52, 211, 153, 0.15);
    border-left-color: #34d399;
}

@keyframes fadeInLine {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Badge "Non enregistre" */
.ligne-item .badge.bg-success {
    font-size: 0.65rem;
    padding: 2px 6px;
}

/* Carte des totaux avec modifications en attente */
.card.border-warning {
    border-width: 2px !important;
}

.pending-badge {
    font-size: 0.7rem;
    font-weight: normal;
}

/* ===========================================
   Skip Link pour l'accessibilité
   =========================================== */
.skip-link {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    z-index: 9999;
    text-decoration: none;
    font-weight: 500;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--warning-color);
    outline-offset: 2px;
}

/* ===========================================
   Indicateurs stock accessibles (texte pour screen readers)
   =========================================== */
.stock-badge .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
