/* ============================================================================
   Stockaz — Mode Bar
   Fichier : assets/css/stockaz-bar.css
   ============================================================================ */

:root {
    --stbar-primary:    ##6a00ae !important;
    --stbar-success:    #16A34A !important;
    --stbar-warning:    #F59E0B !important;
    --stbar-danger:     #DC2626 !important;
    --stbar-border:     #E5E7EB !important;
    --stbar-bg:         #F9FAFB !important;
    --stbar-dark:       #1F2937 !important;
    --stbar-gray:       #6B7280 !important;
    --stbar-radius:     12px;
    --stbar-shadow:     0 2px 12px rgba(0,0,0,0.08);
}

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.stbar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stbar-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.stbar-header-icon {
    width: 50px; height: 50px;
    background: #EEF2FF;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--stbar-primary);
    flex-shrink: 0;
}
.stbar-title {
    font-size: 22px; font-weight: 700;
    color: var(--stbar-dark); margin: 0 0 4px;
}
.stbar-subtitle {
    font-size: 13px; color: var(--stbar-gray); margin: 0;
}
.stbar-config-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 18px;
    background: #fff;
    border: 1.5px solid var(--stbar-border);
    border-radius: 8px;
    font-size: 14px; font-weight: 600; color: var(--stbar-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.stbar-config-btn:hover {
    background: #EEF2FF; border-color: var(--stbar-primary);
}

/* ── États chargement / vide ─────────────────────────────────────────────── */
.stbar-loading-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 60px 20px; color: var(--stbar-gray);
}
.stbar-dots {
    display: flex; gap: 8px; margin-bottom: 16px;
}
.stbar-dots span {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--stbar-primary); opacity: 0.3;
    animation: stbar-bounce 1.2s infinite ease-in-out;
}
.stbar-dots span:nth-child(2) { animation-delay: 0.2s; }
.stbar-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes stbar-bounce {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40%            { opacity: 1;   transform: scale(1.1); }
}
.stbar-empty-state {
    text-align: center; padding: 60px 20px; color: var(--stbar-gray);
}
.stbar-empty-icon { font-size: 48px; opacity: 0.4; margin-bottom: 16px; }
.stbar-empty-state h3 { color: var(--stbar-dark); margin: 0 0 8px; }
.stbar-loading-inline {
    display: flex; align-items: center; justify-content: center; padding: 40px;
}

/* ── Onglets serveuses ───────────────────────────────────────────────────── */
.stbar-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 16px;
    border-bottom: 2px solid var(--stbar-border) !important;
    margin-bottom: 20px;
}
.stbar-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 18px !important;
    border-radius: var(--stbar-radius) !important;
    border: 2px solid var(--stbar-border) !important;
    background: #fff !important;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 100px;
}
.stbar-tab:hover {
    border-color: var(--stbar-primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(42,78,181,0.12);
}
.stbar-tab-name {
    font-size: 14px; font-weight: 700; color: var(--stbar-dark) !important;
}
.stbar-tab-badge {
    font-size: 12px !important; font-weight: 700 !important;
    padding: 2px 10px !important;
    border-radius: 20px !important;
    background: #FEF3C7 !important; color: #92400E !important;
}

/* Couleurs d'état des onglets */
.stbar-tab-gray { border-color: #E5E7EB; background: #F9FAFB; }
.stbar-tab-gray .stbar-tab-name { color: #9CA3AF; }
.stbar-tab-orange { border-color: #FCD34D; background: #FFFBEB; }
.stbar-tab-orange .stbar-tab-badge { background: #FEF3C7; color: #92400E; }
.stbar-tab-green { border-color: #6EE7B7; background: #F0FDF4; }
.stbar-tab-green .stbar-tab-badge { background: #DCFCE7; color: #166534; }

/* Onglet actif */
.stbar-tab-active {
    border-color: var(--stbar-primary) !important;
    background: #EEF2FF !important;
    box-shadow: 0 0 0 3px rgba(42,78,181,0.12) !important;
}

/* ── Hint "sélectionner" ─────────────────────────────────────────────────── */
.stbar-select-hint {
    text-align: center;
    padding: 50px 20px;
    color: var(--stbar-gray);
    font-size: 15px;
}
.stbar-select-hint i { font-size: 32px; margin-bottom: 12px; display: block; opacity: 0.4; }

/* ── Barre de recherche produit ──────────────────────────────────────────── */
.stbar-search-bar {
    position: relative;
    margin-bottom: 16px !important;
    padding: 12px !important;
}
.stbar-search-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.stbar-search-icon {
    position: absolute; left: 12px; top: 50% !important;
    transform: translateY(-50%) !important;
    color: #9CA3AF !important; pointer-events: none;
}
.stbar-search-input {
    flex: 1;
    padding: 10px 36px 10px 36px !important;
    border: 1.5px solid var(--stbar-border) !important !important;
    border-radius: 8px !important;
    font-size: 15px !important; color: var(--stbar-dark) !important;
    transition: border-color 0.15s;
}
.stbar-search-input:focus {
    outline: none;
    border-color: var(--stbar-primary) !important;
    box-shadow: 0 0 0 3px rgba(42,78,181,0.08) !important;
}
.stbar-clear-btn, .stbar-scan-btn {
    background: none; border: none; cursor: pointer;
    padding: 6px 10px; border-radius: 6px;
    font-size: 16px; color: var(--stbar-gray);
    transition: background 0.15s;
}
.stbar-clear-btn { position: absolute; right: 50px; top: 50%; transform: translateY(-50%); }
.stbar-scan-btn { color: var(--stbar-primary); }
.stbar-scan-btn:hover { background: #EEF2FF; }

/* Résultats de recherche */
.stbar-search-results {
    position: absolute;
    left: 12px; right: 12px; top: calc(100% + 4px) !important;
    background: #fff !important;
    border: 1.5px solid var(--stbar-border) !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12) !important;
    z-index: 200 !important;
    max-height: 320px;
    overflow-y: auto;
}
.stbar-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #F3F4F6;
    transition: background 0.12s;
}
.stbar-result-item:last-child { border-bottom: none; }
.stbar-result-item:hover { background: #F9FAFB; }
.stbar-result-photo {
    width: 40px; height: 40px;
    border-radius: 6px; object-fit: cover;
    border: 1px solid var(--stbar-border); flex-shrink: 0;
}
.stbar-result-photo-empty {
    width: 40px; height: 40px;
    border-radius: 6px; background: #F3F4F6;
    border: 1px solid var(--stbar-border);
    display: flex; align-items: center; justify-content: center;
    color: #D1D5DB; font-size: 16px; flex-shrink: 0;
}
.stbar-result-info { display: flex; flex-direction: column; }
.stbar-result-titre { font-size: 14px; font-weight: 600; color: var(--stbar-dark); }
.stbar-result-prix { font-size: 12px; color: var(--stbar-primary); font-weight: 600; }
.stbar-no-results { padding: 16px; text-align: center; color: var(--stbar-gray); font-size: 14px; }

/* Zone de confirmation d'ajout */
.stbar-add-zone {
    margin-top: 12px;
    padding: 14px;
    background: #F0F4FF;
    border-radius: 10px;
    border: 1.5px solid #C7D7FF;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.stbar-add-product-info {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 180px;
}
.stbar-add-photo {
    width: 44px; height: 44px;
    border-radius: 6px; object-fit: cover;
    border: 1px solid var(--stbar-border);
}
.stbar-add-titre { font-size: 14px; font-weight: 700; color: var(--stbar-dark); }
.stbar-add-prix { font-size: 13px; color: var(--stbar-primary); }
.stbar-qty-wrap {
    display: flex; align-items: center; gap: 0;
    background: #fff; border-radius: 8px;
    border: 1.5px solid var(--stbar-border);
    overflow: hidden;
}
.stbar-qty-btn {
    background: none; border: none; cursor: pointer;
    width: 34px; height: 34px; font-size: 18px; font-weight: 700;
    color: var(--stbar-primary); display: flex; align-items: center; justify-content: center;
    transition: background 0.12s;
}
.stbar-qty-btn:hover { background: #EEF2FF; }
.stbar-qty-input {
    width: 48px; text-align: center; border: none;
    font-size: 15px; font-weight: 700; color: var(--stbar-dark);
    padding: 0;
}
.stbar-qty-input:focus { outline: none; }
.stbar-add-actions { display: flex; gap: 8px; }
.stbar-cancel-btn {
    padding: 8px 16px; border-radius: 7px;
    background: #fff; border: 1.5px solid var(--stbar-border);
    color: var(--stbar-gray); cursor: pointer; font-size: 13px;
    transition: all 0.12s;
}
.stbar-cancel-btn:hover { border-color: #9CA3AF; }
.stbar-confirm-add-btn {
    padding: 8px 18px; border-radius: 7px;
    background: var(--stbar-primary); border: none;
    color: #fff; cursor: pointer; font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 6px;
    transition: background 0.12s;
}
.stbar-confirm-add-btn:hover { background: #1e3d9a; }
.stbar-confirm-add-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Flux des lignes ─────────────────────────────────────────────────────── */
.stbar-lignes-container {
    margin-bottom: 16px;
    padding: 0 !important;
    overflow: hidden;
}
.stbar-lignes-list { display: flex; flex-direction: column; }
.stbar-lignes-empty {
    text-align: center; padding: 40px 20px;
    color: var(--stbar-gray);
}
.stbar-lignes-empty i { font-size: 32px; margin-bottom: 10px; display: block; opacity: 0.3; }

.stbar-ligne {
    display: grid;
    grid-template-columns: 28px 1fr auto auto auto;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--stbar-border);
    transition: background 0.12s;
}
.stbar-ligne:last-child { border-bottom: none; }
.stbar-ligne:hover { background: #FAFAFA; }

.stbar-ligne-pending { background: #FFFBEB; }
.stbar-ligne-confirmed { background: #fff; }
.stbar-ligne-encaissement { background: #F0FDF4 !important; }
.stbar-ligne-avance { background: #FFF7ED !important; }
.stbar-ligne-confirming { background: #F3F4F6; opacity: 0.6; }

.stbar-ligne-status { text-align: center; }
.stbar-pending-icon  { color: var(--stbar-warning); font-size: 15px; }
.stbar-confirmed-icon{ color: var(--stbar-success);  font-size: 15px; }
.stbar-enc-icon      { color: var(--stbar-success);  font-size: 15px; }
.stbar-avance-icon   { color: #EA580C; font-size: 15px; }

.stbar-ligne-info {
    display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.stbar-ligne-titre {
    font-size: 14px; font-weight: 600; color: var(--stbar-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stbar-ligne-detail { font-size: 12px; color: var(--stbar-gray); }
.stbar-enc-titre    { color: var(--stbar-success) !important; }
.stbar-avance-titre { color: #EA580C !important; }

.stbar-ligne-montant {
    font-size: 14px; font-weight: 700; color: var(--stbar-primary);
    white-space: nowrap; text-align: right;
}
.stbar-enc-montant    { color: var(--stbar-success) !important; }
.stbar-avance-montant { color: #EA580C !important; font-weight: 700; }

/* Hint dans le modal encaissement */
.stbar-enc-hint {
    display: block;
    background: #F3F4F6;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: #6B7280;
    line-height: 1.6;
}

.stbar-ligne-time {
    font-size: 11px; color: #9CA3AF; white-space: nowrap;
}

.stbar-ligne-actions { display: flex; align-items: center; }
.stbar-ligne-delete {
    background: none; border: none; cursor: pointer;
    color: #D1D5DB; padding: 4px 6px; border-radius: 6px;
    font-size: 13px; display: flex; align-items: center; gap: 4px;
    transition: all 0.12s;
}
.stbar-ligne-delete:hover { background: #FEE2E2; color: var(--stbar-danger); }
.stbar-countdown {
    font-size: 11px; color: var(--stbar-warning);
    font-weight: 700; min-width: 30px;
}

/* ── Pied de session ─────────────────────────────────────────────────────── */
.stbar-footer {
    padding: 16px !important;
}
.stbar-totaux {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.stbar-total-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    padding: 12px;
    background: var(--stbar-bg);
    border-radius: 10px;
    border: 1px solid var(--stbar-border);
}
.stbar-total-label {
    font-size: 12px; color: var(--stbar-gray); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.stbar-total-value {
    font-size: 16px; font-weight: 700; color: var(--stbar-dark);
}
.stbar-encaisse-color { color: var(--stbar-success) !important; }
.stbar-solde-item .stbar-total-label { color: var(--stbar-danger); }
.stbar-solde-value {
    font-size: 20px; font-weight: 800; color: var(--stbar-danger);
}
.stbar-solde-red { color: var(--stbar-danger) !important; }
.stbar-solde-green { color: var(--stbar-success) !important; }

.stbar-footer-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
}
.stbar-encaissement-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 8px;
    background: #F0FDF4; border: 1.5px solid #6EE7B7;
    color: var(--stbar-success); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.stbar-encaissement-btn:hover { background: #DCFCE7; }

.stbar-historique-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 8px;
    background: #fff; border: 1.5px solid var(--stbar-border);
    color: var(--stbar-gray); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.stbar-historique-btn:hover { border-color: var(--stbar-primary); color: var(--stbar-primary); }

.stbar-cloturer-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 8px;
    background: var(--stbar-primary); border: none;
    color: #fff; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: background 0.15s;
    margin-left: auto;
    box-shadow: 0 4px 12px rgba(42,78,181,0.3);
}
.stbar-cloturer-btn:hover { background: #1e3d9a; }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.stbar-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9998;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.stbar-modal {
    background: #fff; border-radius: 16px;
    width: 100%; max-width: 700px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
}
.stbar-modal-sm { max-width: 480px; }
.stbar-modal-xs { max-width: 380px; }
.stbar-modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--stbar-border);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.stbar-modal-header h2 {
    margin: 0; font-size: 17px; color: var(--stbar-dark);
    display: flex; align-items: center; gap: 10px;
}
.stbar-modal-close {
    background: none; border: none; font-size: 24px;
    cursor: pointer; color: #9CA3AF; line-height: 1; padding: 0;
}
.stbar-modal-close:hover { color: var(--stbar-dark); }
.stbar-modal-body {
    padding: 20px 22px; overflow-y: auto; flex: 1;
}
.stbar-modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--stbar-border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* Config serveuses */
.stbar-config-list { display: flex; flex-direction: column; gap: 8px; }
.stbar-config-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: var(--stbar-bg);
    border-radius: 8px;
    border: 1.5px solid var(--stbar-border);
    cursor: pointer;
    transition: border-color 0.12s;
}
.stbar-config-item:hover { border-color: var(--stbar-primary); }
.stbar-config-item input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; accent-color: var(--stbar-primary);
}
.stbar-config-nom {
    flex: 1; font-size: 14px; font-weight: 600; color: var(--stbar-dark);
}
.stbar-config-tel { font-size: 12px; color: var(--stbar-gray); }

/* Champs formulaire dans modals */
.stbar-field { margin-bottom: 14px; }
.stbar-field-label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--stbar-dark); margin-bottom: 5px;
}
.stbar-input {
    padding: 9px 12px;
    border: 1.5px solid var(--stbar-border);
    border-radius: 8px; font-size: 14px; color: var(--stbar-dark);
    transition: border-color 0.15s;
}
.stbar-input:focus {
    outline: none; border-color: var(--stbar-primary);
    box-shadow: 0 0 0 3px rgba(42,78,181,0.08);
}
.stbar-input-full { width: 100%; box-sizing: border-box; }
.stbar-input-lg { font-size: 22px; font-weight: 700; padding: 12px 14px; }

/* Modal clôture */
.stbar-cloture-summary {
    background: var(--stbar-bg);
    border-radius: 10px; padding: 16px;
    border: 1px solid var(--stbar-border);
    margin-bottom: 14px;
}
.stbar-summary-row {
    display: flex; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid #F3F4F6;
    font-size: 14px;
}
.stbar-summary-row:last-child { border-bottom: none; }
.stbar-summary-solde {
    margin-top: 8px; padding-top: 12px;
    border-top: 2px solid var(--stbar-border) !important;
    font-size: 16px; font-weight: 700;
}
.stbar-report-notice {
    background: #FEF3C7; border: 1px solid #FCD34D;
    border-radius: 8px; padding: 10px 14px;
    font-size: 13px; color: #92400E;
    display: flex; align-items: flex-start; gap: 8px;
}

/* Historique */
.stbar-hist-session {
    border: 1.5px solid var(--stbar-border);
    border-radius: 10px; margin-bottom: 14px; overflow: hidden;
}
.stbar-hist-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 12px 14px; background: var(--stbar-bg);
    border-bottom: 1px solid var(--stbar-border);
    gap: 12px; flex-wrap: wrap;
}
.stbar-hist-date { font-size: 13px; color: var(--stbar-gray); }
.stbar-hist-totaux { display: flex; gap: 12px; flex-wrap: wrap; }
.stbar-hist-vendu { font-size: 13px; font-weight: 600; color: var(--stbar-primary); }
.stbar-hist-enc { font-size: 13px; font-weight: 600; color: var(--stbar-success); }
.stbar-hist-reporte { font-size: 13px; font-weight: 600; color: var(--stbar-danger); }
.stbar-hist-lignes { padding: 8px 14px; }
.stbar-hist-ligne {
    display: flex; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid #F9FAFB;
    font-size: 13px; color: var(--stbar-dark);
}
.stbar-hist-ligne:last-child { border-bottom: none; }
.stbar-hist-enc-ligne { color: var(--stbar-success); }
.stbar-empty-hist { text-align: center; padding: 40px; color: var(--stbar-gray); }
.stbar-load-more-hist {
    display: block; width: 100%; padding: 10px;
    background: none; border: 1px solid var(--stbar-border);
    border-radius: 8px; color: var(--stbar-primary); font-size: 13px;
    cursor: pointer; margin-top: 8px; transition: background 0.12s;
}
.stbar-load-more-hist:hover { background: #EEF2FF; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.stbar-toast {
    position: fixed; top: 20px; right: 20px;
    z-index: 99999;
    padding: 12px 18px; border-radius: 10px;
    font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    max-width: 360px;
    color: #fff;
}
.stbar-toast-success { background: #065F46; }
.stbar-toast-error   { background: #7F1D1D; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media screen and (max-width: 768px) {
    .stbar-header { flex-direction: column; }
    .stbar-totaux { grid-template-columns: 1fr 1fr; }
    .stbar-solde-item { grid-column: 1 / -1; }
    .stbar-footer-actions { flex-direction: column; }
    .stbar-cloturer-btn { margin-left: 0; justify-content: center; }
    .stbar-ligne { grid-template-columns: 24px 1fr auto auto; }
    /*.stbar-ligne-time { display: none; }*/
    .stbar-add-zone { flex-direction: column; align-items: stretch; }
    .stbar-add-actions { justify-content: flex-end; }
    .stbar-toast { right: 10px; left: 10px; max-width: none; top: 10px; }
}

@media screen and (max-width: 480px) {
    .stbar-totaux { grid-template-columns: 1fr; }
    .stbar-solde-item { grid-column: auto; }
    .stbar-tabs { gap: 6px; }
    .stbar-tab { min-width: 80px; padding: 8px 12px; }
    .stbar-tab-name { font-size: 13px; }
}

/* ── Modal scanner ───────────────────────────────────────────────────────── */
#stbar-qr-reader {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    min-height: 260px;
}

/* Masquer les éléments parasites injectés par html5-qrcode */
#stbar-qr-reader > img,
#stbar-qr-reader__dashboard,
#stbar-qr-reader__header_message { display: none !important; }

#stbar-qr-reader video {
    width: 100% !important;
    border-radius: 10px;
    display: block;
}

#stbar-qr-reader__scan_region {
    border-radius: 10px;
    overflow: hidden;
}

#stbar-qr-reader__scan_region > img {
    display: none !important;
}
