/* ===== BOULANGERIE PRO — Responsive ===== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    background: #f5f3ef;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    margin: 0;
    overflow-x: hidden;
    min-height: 100vh;
}

img, svg, video { max-width: 100%; height: auto; }

/* ---- Layout ---- */
#wrapper {
    min-height: 100vh;
    width: 100%;
}

#page-content {
    min-width: 0; /* empêche le débordement flex */
    width: 100%;
}

main.p-4 {
    padding: 1.25rem !important;
}

/* ---- Sidebar ---- */
#sidebar {
    width: 240px;
    min-height: 100vh;
    background: #2b2118;
    color: #d9cbb8;
    position: sticky;
    top: 0;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 18px 20px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #f0ad4e;
    border-bottom: 1px solid #44372a;
    letter-spacing: 1px;
}

.sidebar-brand span { color: #fff; }

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

.sidebar-menu a {
    display: block;
    padding: 8px 12px;
    margin: 2px 0;
    color: #d9cbb8;
    text-decoration: none;
    border-radius: 8px;
    font-size: .93rem;
}

.sidebar-menu a:hover { background: #44372a; color: #fff; }
.sidebar-menu a.active { background: #f0ad4e; color: #2b2118; font-weight: 700; }

.sidebar-title {
    padding: 12px 12px 4px;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #8a7a66;
}

/* Overlay mobile quand le menu est ouvert */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 999;
}

.sidebar-backdrop.show { display: block; }

/* ---- Topbar ---- */
.topbar {
    background: #fff;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e0d8;
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 8px;
}

.page-title {
    font-weight: 700;
    color: #4a3b2c;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50vw;
}

/* ---- Stat cards ---- */
.stat-card { border: none; border-radius: 14px; }
.stat-card .card-body { padding: 1rem; }
.stat-card .card-body i { font-size: 1.6rem; opacity: .55; float: right; }
.stat-card h3 {
    font-weight: 800;
    font-size: 1.35rem;
    word-break: break-word;
}

/* ---- Tables ---- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table { margin-bottom: 0; }
.table th, .table td { vertical-align: middle; }

/* ---- POS ---- */
.prod-btn {
    border-width: 2px;
    padding: 8px 4px;
    font-size: .85rem;
    height: 100%;
    min-height: 72px;
}
.prod-btn:hover:not(:disabled) {
    background: #f0ad4e;
    border-color: #f0ad4e;
    color: #2b2118;
}
.prod-btn:disabled { opacity: .45; }

/* ---- Login ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(135deg, #2b2118 0%, #6b4f2c 60%, #f0ad4e 100%);
}

.login-card {
    width: 400px;
    max-width: 100%;
    border: none;
    border-radius: 18px;
}

.login-logo {
    width: 70px;
    height: 70px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: #f0ad4e;
    color: #2b2118;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card .btn-warning { background: #f0ad4e; border-color: #f0ad4e; }

/* ---- Cards & forms ---- */
.card { border-radius: 12px; }
.card-header { flex-wrap: wrap; gap: 8px; }

.btn-group { flex-wrap: wrap; }

/* Filtres journal */
.card .btn-group-sm .btn { margin-bottom: 4px; }

/* ---- Etiquettes code-barres (impression A4) ---- */
.label-item {
    display: inline-block;
    width: 46mm;
    height: 30mm;
    margin: 1.5mm;
    border: 1px dashed #999;
    border-radius: 3px;
    padding: 2mm;
    background: #fff;
    vertical-align: top;
    text-align: center;
    overflow: hidden;
}
.label-cat {
    font-size: 7px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.label-name {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
    height: 8mm;
    overflow: hidden;
}
.label-price { font-size: 13px; font-weight: 800; color: #b8860b; }
.label-code { font-size: 7px; color: #555; letter-spacing: 2px; }

/* ========== TABLETTE (<= 991px) ========== */
@media (max-width: 991px) {
    #sidebar {
        position: fixed;
        z-index: 1000;
        height: 100vh;
        left: -260px;
        transition: left .3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: none;
    }
    #sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .35);
    }

    main.p-4 { padding: 1rem !important; }

    .topbar { padding: 10px 12px; }

    .stat-card h3 { font-size: 1.15rem; }
}

/* ========== MOBILE (<= 576px) ========== */
@media (max-width: 576px) {
    main.p-4 { padding: .75rem !important; }

    .page-title { font-size: .95rem; max-width: 40vw; }

    .topbar .badge { display: none; }

    .stat-card .card-body { padding: .75rem; }
    .stat-card h3 { font-size: 1rem; }
    .stat-card .card-body i { font-size: 1.2rem; }
    .stat-card small { font-size: .75rem; }

    /* Boutons produits POS : 2 colonnes */
    .produit-item.col-4 { flex: 0 0 50%; max-width: 50%; }
    .prod-btn { font-size: .78rem; min-height: 64px; padding: 6px 2px; }

    /* Tables plus compactes */
    .table { font-size: .82rem; }
    .table th, .table td { padding: .35rem .4rem; }

    /* Groupes de boutons export / filtres */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    .btn-group > .btn {
        border-radius: .375rem !important;
        margin: 2px 0 !important;
        width: 100%;
    }

    .card-header {
        font-size: .9rem;
        padding: .6rem .75rem;
    }

    /* Filtres dates */
    .card-body .row.g-2 > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Formulaires */
    .form-control, .form-select { font-size: 16px; } /* évite le zoom iOS */

    /* Modal plein écran léger */
    .modal-dialog { margin: .5rem; }
}

/* ========== PETIT MOBILE (<= 400px) ========== */
@media (max-width: 400px) {
    .stat-card h3 { font-size: .9rem; }
    .prod-btn strong { font-size: .8rem; }
}

/* ========== IMPRESSION ========== */
@media print {
    .no-print, #sidebar, .topbar, .sidebar-backdrop { display: none !important; }
    #page-content { margin: 0 !important; }
    main.p-4 { padding: 0 !important; }
    .label-item { border: 1px solid #ccc; }
}
