/**
 * Digiterex Pré-vente - Moroccan B2B Distribution & Pre-sales System
 * Clean, Modern Pure Light Mode & Single-Color Minimalist Design
 */

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --border-color: #e2e8f0;
    --border-focus: #2563eb;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;

    --success: #059669;
    --success-light: #d1fae5;

    --warning: #d97706;
    --warning-light: #fef3c7;

    --danger: #dc2626;
    --danger-light: #fee2e2;

    --whatsapp: #16a34a;
    --whatsapp-hover: #15803d;

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --font-ar: 'Cairo', 'Readex Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-ar);
    background-color: var(--bg-main);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    padding-bottom: 90px;
    -webkit-user-select: none;
    user-select: none;
    /* No long-press copy/share popup on iOS */
    -webkit-touch-callout: none;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
    font-family: var(--font-ar);
}

/* Fields stay typeable/selectable despite body user-select: none */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

button {
    -webkit-appearance: none;
    appearance: none;
}

/* SVG Icon Helper */
.icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.icon-svg.sm {
    width: 14px;
    height: 14px;
}

.icon-svg.lg {
    width: 22px;
    height: 22px;
}

.icon-svg.xl {
    width: 28px;
    height: 28px;
}

/* ==========================================
   HEADER & ROLE BAR (FIXED HEIGHT, 1-LINE TITLE)
   ========================================== */
.app-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
    height: 64px;
    box-sizing: border-box;
}

.header-container {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    overflow: hidden;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.brand-logo svg {
    width: 26px;
    height: 26px;
    stroke: var(--primary);
}

.brand-titles {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.brand-titles h1 {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Inline Sync Status under Society Name */
.sync-status-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 3px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.sync-status-inline.online {
    color: #bbf7d0;
}

.sync-status-inline.offline {
    color: #fef08a;
}

.sync-status-inline.syncing {
    color: #ffffff;
}

.sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.sync-spinner {
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pending-tag {
    background: #f59e0b;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    margin-right: 4px;
}

/* Compact, Small & Clean User Profile Pill */
.user-profile-pill-compact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.32);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-profile-pill-compact:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.25);
}

.profile-avatar-mini {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.profile-details-mini {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-role-tag {
    font-size: 0.72rem;
    font-weight: 700;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.28);
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.profile-chevron {
    color: rgba(255, 255, 255, 0.85);
}

.icon-button {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-button:hover {
    background: #f8fafc;
    color: var(--text-main);
    border-color: var(--border-focus);
}

/* ==========================================
   ROLE NAVIGATION SEGMENTED TABS
   ========================================== */
.role-tabs-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 6px 16px;
    position: sticky;
    top: 60px;
    z-index: 90;
}

.role-tabs-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    background: #f1f5f9;
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.role-tabs-wrapper.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.role-tabs-wrapper.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
}

.role-tabs-wrapper.admin-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
}

@media (max-width: 768px) {
    .role-tabs-wrapper.admin-tabs {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .role-tabs-wrapper.admin-tabs::-webkit-scrollbar {
        display: none;
    }
    .role-tabs-wrapper.admin-tabs .tab-btn {
        flex: 0 0 auto;
        width: auto;
        min-width: 100px;
    }
}

.role-tabs-wrapper.scrollable {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.role-tabs-wrapper.scrollable::-webkit-scrollbar {
    display: none;
}

.role-tabs-wrapper.scrollable .tab-btn {
    flex: 0 0 auto;
    min-width: 100px;
}

.tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ar);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-align: center;
    width: 100%;
}

/* Default to showing short label on small screens */
.tab-label-full {
    display: none;
}
.tab-label-short {
    display: inline;
}

/* On larger screens, show the full label */
@media (min-width: 768px) {
    .tab-label-full {
        display: inline;
    }
    .tab-label-short {
        display: none;
    }
}

.tab-btn .icon-svg {
    stroke: var(--text-muted);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-btn.active .icon-svg {
    stroke: var(--primary);
}

.tab-badge {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 800;
}

.tab-btn.active .tab-badge {
    background: var(--primary);
    color: #ffffff;
}

@media (max-width: 640px) {
    .role-tabs-bar {
        padding: 5px 8px;
        top: 54px;
    }

    .tab-btn {
        padding: 7px 4px;
        font-size: 0.76rem;
        gap: 4px;
    }

    .tab-btn .icon-svg {
        width: 14px;
        height: 14px;
    }
}

/* ==========================================
   MAIN CONTAINER
   ========================================== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* ==========================================
   CATALOG / VENDEUR VIEW
   ========================================== */
.catalog-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
    justify-content: space-between;
}

.search-input-wrapper {
    flex: 1;
    min-width: 240px;
    position: relative;
}

.search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-ar);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

/* Catalog layout switch (phones only) */
.layout-toggle {
    display: none;
    flex-shrink: 0;
    gap: 2px;
    padding: 3px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.layout-toggle-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.layout-toggle-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.category-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    width: 100%;
    scrollbar-width: none;
}

.category-chip {
    font-family: var(--font-ar);
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.category-chip:hover,
.category-chip.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.product-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: var(--shadow-sm);
    position: relative;
}

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

.product-image-container {
    height: 160px;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image {
    transform: scale(1.04);
}

.stock-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.stock-tag.in-stock {
    background: #ffffff;
    color: var(--success);
    border: 1px solid var(--success);
}

.stock-tag.low-stock {
    background: #ffffff;
    color: var(--warning);
    border: 1px solid var(--warning);
}

.stock-tag.out-stock {
    background: #ffffff;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.product-details {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-category {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 4px;
}

.product-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 10px;
}

.product-pricing {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sell-price {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--primary);
}

.sell-price small {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.profit-badge {
    font-size: 0.7rem;
    background: var(--success-light);
    color: var(--success);
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
}

.product-card.in-cart {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.12);
}

.product-actions {
    display: flex;
    align-items: center;
    width: 100%;
}

.qty-stepper-full {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 3px;
    transition: all 0.2s ease;
}

.qty-stepper-full.has-qty {
    background: var(--primary-light);
    border-color: var(--border-focus);
}

.stepper-btn-full {
    width: 44px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stepper-btn-full.plus {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.stepper-btn-full.plus:hover {
    background: var(--primary-hover);
}

.stepper-btn-full.minus:hover {
    background: #e2e8f0;
}

.stepper-btn-full:active {
    transform: scale(0.94);
}

.stepper-value-full {
    /* Narrow on purpose: the empty space around it is a buffer so fast +/- taps don't open the keyboard */
    flex: 0 0 3.2em;
    width: 3.2em;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
    outline: none;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    -moz-appearance: textfield;
}

.stepper-value-full::-webkit-outer-spin-button,
.stepper-value-full::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Fast repeated taps on +/- must not zoom or select text */
.stepper-btn-full {
    touch-action: manipulation;
}

.qty-stepper-full.has-qty .stepper-value-full {
    color: var(--primary);
}

/* ==========================================
   STICKY BOTTOM CART DRAWER / BAR (TABLET & MOBILE)
   ========================================== */
.cart-floating-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

.cart-bar-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-icon-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-badge-bubble {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 999px;
    border: 2px solid #ffffff;
}

.cart-totals-text .cart-total-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cart-totals-text .cart-total-value {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--text-main);
}

.btn-checkout {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
    transition: transform 0.15s, background 0.2s;
}

.btn-checkout:hover {
    background: var(--primary-hover);
}

.btn-checkout:active {
    transform: scale(0.96);
}

/* Checkout Items List (Distributeur Style) */
.checkout-items-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 14px;
    background: #f8fafc;
}

.checkout-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.85rem;
    gap: 8px;
}

.checkout-item-row:last-child {
    border-bottom: none;
}

.checkout-price-input {
    width: 68px;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
    direction: ltr;
    background: #ffffff;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.checkout-price-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* ==========================================
   LIVREUR VIEW (DELIVERY TOURS & MAP)
   ========================================== */
.delivery-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.delivery-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.delivery-order-no {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
}

.delivery-status-pill {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-pending {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.status-delivering,
.status-assigned {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.status-delivered {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.status-cancelled,
.status-canceled {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.delivery-client-info {
    margin-bottom: 14px;
}

.delivery-client-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.delivery-client-address {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.delivery-amount-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-items-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.order-item-chip {
    font-size: 0.78rem;
    color: var(--text-main);
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}

.order-item-chip strong {
    color: var(--primary);
    font-weight: 800;
}

.delivery-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

/* Orders & Deliveries Grid (1 per row on mobile) */
.orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .orders-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
}

/* Clients Grid (1 per row on mobile) */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .clients-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
}

.btn-action-gps {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
    transition: all 0.15s ease;
}

.btn-action-gps:hover {
    background: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-action-gps:active {
    transform: scale(0.98);
}

.btn-action-deliver {
    background: #059669;
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(5, 150, 105, 0.25);
    transition: all 0.15s ease;
}

.btn-action-deliver:hover {
    background: #047857;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-action-deliver:active {
    transform: scale(0.98);
}

.btn-action-cancel {
    background: #ffffff;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-action-cancel:hover {
    background: var(--danger-light);
    transform: translateY(-1px);
}

.btn-action-cancel:active {
    transform: scale(0.98);
}

.btn-receipt-toggle {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-receipt-toggle:hover {
    background: #e2e8f0;
    color: var(--text-main);
}


.order-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-action-preview {
    background: #0284c7;
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(2, 132, 199, 0.25);
    transition: all 0.15s ease;
}

.btn-action-preview:hover {
    background: #0369a1;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-action-preview:active {
    transform: scale(0.98);
}

.btn-delete-fit {
    background: var(--danger-light);
    color: var(--danger);
    border: none;
    padding: 8px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-delete-fit:hover {
    background: var(--danger);
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-delete-fit:active {
    transform: scale(0.95);
}

/* Admin mobile order card: preview button fills the row, square trash beside it */
.order-admin-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.order-admin-actions .btn-delete-fit {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
}

/* Square trash button in order card action rows, pushed to the row end */
.order-card-actions .btn-delete-fit {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    align-self: center;
    margin-inline-start: auto;
}

.btn-action-print {
    background: #1e293b;
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(30, 41, 59, 0.25);
    transition: all 0.15s ease;
}

.btn-action-print:hover {
    background: #0f172a;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-action-print:active {
    transform: scale(0.98);
}

.btn-action-whatsapp {
    background: #25D366;
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(37, 211, 102, 0.25);
    transition: all 0.15s ease;
}

.btn-action-whatsapp:hover {
    background: #1eb956;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-action-whatsapp:active {
    transform: scale(0.98);
}

/* On-Screen Thermal Receipt Preview */
.receipt-preview-content {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04);
    max-height: 60vh;
    overflow-y: auto;
    font-family: var(--font-ar);
    color: #1e293b;
}

.receipt-preview-content .thermal-receipt {
    max-width: 100%;
    margin: 0 auto;
    font-size: 0.88rem;
    line-height: 1.4;
}

.receipt-preview-content .thermal-header {
    text-align: center;
    margin-bottom: 10px;
}

.receipt-preview-content .thermal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 2px;
}

.receipt-preview-content .thermal-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 1px 0;
}

.receipt-preview-content .thermal-divider {
    text-align: center;
    color: #cbd5e1;
    letter-spacing: 1px;
    margin: 6px 0;
    overflow: hidden;
    font-size: 0.75rem;
}

.receipt-preview-content .thermal-info {
    margin: 8px 0;
    font-size: 0.82rem;
}

.receipt-preview-content .thermal-info .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.receipt-preview-content .thermal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.82rem;
}

.receipt-preview-content .thermal-table th,
.receipt-preview-content .thermal-table td {
    padding: 5px 3px;
    border-bottom: 1px solid #f1f5f9;
}

.receipt-preview-content .thermal-table th {
    font-weight: 700;
    color: var(--text-muted);
}

.receipt-preview-content .thermal-totals {
    margin: 8px 0;
    font-size: 0.85rem;
}

.receipt-preview-content .thermal-totals .total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.receipt-preview-content .thermal-totals .net-to-pay {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary);
    border-top: 1px dashed #cbd5e1;
    border-bottom: 1px dashed #cbd5e1;
    padding: 6px 0;
    margin: 6px 0;
}

.receipt-preview-content .thermal-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    margin-bottom: 10px;
}

.receipt-preview-content .sig-box {
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px dotted #cbd5e1;
    padding-top: 4px;
    width: 45%;
    text-align: center;
}

.receipt-preview-content .thermal-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px;
}

/* ==========================================
   ADMIN VIEW (DASHBOARD & STOCK & TEAMS)
   ========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
}

.stat-info .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-info .stat-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text-main);
}

.data-table-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.table-header-bar {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}

.table-header-bar h3 {
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 0.85rem;
}

.styled-table th {
    background: #f8fafc;
    padding: 12px 16px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.styled-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.styled-table tr:hover td {
    background: #f8fafc;
}

/* ==========================================
   MODALS
   ========================================== */
body.modal-open {
    overflow: hidden !important;
    touch-action: none;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.modal-backdrop.active .modal-box {
    transform: scale(1);
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-ar);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

/* Checkout: type-ahead client picker */
.client-suggestions {
    display: none;
    margin-top: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
}

.client-suggestions.open {
    display: block;
}

.client-suggestion-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    font-family: var(--font-ar);
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
}

.client-suggestion-item:last-child {
    border-bottom: none;
}

.client-suggestion-item:hover,
.client-suggestion-item:active {
    background: var(--bg-card-hover);
}

.client-match-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.client-match-hint.existing {
    color: var(--success);
}

.client-match-hint.new {
    color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-gps-grab {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px dashed var(--primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    transition: all 0.2s;
}

.btn-gps-grab:hover {
    background: var(--primary);
    color: #ffffff;
}

/* GPS Status Card in Add Client Modal */
.gps-status-card {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.gps-status-card.idle {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.gps-status-card.loading {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.gps-status-card.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.gps-status-card.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.gps-coords-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #d1fae5;
    color: #047857;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

.btn-store-camera {
    background: #ffffff;
    color: var(--primary);
    border: 1px dashed var(--border-focus);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-ar);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    transition: all 0.2s;
}

.btn-store-camera:hover {
    background: var(--primary-light);
}

.btn-remove-photo {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(220, 38, 38, 0.9);
    color: #ffffff;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-ar);
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
}

.store-card-photo {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
}

.store-thumb-mini {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ==========================================
   FAST PIN KEYPAD MODAL
   ========================================== */
.pin-pad-container {
    text-align: center;
    padding: 10px 0;
}

.pin-dots-display {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 16px 0 24px;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: #ffffff;
    transition: all 0.2s;
}

.pin-dot.filled {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.15);
}

.pin-keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 280px;
    margin: 0 auto;
}

.pin-key-btn {
    height: 56px;
    border-radius: var(--radius-lg);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-ar);
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: background 0.15s, transform 0.1s;
}

.pin-key-btn:hover {
    background: #f1f5f9;
}

.pin-key-btn:active {
    background: var(--primary);
    color: #ffffff;
    transform: scale(0.95);
}

.pin-key-btn.key-action {
    font-size: 0.9rem;
    font-weight: 700;
    background: #ffffff;
    color: var(--danger);
    border-color: var(--border-color);
}

/* ==========================================
   MOBILE & TABLET RESPONSIVE (2 PER ROW)
   ========================================== */
@media (max-width: 640px) {
    .app-header {
        height: 56px;
    }

    .app-container {
        padding: 10px;
    }

    .header-container {
        padding: 0 10px;
    }

    .brand-section {
        gap: 8px;
    }

    .brand-logo {
        width: 36px;
        height: 36px;
    }

    .brand-logo svg {
        width: 20px;
        height: 20px;
    }

    .brand-titles h1 {
        font-size: 0.90rem;
    }

    .sync-status-inline {
        font-size: 0.68rem;
        margin-top: 1px;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .layout-toggle {
        display: flex;
    }

    .catalog-toolbar .search-input-wrapper {
        min-width: 0;
    }

    /* One product per row when the vendeur picks the single layout */
    .products-grid.layout-single {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .products-grid.layout-single .product-image-container {
        height: 170px;
    }

    .products-grid.layout-single .product-details {
        padding: 12px;
    }

    .products-grid.layout-single .product-title {
        font-size: 0.95rem;
        margin-bottom: 8px;
        min-height: 0;
        line-height: 1.3;
    }

    .products-grid.layout-single .sell-price {
        font-size: 1.2rem;
    }

    .products-grid.layout-single .sell-price small {
        font-size: 0.72rem;
    }

    .product-card {
        border-radius: var(--radius-md);
    }

    .product-image-container {
        height: 120px;
    }

    .product-details {
        padding: 10px 8px;
    }

    .product-title {
        font-size: 0.82rem;
        margin-bottom: 6px;
        min-height: 2.2em;
        line-height: 1.25;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .sell-price {
        font-size: 1.05rem;
    }

    .sell-price small {
        font-size: 0.65rem;
    }

    .stepper-btn-full {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .stepper-value-full {
        font-size: 0.95rem;
    }

    .stock-tag {
        top: 6px;
        right: 6px;
        padding: 2px 6px;
        font-size: 0.6rem;
    }
}

/* ==========================================
   TOAST NOTIFICATION (POPUP NOTICES)
   ========================================== */
.toast-notification {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #0f172a;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90vw;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast-notification.success {
    background: #065f46;
    border-color: #10b981;
}

.toast-notification.warning {
    background: #92400e;
    border-color: #f59e0b;
}

.toast-notification.error {
    background: #991b1b;
    border-color: #ef4444;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   58mm / 80mm THERMAL RECEIPT PRINT LAYOUT
   ========================================== */
#receiptPrintSection {
    display: none;
}

@media print {
    body > :not(#receiptPrintSection) {
        display: none !important;
    }

    #receiptPrintSection,
    #receiptPrintSection * {
        visibility: visible;
    }

    #receiptPrintSection {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 78mm;
        margin: 0;
        padding: 0;
        background: #ffffff;
        color: #000000;
        font-family: 'Courier New', Courier, monospace, var(--font-ar);
        direction: rtl;
        font-size: 11pt;
        line-height: 1.2;
    }

    .thermal-receipt {
        padding: 4mm;
    }

    .thermal-header {
        text-align: center;
        margin-bottom: 4mm;
    }

    .thermal-title {
        font-size: 14pt;
        font-weight: 900;
        margin-bottom: 2mm;
    }

    .thermal-sub {
        font-size: 9pt;
        margin: 1mm 0;
    }

    .thermal-divider {
        text-align: center;
        margin: 2mm 0;
        font-size: 8pt;
        overflow: hidden;
    }

    .thermal-info .info-row {
        display: flex;
        justify-content: space-between;
        font-size: 10pt;
        margin-bottom: 1.5mm;
    }

    .thermal-table {
        width: 100%;
        border-collapse: collapse;
        margin: 2mm 0;
    }

    .thermal-table th,
    .thermal-table td {
        padding: 1.5mm 0;
        font-size: 9pt;
    }

    .thermal-totals .total-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 1.5mm;
        font-size: 10pt;
    }

    .thermal-totals .net-to-pay {
        font-size: 12pt;
        font-weight: bold;
        border-top: 1px dashed #000;
        border-bottom: 1px dashed #000;
        padding: 2mm 0;
    }

    .thermal-signatures {
        display: flex;
        justify-content: space-between;
        margin-top: 6mm;
        margin-bottom: 6mm;
    }

    .sig-box {
        font-size: 8pt;
        border-top: 1px dotted #000;
        padding-top: 2mm;
        width: 45%;
        text-align: center;
    }

    .thermal-footer {
        text-align: center;
        font-size: 8pt;
        margin-top: 4mm;
    }
}

/* =========================================
   Filter Pills (Admin Orders & Stats)
   ========================================= */
.orders-filter-toolbar {
    display: flex;
    gap: 8px;
    padding: 0 0 16px 0;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 8px;
}
.orders-filter-toolbar::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    padding: 8px 16px;
    border-radius: 50px;
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-family: var(--font-ar);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.filter-pill:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.filter-pill.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* =========================================
   Responsive Views for Admin Tables/Cards
   ========================================= */
@media (max-width: 768px) {
    .stock-table-wrapper,
    .team-table-wrapper,
    .orders-table-wrapper {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .stock-cards-mobile,
    .team-cards-mobile,
    .orders-cards-mobile {
        display: none !important;
    }
}

/* ==========================================
   MOBILE CARDS (STOCK, ORDERS, TEAM)
   ========================================== */
.stock-cards-mobile,
.team-cards-mobile,
.orders-cards-mobile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 24px;
}

/* STOCK CARD */
.stock-product-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stock-product-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.stock-product-img-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: #f8fafc;
}
.stock-product-card-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.stock-product-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}
.stock-product-card-tags {
    display: flex;
    align-items: center;
    gap: 8px;
}
.stock-product-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
}
.stock-info-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}
.stock-info-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.stock-info-value {
    font-size: 0.85rem;
    color: var(--text-main);
}

/* ADMIN ORDER CARD */
.order-admin-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.order-admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.order-admin-card-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary);
    font-family: monospace;
}
.order-admin-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.order-admin-info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.order-admin-info-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 80px;
}
.order-admin-info-val {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: left;
    flex: 1;
}
.order-admin-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
    margin-top: 12px;
}

/* TEAM USER CARD */
.team-user-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.team-user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.team-user-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
}
.team-user-card-badges {
    display: flex;
    gap: 4px;
}
.team-user-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}
.team-user-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.team-user-info-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.team-user-info-val {
    font-size: 0.88rem;
    color: var(--text-main);
    font-weight: 700;
}


/* ==========================================
   ADMIN CLIENTS DIRECTORY (acl-*)
   ========================================== */
.acl-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.acl-sum-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: start;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.acl-sum-card.primary .acl-sum-value { color: #1d4ed8; }
.acl-sum-card.primary .acl-sum-value small { color: #3b82f6; }

.acl-sum-card.danger .acl-sum-value { color: #b91c1c; }
.acl-sum-card.danger .acl-sum-value small { color: #ef4444; }

.acl-sum-card.success .acl-sum-value { color: #15803d; }
.acl-sum-card.success .acl-sum-value small { color: #22c55e; }

.acl-sum-card.warning .acl-sum-value { color: #b45309; }

.acl-sum-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.acl-sum-value { font-size: 1.35rem; font-weight: 900; color: var(--text-main); white-space: nowrap; }
.acl-sum-value small { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-inline-start: 4px; }
.acl-summary.compact .acl-sum-value { font-size: 1.15rem; }
.acl-summary.compact .acl-sum-label { font-size: 0.7rem; }

.acl-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.acl-filters { display: flex; gap: 6px; }

.acl-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}
.acl-card {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.acl-card:hover { 
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.12), 0 6px 12px -4px rgba(0, 0, 0, 0.08); 
    transform: translateY(-2px); 
    border-color: #94a3b8;
}

.acl-card-main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 18px 20px;
    cursor: pointer;
}
.acl-avatar {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f1f5f9;
}
.acl-avatar-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    background: #eff6ff;
}
.acl-info { flex: 1; min-width: 0; }
.acl-name {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.acl-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.acl-meta span:not(:last-child)::after { content: '•'; margin-inline-start: 12px; color: #cbd5e1; }

.acl-debt-badge-red {
    background: var(--danger-light);
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
.acl-paid-badge {
    background: var(--success-light);
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.acl-actions {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}
.acl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    min-width: 42px;
    padding: 0 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.acl-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.acl-btn .icon-svg { width: 18px; height: 18px; margin: 0; }
.acl-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.acl-btn.primary:hover { filter: brightness(1.08); }
.acl-btn.primary .icon-svg { stroke: #fff; }
.acl-btn.disabled { color: var(--text-dim, #94a3b8); cursor: default; direction: rtl; justify-content: center; }

.acl-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}
.acl-empty .icon-svg { width: 40px; height: 40px; opacity: .4; }
.acl-empty p { margin-top: 8px; }

/* Client orders modal */
.acl-orders-title {
    font-weight: 800;
    font-size: 0.9rem;
    margin: 6px 0 8px;
    color: var(--text-main);
}
.acl-orders-list {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.acl-order-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
}
.acl-order-row:last-child { border-bottom: none; }
.acl-order-row.cancelled { opacity: .55; }
.acl-order-left { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.acl-order-left strong { font-size: 0.85rem; }
.acl-order-date { font-size: 0.72rem; color: var(--text-muted); }
.acl-order-right { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.acl-order-right strong { font-size: 0.85rem; }
.acl-rest { font-size: 0.72rem; color: var(--danger); font-weight: 700; }

@media (max-width: 600px) {
    .acl-summary { gap: 6px; }
    .acl-sum-card { padding: 10px; }
    .acl-sum-label { font-size: 0.68rem; }
    .acl-sum-value { font-size: 0.95rem; }
    .acl-list { grid-template-columns: 1fr; }
    .acl-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .acl-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
    .acl-filters .filter-pill { flex: 0 0 auto; padding: 6px 14px; font-size: 0.8rem; }
    .acl-order-row .delivery-status-pill { display: none; }
    .acl-name { font-size: 1.05rem; white-space: normal; }
    .acl-card-main { padding: 14px 12px; gap: 0; }
    .acl-avatar { width: 48px; height: 48px; border-radius: 10px; }
    .acl-avatar-letter { font-size: 1.4rem; }
    .acl-actions { flex-wrap: wrap; }
    .acl-btn { flex: 1; }
}

/* ==========================================
   FULL-SCREEN IMAGE VIEWER
   ========================================== */
img.zoomable {
    cursor: zoom-in;
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.92);
    cursor: zoom-out;
}

.image-viewer.open {
    display: flex;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.image-viewer-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

/* ==========================================
   ADMIN STOCK: FILTERS & CATEGORIES MODAL
   ========================================== */
.stock-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stock-filters .search-input-wrapper {
    min-width: 200px;
}

.stock-category-filter {
    width: auto;
    flex: 0 1 200px;
    min-width: 140px;
}

.category-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.category-add-row .btn-checkout {
    flex-shrink: 0;
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-row .form-control {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
}

.category-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.category-row-btn {
    flex-shrink: 0;
    height: 38px;
    padding: 0 12px;
}

.category-row .btn-delete-fit.category-row-btn {
    width: 38px;
    padding: 0;
}

/* Admin stock mobile card: edit fills the row, square delete beside it */
.stock-product-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Same dashed divider as above the price row */
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border-color);
}

.stock-product-card-actions .btn-action-preview {
    height: 40px;
}

.stock-product-card-actions .btn-delete-fit {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 0;
}

/* Product expiry date (expiryTag in app.js) */
.expiry-tag { display: inline-block; font-size: 0.7rem; font-weight: 700; color: var(--text-dim); }
.expiry-tag.soon { color: var(--warning); }
.expiry-tag.expired { color: var(--danger); }
