/*
 * Glassmorphism theme
 * Loaded after style.css and only overrides it — remove the <link> to
 * glass.css in the page headers to go back to the original flat look.
 *
 * Blur is kept to large surfaces (sidebar, cards, cart, modals). Small,
 * repeated elements like POS product tiles and table rows use translucency
 * only, so the POS stays fast on low-end tablets and PCs.
 */

:root {
    --glass-bg: rgba(255, 255, 255, 0.58);
    --glass-bg-strong: rgba(255, 255, 255, 0.78);
    --glass-bg-soft: rgba(255, 255, 255, 0.38);
    --glass-edge: rgba(255, 255, 255, 0.7);
    --glass-blur: blur(18px) saturate(160%);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.75);
    --glass-shadow-lg: 0 24px 64px rgba(31, 38, 135, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.8);

    /* Re-point the base theme's tokens so inline styles follow along */
    --card: var(--glass-bg);
    --bg: var(--glass-bg-soft);
    --border: rgba(15, 23, 42, 0.08);
    --primary-light: rgba(99, 102, 241, 0.12);
    --secondary: #55607a;
}

/* ---------- Backdrop ---------- */

html {
    min-height: 100%;
    background: #eef0fb;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(42rem 42rem at 8% 12%, rgba(99, 102, 241, 0.38), transparent 60%),
        radial-gradient(36rem 36rem at 92% 8%, rgba(236, 72, 153, 0.22), transparent 60%),
        radial-gradient(40rem 40rem at 85% 90%, rgba(14, 165, 233, 0.26), transparent 60%),
        radial-gradient(34rem 34rem at 20% 95%, rgba(124, 58, 237, 0.24), transparent 60%),
        linear-gradient(135deg, #eef0fb 0%, #f5f3ff 50%, #ecfeff 100%);
    background-attachment: fixed;
}

/* ---------- Glass surfaces ---------- */

.card,
.stat-card,
.pos-search,
.pos-cart,
.login-card,
.modal {
    background: var(--glass-bg);
    border: 1px solid var(--glass-edge);
    box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
}

.card-header {
    border-bottom-color: rgba(255, 255, 255, 0.55);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    /* soft light sweep across the top of each stat tile */
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 55%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent);
    pointer-events: none;
}

.stat-card > * {
    position: relative;
}

.stat-card {
    container-type: inline-size;
}

.stat-card .stat-value {
    /* big peso amounts shrink to the tile's own width (5 tiles on a warehouse
       dashboard with POS, 2 per row on phones) instead of breaking mid-number */
    font-size: clamp(1.1rem, 13cqi, 1.85rem);
    white-space: nowrap;
}

/* Browsers without container units: shrink with the screen instead */
@supports not (font-size: 1cqi) {
    .stat-card .stat-value {
        font-size: clamp(1.1rem, 1.6vw, 1.85rem);
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

.stat-card:hover {
    box-shadow: var(--glass-shadow-lg);
    transform: translateY(-3px);
}

.page-header h1 {
    background: linear-gradient(135deg, #1e1b4b, #4338ca 60%, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Sidebar ---------- */

.sidebar {
    background: linear-gradient(180deg, rgba(23, 27, 56, 0.78), rgba(15, 18, 40, 0.86));
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
}

.sidebar-brand {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(139, 92, 246, 0.9));
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.sidebar-footer {
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-toggle {
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-edge);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
}

.sidebar-overlay {
    background: rgba(15, 23, 42, 0.35);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* ---------- Forms ---------- */

.form-control,
.pos-search input,
.discount-controls input,
.discount-controls select {
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.form-control:focus,
.pos-search input:focus {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* ---------- Buttons ---------- */

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #6d28d9);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 18px rgba(22, 163, 74, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-danger {
    background: linear-gradient(135deg, #f43f5e, #dc2626);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(31, 38, 135, 0.08);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.85);
}

/* ---------- Tables ---------- */

table th {
    background: rgba(255, 255, 255, 0.4);
}

table th:first-child {
    border-top-left-radius: var(--radius-sm);
}

table th:last-child {
    border-top-right-radius: var(--radius-sm);
}

table a {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
}

table a:hover {
    text-decoration: underline;
}

table tbody tr:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ---------- Badges & alerts ---------- */

.badge {
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.badge-success { background: rgba(34, 197, 94, 0.18); color: #14532d; }
.badge-danger  { background: rgba(239, 68, 68, 0.18); color: #7f1d1d; }
.badge-warning { background: rgba(245, 158, 11, 0.22); color: #78350f; }
.badge-info    { background: rgba(99, 102, 241, 0.16); color: #312e81; }

.alert {
    border-radius: var(--radius);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.alert-success { background: rgba(220, 252, 231, 0.75); border-color: rgba(134, 239, 172, 0.8); }
.alert-error   { background: rgba(254, 226, 226, 0.78); border-color: rgba(252, 165, 165, 0.8); }
.alert-warning { background: rgba(254, 243, 199, 0.78); border-color: rgba(253, 224, 71, 0.7); }

/* ---------- POS screen ---------- */

/* Tiles keep their natural height instead of stretching to fill the screen */
.pos-product-grid {
    align-content: start;
}

.product-card {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 14px rgba(31, 38, 135, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.product-card:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.pos-categories .cat-btn,
.variant-btn,
.payment-method-btn {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(255, 255, 255, 0.9);
}

.pos-cart-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.15));
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

.pos-cart-summary {
    background: rgba(255, 255, 255, 0.4);
    border-top-color: rgba(255, 255, 255, 0.6);
}

.cart-item .item-qty button {
    background: rgba(255, 255, 255, 0.7);
}

/* ---------- Modals ---------- */

.modal-overlay {
    background: rgba(30, 27, 75, 0.28);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter: blur(8px) saturate(120%);
}

.modal {
    background: var(--glass-bg-strong);
    box-shadow: var(--glass-shadow-lg);
}

.modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

.modal-footer {
    border-top-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.3);
}

/* Receipts stay solid white so they read (and print) like paper */
.receipt {
    background: #fff;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* ---------- Login ---------- */

.login-wrapper {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(38rem 38rem at 15% 20%, rgba(129, 140, 248, 0.9), transparent 60%),
        radial-gradient(34rem 34rem at 85% 15%, rgba(236, 72, 153, 0.55), transparent 60%),
        radial-gradient(40rem 40rem at 80% 90%, rgba(56, 189, 248, 0.6), transparent 60%),
        linear-gradient(135deg, #4338ca, #6d28d9 55%, #0e7490);
}

.login-card {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
    backdrop-filter: blur(24px) saturate(170%);
    color: #fff;
}

.login-card h1 {
    color: #fff;
    text-shadow: 0 2px 12px rgba(30, 27, 75, 0.35);
}

.login-card .subtitle,
.login-card .login-credit,
.login-card label {
    color: rgba(255, 255, 255, 0.88);
}

.login-card .form-control {
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
}

.login-card .alert-error {
    background: rgba(254, 226, 226, 0.92);
}

/* ---------- Fallbacks ---------- */

/* Browsers without backdrop-filter: use more opaque surfaces so text stays readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root {
        --glass-bg: rgba(255, 255, 255, 0.9);
        --glass-bg-strong: rgba(255, 255, 255, 0.97);
    }

    .sidebar {
        background: linear-gradient(180deg, #171b38, #0f1228);
    }

    .login-card {
        background: rgba(30, 27, 75, 0.82);
    }
}

/* Users who ask the OS for less transparency get solid surfaces */
@media (prefers-reduced-transparency: reduce) {
    :root {
        --glass-bg: #ffffff;
        --glass-bg-strong: #ffffff;
    }

    .card, .stat-card, .pos-search, .pos-cart, .modal, .sidebar, .alert, .modal-overlay {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .sidebar {
        background: #151b2e;
    }

    .login-card {
        background: #312e81;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media print {
    html, body {
        background: #fff;
    }
}
