@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;
    --font-arabic: 'Tajawal', sans-serif;

    /* Palette Luxury Fashion (Myssitar) */
    --primary: #0F172A;
    --primary-hover: #1E293B;
    --gold: #C5A880;
    --gold-dark: #9E7D4E;
    --gold-light: #F7F3EB;
    
    --bg-main: #F8FAFC;
    --bg-card: #FFFFFF;
    --border-color: #E2E8F0;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    --success: #10B981;
    --success-bg: #ECFDF5;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --info: #3B82F6;
    --info-bg: #EFF6FF;

    --sidebar-w: 260px;
    --header-h: 70px;
}

body.dark {
    --bg-main: #090D16;
    --bg-card: #111827;
    --border-color: #1F2937;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --text-light: #6B7280;
    --gold-light: #1E1B15;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body {
    font-family: var(--font-arabic), var(--font-sans);
}

/* Typography */
h1, h2, h3, h4, .font-display {
    font-family: var(--font-display);
    font-weight: 700;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Layout Elements */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transition: all 0.2s ease;
}

[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    transition: margin-left 0.22s cubic-bezier(0.16, 1, 0.3, 1), margin-right 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-w);
}

/* Sidebar Toggle & Hide State */
.sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
    background: var(--bg-main);
    color: var(--text-main);
    border-color: #CBD5E1;
}

body.sidebar-hidden .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
}
[dir="rtl"] body.sidebar-hidden .sidebar {
    transform: translateX(100%);
}

body.sidebar-hidden .main-content {
    margin-left: 0 !important;
}
[dir="rtl"] body.sidebar-hidden .main-content {
    margin-right: 0 !important;
}

body.sidebar-hidden #sidebar-show-btn,
body.sidebar-hidden #navbar-brand-logo {
    display: inline-flex !important;
}

.top-navbar {
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.content-body {
    padding: 24px;
    flex: 1;
}

/* Navigation Links */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s ease;
    margin: 2px 12px;
}

.nav-link:hover {
    background: #F1F5F9;
    color: var(--text-main);
}

body.dark .nav-link:hover {
    background: #1F2937;
}

.nav-link.active {
    background: #0F172A;
    color: #FFFFFF;
}

body.dark .nav-link.active {
    background: #F3F4F6;
    color: #111827;
}

.nav-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    padding: 16px 24px 6px;
    font-weight: 600;
}

/* Cards & Containers */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    min-height: 42px;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
}

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

.btn-gold {
    background: linear-gradient(135deg, #C5A880 0%, #9E7D4E 100%);
    color: #FFFFFF;
}

.btn-gold:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #F1F5F9;
    color: #334155;
    border-color: #E2E8F0;
}

body.dark .btn-secondary {
    background: #1F2937;
    color: #E5E7EB;
    border-color: #374151;
}

.btn-success {
    background: var(--success);
    color: #FFFFFF;
}

.btn-danger {
    background: var(--danger);
    color: #FFFFFF;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
    min-height: 48px;
}

/* Touch Targets for POS */
.touch-btn {
    min-height: 48px;
    min-width: 48px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-main);
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
}

body.dark .table th {
    background: #1F2937;
}

[dir="rtl"] .table th {
    text-align: right;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table tr:hover td {
    background: #F8FAFC;
}

body.dark .table tr:hover td {
    background: #1E293B;
}

/* Badges & Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gold    { background: var(--gold-light); color: var(--gold-dark); }

/* Modals */
.modal-backdrop, .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1080;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    padding: max(12px, var(--safe-top, 0px)) max(12px, var(--safe-right, 0px)) max(12px, var(--safe-bottom, 0px)) max(12px, var(--safe-left, 0px));
}

.modal-backdrop.active, .modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: 16px;
    width: 92%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin: auto;
}

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

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

/* Premium Modal Close Button */
.modal-close,
.modal-header .btn-close,
.modal-header button.btn-close,
.modal-header button[onclick^="closeModal"]:not(.btn-primary):not(.btn-gold):not(.btn-danger) {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 1px solid #E2E8F0 !important;
    background: #F8FAFC !important;
    color: #64748B !important;
    cursor: pointer !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06) !important;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
    outline: none !important;
    flex-shrink: 0 !important;
    text-decoration: none !important;
    font-size: 18px !important;
    line-height: 1 !important;
}

.modal-close:hover,
.modal-header .btn-close:hover,
.modal-header button.btn-close:hover,
.modal-header button[onclick^="closeModal"]:not(.btn-primary):not(.btn-gold):not(.btn-danger):hover {
    background: #EEF2F6 !important;
    color: #0F172A !important;
    border-color: #CBD5E1 !important;
    transform: rotate(90deg) scale(1.08) !important;
    box-shadow: 0 4px 10px -2px rgba(15, 23, 42, 0.12) !important;
}

.modal-close:active,
.modal-header .btn-close:active,
.modal-header button.btn-close:active,
.modal-header button[onclick^="closeModal"]:not(.btn-primary):not(.btn-gold):not(.btn-danger):active {
    transform: rotate(90deg) scale(0.92) !important;
    background: #E2E8F0 !important;
}

.modal-close svg,
.modal-header .btn-close svg,
.modal-header button[onclick^="closeModal"] svg {
    display: block;
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    transition: stroke 0.2s ease;
}

/* Dark Modal Headers & Colored Headers (e.g. Navy, Amber, Gradients, Alert Red) */
.modal-header[style*="#0F172A"] .modal-close,
.modal-header[style*="#0F172A"] button[onclick^="closeModal"],
.modal-header[style*="#B45309"] .modal-close,
.modal-header[style*="#B45309"] button[onclick^="closeModal"],
.modal-header[style*="#78350F"] .modal-close,
.modal-header[style*="#78350F"] button[onclick^="closeModal"],
.modal-header[style*="#1E293B"] .modal-close,
.modal-header[style*="#1E293B"] button[onclick^="closeModal"],
.modal-header[style*="#090D16"] .modal-close,
.modal-header[style*="#090D16"] button[onclick^="closeModal"],
.modal-header[style*="#DC2626"] .modal-close,
.modal-header[style*="#DC2626"] button[onclick^="closeModal"],
.modal-header[style*="#991B1B"] .modal-close,
.modal-header[style*="#991B1B"] button[onclick^="closeModal"],
.modal-header[style*="linear-gradient"] .modal-close,
.modal-header[style*="linear-gradient"] button[onclick^="closeModal"],
.modal-close-dark,
.modal-close.dark {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-header[style*="#0F172A"] .modal-close:hover,
.modal-header[style*="#0F172A"] button[onclick^="closeModal"]:hover,
.modal-header[style*="#B45309"] .modal-close:hover,
.modal-header[style*="#B45309"] button[onclick^="closeModal"]:hover,
.modal-header[style*="#78350F"] .modal-close:hover,
.modal-header[style*="#78350F"] button[onclick^="closeModal"]:hover,
.modal-header[style*="#1E293B"] .modal-close:hover,
.modal-header[style*="#1E293B"] button[onclick^="closeModal"]:hover,
.modal-header[style*="#090D16"] .modal-close:hover,
.modal-header[style*="#090D16"] button[onclick^="closeModal"]:hover,
.modal-header[style*="#DC2626"] .modal-close:hover,
.modal-header[style*="#DC2626"] button[onclick^="closeModal"]:hover,
.modal-header[style*="#991B1B"] .modal-close:hover,
.modal-header[style*="#991B1B"] button[onclick^="closeModal"]:hover,
.modal-header[style*="linear-gradient"] .modal-close:hover,
.modal-header[style*="linear-gradient"] button[onclick^="closeModal"]:hover,
.modal-close-dark:hover,
.modal-close.dark:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    color: #FFFFFF !important;
    transform: rotate(90deg) scale(1.08) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

.modal-header[style*="#0F172A"] .modal-close:active,
.modal-header[style*="#0F172A"] button[onclick^="closeModal"]:active,
.modal-header[style*="#B45309"] .modal-close:active,
.modal-header[style*="#B45309"] button[onclick^="closeModal"]:active,
.modal-header[style*="#78350F"] .modal-close:active,
.modal-header[style*="#78350F"] button[onclick^="closeModal"]:active,
.modal-header[style*="linear-gradient"] .modal-close:active,
.modal-header[style*="linear-gradient"] button[onclick^="closeModal"]:active,
.modal-close-dark:active,
.modal-close.dark:active {
    background: rgba(255, 255, 255, 0.22) !important;
    transform: rotate(90deg) scale(0.92) !important;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: calc(72px + var(--safe-top, 0px));
    right: max(16px, var(--safe-right, 0px));
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

[dir="rtl"] #toast-container {
    right: auto;
    left: max(16px, var(--safe-left, 0px));
}

.toast {
    pointer-events: auto;
    background: #0F172A;
    color: #FFFFFF;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 12px 30px -4px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    font-weight: 600;
    min-width: 260px;
    max-width: 100%;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255,255,255,0.12);
    word-break: break-word;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error   { border-left: 4px solid var(--danger); }
.toast.toast-warning { border-left: 4px solid var(--warning); }
.toast.toast-info    { border-left: 4px solid var(--gold); }

@media (max-width: 768px) {
    #toast-container {
        top: calc(68px + var(--safe-top, 0px));
        left: 16px;
        right: 16px;
        align-items: center;
        max-width: none;
    }
    .toast {
        width: 100%;
        max-width: 480px;
    }
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Grid helper utilities */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }

/* POS Category Cards Navigation (Category-First Flow) */
.pos-cat-card {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    user-select: none;
    -webkit-user-select: none;
}
.pos-cat-card:hover {
    transform: translateY(-4px) !important;
    border-color: var(--gold) !important;
    box-shadow: 0 12px 20px -3px rgba(15, 23, 42, 0.09), 0 4px 6px -2px rgba(15, 23, 42, 0.04) !important;
}
.pos-cat-card:active {
    transform: scale(0.97) !important;
}

.quick-cat-pill {
    transition: all 0.15s ease;
}
.quick-cat-pill.active {
    background: #0F172A !important;
    color: #FFFFFF !important;
    border-color: #0F172A !important;
    font-weight: 700 !important;
}

/* POS Product Grid & Responsive Cards */
#product-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    grid-auto-rows: max-content !important;
    gap: 14px !important;
    align-content: start !important;
    overflow-y: auto !important;
}

.pos-product-card {
    height: 100% !important;
    box-sizing: border-box !important;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

.pos-product-card:hover {
    transform: translateY(-2px) !important;
    border-color: var(--gold) !important;
    box-shadow: 0 8px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04) !important;
}

.pos-product-card:active {
    transform: scale(0.98) !important;
}

/* POS Stock Request Modal Stepper & Quick Chips (Option B) */
.btn-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1.5px solid #CBD5E1;
    background: #F8FAFC;
    color: #0F172A;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-stepper:hover:not(:disabled) {
    background: #E2E8F0;
    border-color: #94A3B8;
    transform: translateY(-1px);
}
.btn-stepper:active:not(:disabled) {
    background: #CBD5E1;
    transform: scale(0.95);
}
.btn-stepper:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #F1F5F9;
    border-color: #E2E8F0;
    transform: none;
}

.sr-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid #CBD5E1;
    background: #FFFFFF;
    color: #334155;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.15s ease;
}
.sr-chip:hover {
    border-color: #6366F1;
    color: #4F46E5;
    background: #EEF2FF;
    transform: translateY(-1px);
}
.sr-chip:active {
    transform: scale(0.96);
}
.sr-chip.active {
    background: #4F46E5 !important;
    color: #FFFFFF !important;
    border-color: #4F46E5 !important;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}
.sr-chip-max {
    border-color: #F59E0B;
    background: #FFFBEB;
    color: #B45309;
}
.sr-chip-max:hover {
    border-color: #D97706;
    background: #FEF3C7;
    color: #92400E;
}
.sr-chip-max.active {
    background: #D97706 !important;
    color: #FFFFFF !important;
    border-color: #D97706 !important;
}

/* ==========================================================================
   DISPLAY SIZING & ACCESSIBILITY (POS & GLOBAL APP SCALING)
   ========================================================================== */

:root {
    --pos-scale: 1;
    --pos-font-scale: 1;
    --pos-base-font: 14px;
    --pos-card-title-size: 13.5px;
    --pos-card-price-size: 15px;
    --pos-cart-title-size: 13.5px;
    --pos-cart-price-size: 14px;
    --pos-cart-btn-size: 32px;
    --pos-cat-title-size: 13.5px;
    --pos-cat-icon-size: 26px;
    --pos-input-height: 40px;
    --pos-input-font: 14px;
    --pos-cart-width: 420px;
    --pos-total-size: 24px;
    --pos-pay-btn-size: 18px;
    --app-base-font: 14px;
}

/* 1. Normal (100% - Default) */
body[data-pos-size="normal"],
html[data-pos-size="normal"] {
    --pos-scale: 1;
    --pos-font-scale: 1;
    --pos-base-font: 14px;
    --pos-card-title-size: 13.5px;
    --pos-card-price-size: 15px;
    --pos-cart-title-size: 13.5px;
    --pos-cart-price-size: 14px;
    --pos-cart-btn-size: 32px;
    --pos-cat-title-size: 13.5px;
    --pos-cat-icon-size: 26px;
    --pos-input-height: 40px;
    --pos-input-font: 14px;
    --pos-cart-width: 420px;
    --pos-total-size: 24px;
    --pos-pay-btn-size: 18px;
}

/* 2. Medium (112% - Confortable) */
body[data-pos-size="medium"],
html[data-pos-size="medium"] {
    --pos-scale: 1.12;
    --pos-font-scale: 1.12;
    --pos-base-font: 15.5px;
    --pos-card-title-size: 15px;
    --pos-card-price-size: 17px;
    --pos-cart-title-size: 15px;
    --pos-cart-price-size: 15.5px;
    --pos-cart-btn-size: 36px;
    --pos-cat-title-size: 15px;
    --pos-cat-icon-size: 30px;
    --pos-input-height: 44px;
    --pos-input-font: 15px;
    --pos-cart-width: 450px;
    --pos-total-size: 28px;
    --pos-pay-btn-size: 20px;
}

/* 3. Large (125% - Grand Tactile / Recommandé POS) */
body[data-pos-size="large"],
html[data-pos-size="large"] {
    --pos-scale: 1.25;
    --pos-font-scale: 1.25;
    --pos-base-font: 17px;
    --pos-card-title-size: 16.5px;
    --pos-card-price-size: 19px;
    --pos-cart-title-size: 16.5px;
    --pos-cart-price-size: 17.5px;
    --pos-cart-btn-size: 40px;
    --pos-cat-title-size: 16.5px;
    --pos-cat-icon-size: 34px;
    --pos-input-height: 48px;
    --pos-input-font: 16.5px;
    --pos-cart-width: 480px;
    --pos-total-size: 32px;
    --pos-pay-btn-size: 22px;
}

/* 4. Extra Large (140% - Très Grand / Haute Visibilité) */
body[data-pos-size="xlarge"],
html[data-pos-size="xlarge"] {
    --pos-scale: 1.40;
    --pos-font-scale: 1.40;
    --pos-base-font: 18.5px;
    --pos-card-title-size: 18.5px;
    --pos-card-price-size: 21px;
    --pos-cart-title-size: 18.5px;
    --pos-cart-price-size: 19.5px;
    --pos-cart-btn-size: 46px;
    --pos-cat-title-size: 18.5px;
    --pos-cat-icon-size: 38px;
    --pos-input-height: 52px;
    --pos-input-font: 18px;
    --pos-cart-width: 520px;
    --pos-total-size: 36px;
    --pos-pay-btn-size: 24px;
}

/* Global App Font Scaling */
body[data-app-size="medium"],
.app-wrapper[data-app-size="medium"] {
    font-size: 15px;
    --app-base-font: 15px;
}
body[data-app-size="large"],
.app-wrapper[data-app-size="large"] {
    font-size: 16.5px;
    --app-base-font: 16.5px;
}

/* Specific POS Element Overrides according to active scale */
body[data-pos-size] {
    font-size: var(--pos-base-font);
}
body[data-pos-size] #pos-cart-sidebar,
body[data-pos-size] .pos-cart-sidebar {
    width: var(--pos-cart-width) !important;
}
body[data-pos-size] .pos-product-card h4,
body[data-pos-size] .pos-product-card .pos-product-title {
    font-size: var(--pos-card-title-size) !important;
}
body[data-pos-size] .pos-product-card .pos-product-price {
    font-size: var(--pos-card-price-size) !important;
}
body[data-pos-size] .pos-product-card .pos-stock-pill-local,
body[data-pos-size] .pos-product-card .pos-stock-pill-online {
    font-size: calc(var(--pos-font-scale) * 11px) !important;
    line-height: 1.2 !important;
}
body[data-pos-size] .pos-product-card {
    height: 100% !important;
}
body[data-pos-size] .pos-cat-card > div:nth-child(2),
body[data-pos-size] .pos-cat-card .pos-cat-title {
    font-size: var(--pos-cat-title-size) !important;
}
body[data-pos-size] .pos-cat-card > div:first-child,
body[data-pos-size] .pos-cat-card > div[style*="border-radius:14px"] {
    font-size: var(--pos-cat-icon-size) !important;
}
body[data-pos-size] .pos-cat-card span {
    font-size: calc(var(--pos-font-scale) * 11.5px) !important;
}
body[data-pos-size] #pos-barcode-input,
body[data-pos-size] #pos-search-input {
    height: var(--pos-input-height) !important;
    font-size: var(--pos-input-font) !important;
}
body[data-pos-size] .quick-cat-pill {
    font-size: calc(var(--pos-font-scale) * 11.5px) !important;
    padding: calc(var(--pos-font-scale) * 4px) calc(var(--pos-font-scale) * 10px) !important;
}
body[data-pos-size] .size-pill {
    font-size: calc(var(--pos-font-scale) * 11px) !important;
    padding: calc(var(--pos-font-scale) * 4px) calc(var(--pos-font-scale) * 10px) !important;
    min-height: calc(var(--pos-font-scale) * 26px) !important;
}
body[data-pos-size] .color-pill {
    width: calc(var(--pos-font-scale) * 22px) !important;
    height: calc(var(--pos-font-scale) * 22px) !important;
}
body[data-pos-size] .cart-item-row h5 {
    font-size: var(--pos-cart-title-size) !important;
}
body[data-pos-size] .cart-item-row div > div > span:last-child {
    font-size: var(--pos-cart-price-size) !important;
}
body[data-pos-size] .cart-item-row button.touch-btn {
    width: var(--pos-cart-btn-size) !important;
    height: var(--pos-cart-btn-size) !important;
    min-width: var(--pos-cart-btn-size) !important;
    min-height: var(--pos-cart-btn-size) !important;
    font-size: calc(var(--pos-font-scale) * 16px) !important;
}
body[data-pos-size] .cart-item-row input[type="number"] {
    width: calc(var(--pos-cart-btn-size) * 1.25) !important;
    height: var(--pos-cart-btn-size) !important;
    font-size: calc(var(--pos-font-scale) * 14px) !important;
}
body[data-pos-size] #cart-grand-total {
    font-size: var(--pos-total-size) !important;
}
body[data-pos-size] #cart-pay-button {
    font-size: var(--pos-pay-btn-size) !important;
    padding: calc(var(--pos-font-scale) * 15px) !important;
}
body[data-pos-size] #cart-pay-button span {
    font-size: var(--pos-pay-btn-size) !important;
}
body[data-pos-size] #selected-customer-name {
    font-size: calc(var(--pos-font-scale) * 14px) !important;
}
body[data-pos-size] #pos-current-cat-title {
    font-size: calc(var(--pos-font-scale) * 14px) !important;
}

/* Quick Font Size Switcher in POS Navigation */
.pos-font-size-switcher {
    display: inline-flex;
    align-items: center;
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}
.btn-pos-scale {
    background: transparent;
    border: none;
    color: #94A3B8;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.2;
}
.btn-pos-scale:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.08);
}
.btn-pos-scale.active {
    background: #C5A880 !important;
    color: #0F172A !important;
    font-weight: 800 !important;
}

/* Interactive Size Selector Cards (in Settings) */
.size-choice-card {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
}
.size-choice-card:hover {
    border-color: #C5A880;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}
.size-choice-card.active {
    border-color: #C5A880 !important;
    background: linear-gradient(135deg, #FFFDF9 0%, #FAF6EE 100%) !important;
    box-shadow: 0 6px 18px rgba(197, 168, 128, 0.25) !important;
}
.size-choice-card.active .size-check-badge {
    display: flex !important;
}
.size-check-badge {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #C5A880;
    color: #FFFFFF;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
}

/* ==========================================================================
   IPAD & IOS FULLSCREEN STANDALONE (PWA) OPTIMIZATIONS
   ========================================================================== */

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Enable smooth scrolling & prevent tap delay on touchscreens */
html, body {
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
}

/* iOS Standalone Mode / iPad Fullscreen adjustments */
@media all and (display-mode: standalone), (display-mode: fullscreen) {
    body.pos-body,
    body[data-pos-size] {
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
        padding-left: var(--safe-left);
        padding-right: var(--safe-right);
    }
    header.pos-header {
        padding-top: var(--safe-top) !important;
        height: calc(62px + var(--safe-top)) !important;
    }
}

body.ios-standalone header.pos-header {
    padding-top: var(--safe-top) !important;
    height: calc(62px + var(--safe-top)) !important;
}



