body {
    background-color: var(--primary-color);
}

/* ===== GESTIBAR CUSTOM STYLES ===== */

/* Variables CSS personnalisées */
:root {
    --primary-color: #D5EBF0;
    --success-color: #1cc88a;
    --warning-color: #8D8066;
    --danger-color: #e74a3b;
    --info-color: #85898F;
    --dark-color: #7B6F6F;
    --light-color: #f8f9fc;
    --text-dark: #42433F;
    --border-radius: 0.35rem;
    --box-shadow: 0 0.15rem 1.75rem 0 rgba(66, 67, 63, 0.15);
}

/* ===== LAYOUT & STRUCTURE ===== */

.page-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    color: var(--text-dark);
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.page-title {
    margin: 0;
    font-weight: 700;
    font-size: 2rem;
}

.breadcrumb {
    background: transparent;
    margin: 0.5rem 0 0 0;
}

.breadcrumb-item a {
    color: rgba(66, 67, 63, 0.8);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: rgba(66, 67, 63, 0.6);
}

/* ===== CARDS & COMPONENTS ===== */

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 2rem 0 rgba(58, 59, 69, 0.2);
}

.card-header {
    background: linear-gradient(135deg, var(--light-color) 0%, #eaecf4 100%);
    border-bottom: 1px solid #e3e6f0;
    font-weight: 700;
}

.border-left-primary {
    border-left: 0.25rem solid var(--primary-color) !important;
}

.border-left-success {
    border-left: 0.25rem solid var(--success-color) !important;
}

.border-left-warning {
    border-left: 0.25rem solid var(--warning-color) !important;
}

.border-left-danger {
    border-left: 0.25rem solid var(--danger-color) !important;
}

.border-left-info {
    border-left: 0.25rem solid var(--info-color) !important;
}

/* ===== KPI CARDS ===== */

.text-xs {
    font-size: 0.7rem;
}

.text-gray-300 {
    color: #dddfeb !important;
}

/* ===== SCANNER CAMÉRA ===== */

/* Container principal du scanner */
#scannerContainer {
    width: 100% !important;
    height: 300px !important;
    max-width: 100% !important;
    overflow: hidden !important;
    border-radius: 8px;
    background: #f8f9fa;
    position: relative;
}

/* Styles pour HTML5QrCode */
#scannerContainer video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 8px;
}

#scannerContainer canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}

/* Zone de scan avec bordures */
.scanner-area {
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 1rem;
    background: #ffffff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Responsive pour différentes tailles d'écran */
@media (max-width: 768px) {
    #scannerContainer {
        height: 250px !important;
    }
}

@media (max-width: 576px) {
    #scannerContainer {
        height: 200px !important;
    }
}

/* Fix pour Firefox */
@-moz-document url-prefix() {
    #scannerContainer {
        min-height: 300px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #scannerContainer video,
    #scannerContainer canvas {
        max-width: 100%;
        max-height: 100%;
        width: auto !important;
        height: auto !important;
    }
}

/* Fix pour Brave/Chromium */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    #scannerContainer {
        overflow: visible;
        position: relative;
    }
    
    #scannerContainer video,
    #scannerContainer canvas {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
    }
}

.text-gray-800 {
    color: var(--text-dark) !important;
}

/* ===== BUTTONS ===== */

.btn {
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
    padding: 1rem;
}

.btn-block i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* ===== TABLES ===== */

.table {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead th {
    background: linear-gradient(135deg, var(--dark-color) 0%, var(--text-dark) 100%);
    color: white;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.table-hover tbody tr:hover {
    background-color: rgba(213, 235, 240, 0.1);
    transform: scale(1.01);
    transition: all 0.2s ease;
}

/* ===== BADGES ===== */

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
}

/* ===== FORMS ===== */

.form-control, .form-select {
    border-radius: var(--border-radius);
    border: 1px solid #d1d3e2;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(213, 235, 240, 0.25);
}

/* ===== MODALS ===== */

.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: 0 0.5rem 2rem 0 rgba(58, 59, 69, 0.3);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    color: var(--text-dark);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-title {
    font-weight: 700;
}

/* ===== ALERTS ===== */

.alert {
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
}

.alert-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* ===== TIMELINE ===== */

.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline-item {
    position: relative;
    padding-left: 30px;
    margin-bottom: 20px;
}

.timeline-marker {
    position: absolute;
    left: 0;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 3px var(--info-color);
}

.timeline-content {
    padding: 10px 0;
}

.timeline-title {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
}

.timeline-text {
    margin: 0 0 5px 0;
    font-size: 12px;
    color: var(--dark-color);
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .page-header {
        padding: 1rem 0;
        margin-bottom: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .btn-block {
        padding: 0.75rem;
    }
    
    .btn-block i {
        font-size: 1.25rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .col-md-3, .col-md-6 {
        margin-bottom: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .badge {
        font-size: 0.7rem;
        padding: 0.375rem 0.5rem;
    }
}

/* ===== ANIMATIONS ===== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* ===== LOADING STATES ===== */

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== CUSTOM SCROLLBAR ===== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--info-color);
}

/* ===== UTILITY CLASSES ===== */

.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
}

.bg-gradient-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #13855c 100%);
}

.bg-gradient-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, var(--dark-color) 100%);
}

.bg-gradient-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #be2617 100%);
}

/* ===== PRINT STYLES ===== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .page-header {
        background: none !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ✅ STYLES POUR L'ÉDITION INLINE DU STOCK */

/* Interface d'édition */
.stock-edit-interface {
    display: inline-block;
    margin-left: 0.5rem;
}

.stock-edit-interface .input-group {
    max-width: 120px;
}

.stock-edit-interface .form-control {
    border-radius: 0.25rem 0 0 0.25rem;
    border: 1px solid var(--primary-color);
    font-weight: 600;
    text-align: center;
}

.stock-edit-interface .btn {
    border-radius: 0;
    padding: 0.25rem 0.5rem;
}

.stock-edit-interface .stock-save-btn {
    border-radius: 0;
}

.stock-edit-interface .stock-cancel-btn {
    border-radius: 0 0.25rem 0.25rem 0;
}

/* Icône d'édition */
.stock-edit-icon {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.stock-edit-icon:hover {
    opacity: 1;
}

/* États de l'édition */
.stock-editable-mobile.editing,
.stock-editable-tablet.editing,
.stock-editable-desktop.editing {
    background-color: rgba(213, 235, 240, 0.2);
    border-radius: 0.25rem;
    padding: 0.25rem;
}

/* Responsive pour mobile */
@media (max-width: 767.98px) {
    .stock-edit-interface .input-group {
        max-width: 100px;
    }
    
    .stock-edit-interface .form-control {
        font-size: 0.875rem;
        padding: 0.25rem;
    }
    
    .stock-edit-interface .btn {
        padding: 0.25rem;
        font-size: 0.75rem;
    }
}

/* Responsive pour tablettes */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .stock-edit-interface .input-group {
        max-width: 110px;
    }
}

/* Animation d'édition */
.stock-edit-interface {
    animation: slideIn 0.2s ease-out;
}

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

/* Validation visuelle */
.stock-input.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.stock-input.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* ✅ STYLES RESPONSIVE COMPLETS POUR GESTIBAR STOCK */

/* ===== MOBILE (jusqu'à 767.98px) ===== */
@media (max-width: 767.98px) {
    .product-card-mobile {
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .product-card-mobile .card-body {
        padding: 1rem;
    }
    
    .product-card-mobile .btn-group-sm .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .d-md-none .text-muted {
        font-size: 0.75rem;
    }
}

/* ===== TABLETTE (768px à 1023.98px) ===== */
@media (min-width: 768px) and (max-width: 1023.98px) {
    /* Tableau compact pour tablettes */
    #gestibarStockTableTablet {
        font-size: 0.875rem;
    }
    
    #gestibarStockTableTablet th,
    #gestibarStockTableTablet td {
        padding: 0.5rem 0.25rem;
        vertical-align: middle;
    }
    
    #gestibarStockTableTablet .img-thumbnail {
        border-radius: 4px;
    }
    
    /* Filtres compacts */
    .form-select-sm {
        font-size: 0.875rem;
        padding: 0.375rem 0.5rem;
    }
    
    .form-check-inline {
        margin-right: 0.5rem;
    }
    
    .form-check-label {
        font-size: 0.875rem;
    }
    
    /* Boutons adaptés tablettes */
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-group-vertical .btn {
        margin-bottom: 0.25rem;
    }
    
    /* Badges optimisés tablettes */
    .badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    /* En-tête adapté */
    .card-header h6 {
        font-size: 1.1rem;
    }
    
    /* Espacement optimisé */
    .card-body {
        padding: 1rem;
    }
    
    .row.g-2 > * {
        padding: 0.25rem;
    }
}

/* ===== DESKTOP (1200px et plus) ===== */
@media (min-width: 1200px) {
    /* Layout desktop */
    .main-panel {
        margin-left: 250px !important;
        width: calc(100% - 250px) !important;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    .page-inner {
        flex: 1;
        width: 100%;
        padding: 20px;
    }
    
    .container {
        max-width: 100%;
        width: 100%;
    }
    
    /* Styles existants pour desktop */
    #gestibarStockTable th,
    #gestibarStockTable td {
        padding: 0.75rem;
    }
    
    .form-select, .form-control {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
    }
    
    /* S'assurer que les formulaires prennent toute la largeur */
    .form-container {
        width: 100%;
        max-width: 100%;
    }
    
    .card {
        width: 100%;
    }
    
    /* Footer desktop */
    .footer {
        margin-top: auto;
        background-color: #f8f9fa;
        border-top: 1px solid #dee2e6;
        padding: 1rem 0;
        width: 100%;
    }
}

/* ===== MODALS RESPONSIVES ===== */

/* Mobile : Full screen */
@media (max-width: 575.98px) {
    .modal-fullscreen-sm-down {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-fullscreen-sm-down .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }
}

/* Tablette : Large mais pas full screen */
@media (min-width: 576px) and (max-width: 1023.98px) {
    .modal-lg-md {
        max-width: 90%;
        margin: 1.75rem auto;
    }
    
    .modal-lg-md .modal-content {
        border-radius: 0.5rem;
    }
    
    /* Optimisation du contenu des modals sur tablettes */
    .modal-body {
        padding: 1.5rem;
    }
    
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .tab-content {
        padding-top: 1rem;
    }
}

/* ===== UTILITAIRES RESPONSIVES ===== */

/* Masquage conditionnel selon la taille d'écran */
.d-tablet-only {
    display: none;
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .d-tablet-only {
        display: block;
    }
}

.d-mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .d-mobile-only {
        display: none;
    }
}

.d-desktop-only {
    display: none;
}

@media (min-width: 1024px) {
    .d-desktop-only {
        display: block;
    }
}

/* ===== OPTIMISATIONS SPÉCIFIQUES TABLETTE ===== */

@media (min-width: 768px) and (max-width: 1023.98px) {
    /* Fix pour le défilement sur tablette */
    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    
    .wrapper {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    
    .main-panel {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    
    .page-inner {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: calc(100vh - 60px) !important;
    }
    
    .container {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
    
    /* Amélioration de la lisibilité */
    .text-muted {
        color: var(--dark-color) !important;
    }
    
    /* Espacement optimisé pour tablettes */
    .mb-3 {
        margin-bottom: 1rem !important;
    }
    
    .mt-3 {
        margin-top: 1rem !important;
    }
    
    /* Boutons d'action optimisés */
    .btn-group-vertical {
        width: 100%;
    }
    
    .btn-group-vertical .btn {
        width: 100%;
        text-align: center;
    }
    
    /* Images optimisées tablettes */
    .img-thumbnail {
        object-fit: cover;
    }
    
    /* S'assurer que les modals ne bloquent pas le scroll */
    
    /* ===== OPTIMISATION BOUTONS ACTIONS RAPIDES EN MODE TABLETTE ===== */
    
    /* Grille de 4 boutons par ligne en mode tablette */
    .card-body .row .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    /* Boutons d'action rapide optimisés pour tablette */
    .card-body .btn-block {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
        min-height: 60px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }
    
    /* Icônes des boutons d'action rapide */
    .card-body .btn-block i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }
    
    /* Texte des boutons d'action rapide */
    .card-body .btn-block small {
        font-size: 0.75rem;
        line-height: 1.2;
    }
    
    /* Espacement optimisé entre les boutons */
    .card-body .row .col-md-3 {
        margin-bottom: 1rem;
    }
    
    /* Responsive pour très petites tablettes */
    @media (max-width: 991.98px) {
        .card-body .row .col-md-3 {
            flex: 0 0 50%;
            max-width: 50%;
        }
    }
    .modal {
        overflow-y: auto !important;
    }
    
    .modal-dialog {
        overflow-y: auto !important;
    }
    
    .modal-content {
        overflow-y: auto !important;
    }
}
