/* MagazaSatis - Premium SaaS UI Design System (shadcn/ui inspired) */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Light Mode Tokens (Zinc/Slate base) */
    --background: #f8fafc;
    --foreground: #09090b;
    --card: #ffffff;
    --card-foreground: #09090b;
    --popover: #ffffff;
    --popover-foreground: #09090b;
    --primary: #09090b;
    --primary-foreground: #fafafa;
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --accent: #f8fafc;
    --accent-foreground: #0f172a;
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #09090b;

    /* Brand accents (Strictly Neutral & Emerald - No Purple) */
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;

    --radius: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
}

[data-theme="dark"] {
    /* Dark Mode Tokens (Deep neutral/zinc surfaces) */
    --background: #09090b;
    --foreground: #f4f4f5;
    --card: #121215;
    --card-foreground: #f4f4f5;
    --popover: #121215;
    --popover-foreground: #f4f4f5;
    --primary: #f4f4f5;
    --primary-foreground: #09090b;
    --secondary: #1e1e24;
    --secondary-foreground: #f4f4f5;
    --muted: #1a1a20;
    --muted-foreground: #94a3b8;
    --accent: #1e1e24;
    --accent-foreground: #f4f4f5;
    --destructive: #7f1d1d;
    --destructive-foreground: #fef2f2;
    --border: #27272a;
    --input: #27272a;
    --ring: #d4d4d8;

    --emerald-50: #064e3b;
    --emerald-100: #065f46;
    --emerald-500: #10b981;
    --emerald-600: #34d399;
    --emerald-700: #6ee7b7;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border-color: var(--border);
}

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

/* Header & Nav */
.app-header {
    height: 64px;
    background-color: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo-wrap {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.brand-logo-img {
    height: 38px;
    max-width: 175px;
    object-fit: contain;
    display: block;
}

[data-theme="dark"] .brand-logo-wrap {
    background-color: #ffffff;
    padding: 4px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: var(--primary);
    color: var(--primary-foreground);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-title .badge-app {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--secondary);
    color: var(--secondary-foreground);
    font-weight: 600;
    text-transform: uppercase;
}

.sync-meta-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11.5px;
    line-height: 1.25;
}

.sync-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted-foreground);
    white-space: nowrap;
}

.sync-meta-label {
    font-weight: 500;
    color: var(--muted-foreground);
}

.sync-meta-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--foreground);
    letter-spacing: -0.2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons (shadcn style) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    user-select: none;
    white-space: nowrap;
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.btn-lg {
    height: 44px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}
.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    border-color: var(--border);
}
.btn-secondary:hover {
    background-color: var(--border);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--foreground);
}
.btn-outline:hover {
    background-color: var(--muted);
}

.btn-ghost {
    background-color: transparent;
    color: var(--foreground);
}
.btn-ghost:hover {
    background-color: var(--muted);
}

.btn-emerald {
    background-color: #059669;
    color: #ffffff;
}
.btn-emerald:hover {
    background-color: #047857;
}

.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}
.btn-destructive:hover {
    opacity: 0.9;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.badge-default {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.badge-success {
    background: var(--emerald-50);
    color: var(--emerald-600);
    border-color: var(--emerald-500);
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
}
[data-theme="dark"] .badge-warning {
    background: #78350f;
    color: #fde68a;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}
[data-theme="dark"] .badge-danger {
    background: #7f1d1d;
    color: #fca5a5;
}

/* Layout */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 440px;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 64px);
}

@media (max-width: 1080px) {
    .pos-layout {
        grid-template-columns: 1fr 380px;
    }
}

@media (max-width: 860px) {
    .pos-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    .pos-cart-panel {
        border-left: none !important;
        border-top: 1px solid var(--border);
        height: auto;
        max-height: none;
        position: relative;
        top: 0;
    }
    .cart-summary-section {
        position: sticky;
        bottom: 0;
        z-index: 35;
        box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.12);
        border-top: 2px solid var(--border);
    }
}

/* Products Section (Left) */
.pos-products-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    max-height: calc(100vh - 64px);
    background-color: var(--background);
}

.products-toolbar {
    background-color: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.search-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Quick Barcode Scanner Box (Visual Highlight) */
.barcode-box-wrapper {
    flex: 1.2;
    position: relative;
}

.barcode-input {
    width: 100%;
    height: 44px;
    background-color: var(--secondary);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 0 40px 0 38px;
    font-size: 14px;
    font-family: var(--font-mono);
    color: var(--foreground);
    outline: none;
    transition: all 0.2s ease;
}

.barcode-input:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    border-color: var(--emerald-500);
}

.barcode-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    pointer-events: none;
}

.search-box-wrapper {
    flex: 2;
    position: relative;
}

.search-input {
    width: 100%;
    height: 44px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 16px 0 38px;
    font-size: 14px;
    color: var(--foreground);
    outline: none;
    transition: all 0.15s ease;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--border);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    pointer-events: none;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
}

.select-filter {
    height: 32px;
    padding: 0 10px;
    border-radius: var(--radius);
    background-color: var(--card);
    border: 1px solid var(--border);
    color: var(--foreground);
    font-size: 12px;
    outline: none;
    cursor: pointer;
    max-width: 180px;
}

.toggle-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--muted-foreground);
    user-select: none;
}

.view-toggle-group {
    margin-left: auto;
    display: flex;
    background-color: var(--secondary);
    border-radius: var(--radius);
    padding: 2px;
}

.view-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
}

.view-btn.active {
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
}

/* Products Content Scrollable Area */
.products-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

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

.product-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.15s ease;
    position: relative;
    box-shadow: var(--shadow-sm);
}

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

.card-img-wrap {
    height: 140px;
    background-color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.card-img-wrap img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.product-card:hover .card-img-wrap img {
    transform: scale(1.05);
}

/* Out of Stock Card & Blur Styles */
.product-card.is-out-of-stock {
    border-color: rgba(239, 68, 68, 0.25);
    background-color: var(--card);
}

.product-card.is-out-of-stock:hover {
    transform: none;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: var(--shadow-sm);
}

.product-card.is-out-of-stock .card-img-wrap img,
.img-blurred {
    filter: none;
    opacity: 0.95;
    transform: none;
}

.out-of-stock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

[data-theme="dark"] .out-of-stock-overlay {
    background: rgba(0, 0, 0, 0.25);
}

.out-of-stock-badge-center {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 9999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.95);
    user-select: none;
}

[data-theme="dark"] .out-of-stock-badge-center {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* Table View Out of Stock Thumbnail */
.table-img-wrap {
    width: 42px;
    height: 42px;
    background: var(--secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

.table-img-wrap.is-out-of-stock img {
    filter: none;
    opacity: 0.95;
}

.table-stock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
}

[data-theme="dark"] .table-stock-overlay {
    background: rgba(0, 0, 0, 0.25);
}

.table-stock-pill {
    background: #ef4444;
    color: #ffffff;
    font-size: 8px;
    font-weight: 800;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-brand {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    margin: 4px 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 35px;
}

.card-codes {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted-foreground);
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.card-code-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-code-row span {
    white-space: nowrap;
}

.card-code-row .code-val {
    color: var(--foreground);
    font-weight: 600;
}

.card-gtin-row {
    padding-top: 2px;
    border-top: 1px dashed var(--border);
    color: var(--emerald-700);
}

.card-gtin-row .code-val {
    color: var(--emerald-700);
}

.table-gtin-val {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--emerald-600);
    margin-top: 2px;
}

.card-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-pricing {
    display: flex;
    flex-direction: column;
}

.orig-price {
    font-size: 11px;
    color: var(--muted-foreground);
    text-decoration: line-through;
}

.card-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--foreground);
}

.cash-price-preview {
    font-size: 11px;
    font-weight: 600;
    color: var(--emerald-600);
}

/* Table View */
.products-table-wrap {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

table.products-table th {
    background: var(--secondary);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

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

table.products-table tr:hover td {
    background-color: var(--accent);
}

/* Cart Panel (Right) */
.pos-cart-panel {
    background-color: var(--card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.02);
}

.cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cart-header h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Customer Card */
.cart-customer-section {
    padding: 12px 20px;
    background-color: var(--secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.customer-quick-fill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.customer-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.input-sm {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: var(--radius);
    background-color: var(--card);
    border: 1px solid var(--border);
    color: var(--foreground);
    outline: none;
    width: 100%;
}

.input-sm:focus {
    border-color: var(--primary);
}

/* Cart Items List */
.cart-items-scroll {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    text-align: center;
    color: var(--muted-foreground);
}

.cart-empty-state svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.cart-item {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    transition: border-color 0.15s ease;
}

.cart-item:hover {
    border-color: var(--muted-foreground);
}

.cart-item-thumb {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 6px;
    background-color: var(--card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.cart-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.item-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.item-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

.item-sku {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--muted-foreground);
}

.item-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.item-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}

.qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--foreground);
    font-size: 14px;
    font-weight: 600;
}

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

.qty-input {
    width: 36px;
    height: 28px;
    text-align: center;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 13px;
    color: var(--foreground);
    outline: none;
}

.item-price-col {
    text-align: right;
}

.item-unit-price {
    font-size: 11px;
    color: var(--muted-foreground);
}

.item-row-total {
    font-size: 14px;
    font-weight: 700;
    color: var(--foreground);
}

/* Dual Payment Calculations (Highlight of the app) */
.cart-summary-section {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background-color: var(--card);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    bottom: 0;
    z-index: 25;
    flex-shrink: 0;
    margin-top: auto;
    box-shadow: 0 -4px 12px -2px rgba(0, 0, 0, 0.06);
}

.price-card-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.price-box {
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.price-box-card {
    background-color: var(--secondary);
    border: 1px solid var(--border);
}

.price-box-card .box-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--foreground);
}

.price-box-card .box-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--foreground);
}

/* Highlighted Cash / Transfer Card */
.price-box-cash {
    background-color: var(--emerald-50);
    border: 1.5px solid var(--emerald-500);
}

.price-box-cash .box-label {
    display: flex;
    flex-direction: column;
}

.price-box-cash .box-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--emerald-700);
}

.price-box-cash .discount-pill {
    font-size: 11px;
    font-weight: 600;
    color: var(--emerald-600);
    margin-top: 2px;
}

.price-box-cash .box-amount {
    font-size: 20px;
    font-weight: 800;
    color: var(--emerald-700);
}

/* Action Buttons */
.cart-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Modals / Dialogs */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

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

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

.modal-backdrop.open .modal-content {
    transform: scale(1);
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: var(--secondary);
}

/* Form controls inside modal */
.form-group {
    margin-bottom: 14px;
}

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

.form-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius);
    background-color: var(--background);
    border: 1px solid var(--border);
    color: var(--foreground);
    font-size: 13px;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 380px;
}

.toast {
    background-color: var(--card);
    color: var(--foreground);
    border: 1px solid var(--border);
    padding: 12px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    pointer-events: auto;
    animation: toastSlideIn 0.25s ease-out;
}

.toast-success {
    border-left: 4px solid var(--emerald-500);
}

.toast-error {
    border-left: 4px solid var(--destructive);
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

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

/* Pulse animation for scanner */
@keyframes scannerPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.scanner-beep-active {
    animation: scannerPulse 0.4s ease-out;
}

/* Ticimax Transfer Modal Styles */
.transfer-choice-card {
    width: 100%;
    background-color: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    display: block;
}

.transfer-choice-card:hover {
    border-color: var(--muted-foreground);
    background-color: var(--secondary);
    transform: translateY(-1px);
}

.transfer-choice-card:active {
    transform: translateY(0);
}

.transfer-choice-card.transfer-choice-highlight {
    border-color: var(--emerald-500);
    background-color: var(--emerald-50);
}

.transfer-choice-card.transfer-choice-highlight:hover {
    background-color: #ecfdf5;
    border-color: var(--emerald-600);
}

[data-theme="dark"] .transfer-choice-card.transfer-choice-highlight {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: var(--emerald-600);
}

[data-theme="dark"] .transfer-choice-card.transfer-choice-highlight:hover {
    background-color: rgba(16, 185, 129, 0.16);
}

.transfer-choice-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.badge-ticimax-synced {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .badge-ticimax-synced {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-ticimax-failed {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .badge-ticimax-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.delete-order-btn {
    transition: all 0.15s ease;
}

.delete-order-btn:hover {
    color: var(--destructive) !important;
    background-color: rgba(239, 68, 68, 0.1) !important;
}

/* =========================================================
   GTIN MANAGEMENT PAGE & BARCODE ASSIGN MODAL STYLES
   ========================================================= */
.gtin-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.gtin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 980px) {
    .gtin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .gtin-stats-grid {
        grid-template-columns: 1fr;
    }
}

.gtin-stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gtin-stat-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted-foreground);
}

.gtin-stat-val-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.gtin-stat-val {
    font-size: 24px;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--foreground);
}

.gtin-stat-sub {
    font-size: 11.5px;
    color: var(--muted-foreground);
}

.gtin-progress-track {
    width: 100%;
    height: 6px;
    border-radius: 9999px;
    background: var(--secondary);
    overflow: hidden;
    margin-top: 2px;
}

.gtin-progress-fill {
    height: 100%;
    background: var(--emerald-500);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.gtin-scanner-card,
.gtin-catalog-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.gtin-scanner-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.gtin-scanner-input-wrap {
    flex: 1;
    min-width: 260px;
    position: relative;
}

.gtin-scanner-input {
    width: 100%;
    height: 48px;
    background: var(--secondary);
    border: 2px solid var(--emerald-500);
    border-radius: var(--radius);
    padding: 0 16px 0 42px;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--foreground);
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.gtin-scanner-input:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
    border-color: var(--emerald-600);
}

.gtin-scanner-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.gtin-result-empty {
    margin-top: 18px;
    padding: 28px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--background);
    text-align: center;
    color: var(--muted-foreground);
    font-size: 13px;
}

.gtin-result-card {
    margin-top: 18px;
    border: 1.5px solid var(--emerald-500);
    border-radius: var(--radius);
    background: var(--background);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gtin-match-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--emerald-50);
    border: 1px solid rgba(16, 185, 129, 0.35);
    font-size: 12.5px;
    color: var(--emerald-700);
}

.gtin-prod-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.gtin-prod-thumb {
    width: 84px;
    height: 84px;
    min-width: 84px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gtin-prod-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 4px;
}

.gtin-prod-meta-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted-foreground);
}

.gtin-prod-meta-grid strong {
    color: var(--foreground);
}

.gtin-slot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 760px) {
    .gtin-slot-grid {
        grid-template-columns: 1fr;
    }
}

.gtin-slot-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gtin-slot-box.is-default {
    border-color: var(--emerald-500);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

.gtin-slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.gtin-slot-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--foreground);
}

.gtin-stage-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.badge-gtin-verified {
    background: var(--emerald-50);
    color: var(--emerald-700);
    border: 1px solid rgba(16, 185, 129, 0.4);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
}

.badge-gtin-pending {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .badge-gtin-pending {
    background: rgba(245, 158, 11, 0.14);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

.badge-gtin-missing {
    background: var(--secondary);
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

/* Assign Unrecognized Barcode Modal */
.assign-barcode-banner {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.assign-slot-radios {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.slot-radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.slot-radio-pill input {
    accent-color: var(--emerald-500);
    cursor: pointer;
}

.assign-search-list {
    max-height: 340px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
}

.assign-product-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.assign-product-row:last-child {
    border-bottom: none;
}

.assign-product-row:hover {
    background: var(--accent);
}

.assign-prod-thumb {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.assign-prod-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 2px;
}

.gtin-table-scroll {
    overflow-x: auto;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.gtin-switcher-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-top: 12px;
    border-radius: var(--radius);
    background: var(--secondary);
    border: 1px solid var(--border);
    font-size: 12px;
}

/* =========================================================
   USER MENU & MOBILE RESPONSIVENESS (GTIN / POS / SETTINGS)
   ========================================================= */
.user-menu-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.user-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    background: var(--secondary);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--foreground);
    max-width: 190px;
}

.user-badge-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
        max-width: 100%;
    }

    .app-header {
        height: auto;
        min-height: 56px;
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .brand-wrapper {
        flex: 1 1 100%;
        min-width: 0;
        gap: 10px;
    }

    .brand-logo-img {
        height: 32px;
        max-width: 130px;
    }

    .sync-meta-wrap {
        min-width: 0;
        font-size: 10.5px;
    }

    .sync-meta-row {
        white-space: normal;
        flex-wrap: wrap;
        gap: 2px 6px;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-start;
    }

    .header-actions > .btn,
    .header-actions > a.btn {
        min-height: 44px;
        flex: 1 1 auto;
        font-size: 12.5px;
        padding: 0 10px;
    }

    .user-menu-group {
        width: 100%;
        padding-left: 0;
        padding-top: 8px;
        margin-top: 2px;
        border-left: none;
        border-top: 1px solid var(--border);
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .user-menu-group .btn {
        min-height: 44px;
    }

    .gtin-container {
        padding: 12px;
        gap: 14px;
    }

    .gtin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .gtin-stat-card {
        padding: 12px;
    }

    .gtin-stat-val {
        font-size: 20px;
    }

    .gtin-scanner-card,
    .gtin-catalog-card {
        padding: 14px 12px;
    }

    .gtin-scanner-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .gtin-scanner-input-wrap {
        min-width: 0;
        width: 100%;
    }

    .gtin-scanner-input {
        height: 46px;
        font-size: 16px;
    }

    #gtinScannerSubmitBtn {
        width: 100%;
        min-height: 44px;
    }

    .gtin-scanner-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .gtin-result-card {
        padding: 12px;
    }

    .gtin-prod-thumb {
        width: 64px;
        height: 64px;
        min-width: 64px;
    }

    .gtin-stage-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .gtin-stage-actions .btn {
        min-height: 44px;
        width: 100%;
    }

    .gtin-catalog-card .search-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .gtin-catalog-card .search-row .search-box-wrapper,
    .gtin-catalog-card .search-row .select-filter {
        width: 100%;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 44px;
        font-size: 16px;
    }

    .gtin-catalog-card .search-row .search-input {
        height: 44px !important;
        font-size: 16px !important;
    }

    .gtin-table-scroll {
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .gtin-table-scroll .btn {
        min-height: 44px;
        padding: 0 12px;
    }

    .slot-radio-pill {
        min-height: 44px;
        width: 100%;
    }

    .modal-backdrop {
        padding: 8px;
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100% !important;
        max-height: 92vh;
        border-radius: 12px;
    }

    .modal-header {
        padding: 12px 14px;
    }

    .modal-body {
        padding: 14px;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-footer .btn {
        min-height: 44px;
        flex: 1 1 auto;
    }

    #editGtinModal .modal-body > div[style*="grid-template-columns"],
    #editGtinModal .form-group > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .assign-barcode-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .assign-product-row {
        flex-wrap: wrap;
    }

    .assign-product-row .btn {
        min-height: 44px;
        width: 100%;
    }

    .settings-container {
        padding: 16px 12px 48px 12px !important;
    }

    .theme-selector-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 420px) {
    .gtin-stats-grid {
        grid-template-columns: 1fr;
    }
}
