/* ============================================================
   Sword Cricket POS — Mobile-first stylesheet
   Brand: Midnight Navy #0b1120 / Cyan #00e5ff / Volt #c6ff00
   ============================================================ */

:root {
    --pos-navy:    #0b1120;
    --pos-surface: #0f1829;
    --pos-border:  #1a2640;
    --pos-cyan:    #00e5ff;
    --pos-volt:    #c6ff00;
    --pos-text:    #e8f4f8;
    --pos-muted:   #6b7a99;
    --pos-red:     #ef4444;
    --pos-green:   #22c55e;
    --pos-orange:  #f59e0b;
    --pos-radius:  12px;
    --pos-font:    'Outfit', 'Segoe UI', system-ui, sans-serif;
}

#sc-pos-app * { box-sizing: border-box; }

#sc-pos-app {
    background: var(--pos-navy);
    min-height: 100vh;
    font-family: var(--pos-font);
    color: var(--pos-text);
    padding-bottom: 40px;
}

/* ── Header ──────────────────────────────────────────────── */
.pos-header {
    background: var(--pos-surface);
    border-bottom: 1px solid var(--pos-border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.pos-logo {
    font-size: 18px;
    font-weight: 800;
    color: var(--pos-cyan);
    letter-spacing: -0.3px;
}
.pos-logo span { font-size: 15px; }
.pos-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.pos-export-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pos-date {
    font-size: 12px;
    color: var(--pos-muted);
}

/* ── Body layout ─────────────────────────────────────────── */
.pos-body {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 20px;
    padding: 20px;
    max-width: 1300px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .pos-body { grid-template-columns: 1fr; }
}

/* ── Search / filter ─────────────────────────────────────── */
.pos-search-wrap {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.pos-search-input {
    flex: 1;
    min-width: 180px;
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: 8px;
    color: var(--pos-text);
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    font-family: var(--pos-font);
}
.pos-search-input:focus { border-color: var(--pos-cyan); }
.pos-select {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: 8px;
    color: var(--pos-text);
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--pos-font);
}

/* ── Product list ────────────────────────────────────────── */
.pos-product-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding-right: 4px;
}

.pos-product-item {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    gap: 12px;
}
.pos-product-item:hover { border-color: var(--pos-cyan); background: rgba(0,229,255,0.04); }
.pos-product-item:active { transform: scale(0.99); }
.pos-out-of-stock { opacity: 0.45; pointer-events: none; }

.pos-product-info { flex: 1; min-width: 0; }
.pos-product-name { font-size: 14px; font-weight: 600; color: var(--pos-text); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-product-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pos-sku { font-size: 11px; font-family: monospace; background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 4px; color: var(--pos-muted); }
.pos-cat { font-size: 11px; color: var(--pos-muted); }
.pos-in-cart { font-size: 11px; color: var(--pos-volt); font-weight: 600; }

.pos-product-right { text-align: right; flex-shrink: 0; }
.pos-product-price { font-size: 15px; font-weight: 700; color: var(--pos-cyan); }
.pos-stock { font-size: 11px; margin-top: 3px; }
.pos-stock-ok   { color: var(--pos-green); }
.pos-stock-low  { color: var(--pos-orange); }
.pos-stock-zero { color: var(--pos-red); }

.pos-loading, .pos-empty { text-align: center; padding: 40px; color: var(--pos-muted); font-size: 14px; }

/* ── Cards ───────────────────────────────────────────────── */
.pos-card {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--pos-radius);
    padding: 18px;
    margin-bottom: 16px;
}
.pos-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--pos-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
}
.pos-optional { font-weight: 400; text-transform: none; font-size: 11px; }

/* ── Cart items ──────────────────────────────────────────── */
.pos-empty-cart { text-align: center; padding: 24px 0; color: var(--pos-muted); font-size: 13px; }

.pos-cart-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--pos-border);
    gap: 10px;
}
.pos-cart-item:last-child { border-bottom: none; }
.pos-cart-item-info { flex: 1; }
.pos-cart-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.pos-cart-meta { font-size: 12px; color: var(--pos-muted); }
.pos-original-price { text-decoration: line-through; color: var(--pos-muted); font-size: 11px; }
.pos-cart-right { text-align: right; flex-shrink: 0; }
.pos-cart-total { font-size: 14px; font-weight: 700; color: var(--pos-volt); }
.pos-cart-remove {
    background: none; border: none; color: var(--pos-muted);
    cursor: pointer; font-size: 14px; padding: 2px 6px;
    display: block; margin-top: 4px; margin-left: auto;
}
.pos-cart-remove:hover { color: var(--pos-red); }

/* ── Totals ──────────────────────────────────────────────── */
.pos-totals-table { margin-top: 12px; border-top: 1px solid var(--pos-border); padding-top: 12px; }
.pos-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    color: var(--pos-muted);
}
.pos-tax-row { align-items: center; gap: 8px; }
.pos-tax-field {
    width: 56px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--pos-border);
    border-radius: 6px;
    color: var(--pos-text);
    padding: 4px 8px;
    font-size: 13px;
    text-align: center;
    outline: none;
    font-family: var(--pos-font);
}
.pos-grand-row {
    font-size: 18px !important;
    font-weight: 800;
    color: var(--pos-text) !important;
    border-top: 1px solid var(--pos-border);
    margin-top: 8px;
    padding-top: 8px;
}

/* ── Customer form ───────────────────────────────────────── */
.pos-customer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.pos-input-full { grid-column: 1 / -1; }

/* ── Buttons ─────────────────────────────────────────────── */
.pos-btn {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: var(--pos-font);
    transition: opacity 0.15s, transform 0.1s;
    letter-spacing: 0.3px;
}
.pos-btn:active { transform: scale(0.98); }
.pos-btn-primary  { background: var(--pos-cyan); color: var(--pos-navy); }
.pos-btn-ghost    { background: transparent; color: var(--pos-muted); border: 1px solid var(--pos-border); }
.pos-btn-complete { background: var(--pos-volt); color: var(--pos-navy); width: 100%; font-size: 16px; padding: 16px; border-radius: 10px; }
.pos-btn-print    { background: var(--pos-cyan); color: var(--pos-navy); flex: 1; }
.pos-btn:hover    { opacity: 0.88; }
.pos-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pos-actions { margin-bottom: 16px; }
.pos-print-actions { display: flex; gap: 12px; margin-top: 16px; }

/* ── Inputs ──────────────────────────────────────────────── */
.pos-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--pos-border);
    border-radius: 8px;
    color: var(--pos-text);
    padding: 11px 14px;
    font-size: 14px;
    outline: none;
    font-family: var(--pos-font);
    transition: border-color 0.15s;
}
.pos-input:focus { border-color: var(--pos-cyan); }
.pos-note { display: block; font-size: 11px; color: var(--pos-muted); margin-top: 4px; }

/* ── Modal ───────────────────────────────────────────────── */
.pos-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pos-modal-box {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.pos-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 20px 14px;
    border-bottom: 1px solid var(--pos-border);
    gap: 12px;
}
.pos-modal-title { font-size: 16px; font-weight: 700; color: var(--pos-text); }
.pos-modal-sku   { font-size: 12px; font-family: monospace; color: var(--pos-muted); margin-top: 3px; }
.pos-modal-close { background: none; border: none; color: var(--pos-muted); font-size: 18px; cursor: pointer; padding: 0; flex-shrink: 0; }
.pos-modal-body  { padding: 18px 20px; }
.pos-modal-stock { font-size: 12px; color: var(--pos-muted); margin-bottom: 14px; }
.pos-modal-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pos-field-group label { display: block; font-size: 12px; font-weight: 600; color: var(--pos-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.pos-modal-preview { margin-top: 14px; background: rgba(0,229,255,0.06); border: 1px solid rgba(0,229,255,0.15); border-radius: 8px; padding: 10px 14px; font-size: 14px; color: var(--pos-muted); text-align: center; }
.pos-modal-preview strong { color: var(--pos-volt); font-size: 18px; }
.pos-modal-footer { padding: 14px 20px; border-top: 1px solid var(--pos-border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Invoice ─────────────────────────────────────────────── */
.pos-invoice-card {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}
.inv-shop-header { text-align: center; margin-bottom: 16px; }
.inv-shop-name   { font-size: 16px; font-weight: 800; color: #0f172a; }
.inv-shop-brand  { font-size: 14px; font-weight: 600; color: #0369a1; margin: 3px 0; }
.inv-shop-addr   { font-size: 11px; color: #64748b; line-height: 1.6; }
.inv-divider     { border: none; border-top: 1px dashed #cbd5e1; margin: 14px 0; }
.inv-meta        { display: flex; justify-content: space-between; margin-bottom: 12px; }
.inv-label       { font-size: 10px; text-transform: uppercase; color: #94a3b8; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 3px; }
.inv-value       { font-size: 14px; font-weight: 700; color: #0f172a; }
.inv-customer    { margin-bottom: 12px; }
.inv-cust-sub    { font-size: 12px; font-weight: 400; color: #475569; }
.inv-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-items-table th { font-size: 10px; text-transform: uppercase; color: #94a3b8; padding: 6px 4px; border-bottom: 1px solid #e2e8f0; font-weight: 600; letter-spacing: 0.5px; }
.inv-items-table td { padding: 8px 4px; border-bottom: 1px solid #f1f5f9; color: #1e293b; }
.inv-items-table tr:last-child td { border-bottom: none; }
.inv-right       { text-align: right; }
.inv-totals      { margin-top: 4px; }
.inv-total-row   { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; color: #475569; }
.inv-grand-row   { font-size: 16px; font-weight: 800; color: #0f172a; border-top: 1px solid #e2e8f0; margin-top: 6px; padding-top: 8px; }
.inv-footer      { text-align: center; font-size: 12px; color: #94a3b8; margin-top: 4px; font-style: italic; }

/* ── Toast ───────────────────────────────────────────────── */
.pos-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    white-space: nowrap;
    max-width: 90vw;
}
.pos-toast-success { background: rgba(0,229,255,0.15); border: 1px solid var(--pos-cyan); color: var(--pos-cyan); }
.pos-toast-error   { background: rgba(239,68,68,0.15);  border: 1px solid var(--pos-red);  color: var(--pos-red); }

/* ── Print styles ────────────────────────────────────────── */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    /* Hide EVERYTHING on the page first */
    body > *,
    body > * > * { display: none !important; }

    /* Then show only the invoice */
    #pos-invoice-print,
    #pos-invoice-print * { display: revert !important; }

    /* Explicitly hide website chrome */
    header, footer, nav,
    #masthead, #colophon, #site-header, #site-footer,
    .site-header, .site-footer, .site-navigation,
    .woocommerce-breadcrumb, .announcement-bar,
    #wpadminbar, .admin-bar,
    [class*="header"], [class*="footer"], [class*="navbar"],
    [class*="nav-"], [id*="header"], [id*="footer"],
    .pos-header, .pos-left, .pos-right > *:not(#pos-invoice-wrap),
    .pos-body, #pos-invoice-wrap > .pos-print-actions,
    .pos-toast, .pos-modal, .no-print { display: none !important; }

    /* Invoice styling for print */
    #pos-invoice-print {
        display: block !important;
        position: fixed !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important;
        background: #fff !important;
        color: #000 !important;
        padding: 20px !important;
        border: none !important;
        box-shadow: none !important;
        font-family: Arial, sans-serif !important;
        font-size: 12pt !important;
    }

    .inv-shop-name { font-size: 16pt !important; }
    .inv-grand-row { font-size: 14pt !important; }
    .inv-items-table { font-size: 11pt !important; }
}

/* ── Mobile tweaks ───────────────────────────────────────── */
@media (max-width: 480px) {
    .pos-header { padding: 12px 14px; }
    .pos-body   { padding: 12px; gap: 12px; }
    .pos-customer-grid { grid-template-columns: 1fr; }
    .pos-input-full { grid-column: 1; }
    .pos-modal-fields { grid-template-columns: 1fr; }
    .pos-product-name { font-size: 13px; }
}

/* ── Payment modes ───────────────────────────────────────── */
.pos-payment-modes {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}
.pos-pay-mode {
    flex: 1;
    padding: 10px 8px;
    border: 2px solid var(--pos-border);
    border-radius: 8px;
    background: var(--pos-surface);
    color: var(--pos-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--pos-font);
    transition: all 0.15s;
    text-align: center;
}
.pos-pay-mode:hover { border-color: var(--pos-cyan); color: var(--pos-text); }
.pos-pay-mode.active {
    border-color: var(--pos-cyan);
    background: rgba(0,229,255,0.08);
    color: var(--pos-cyan);
}

/* ── Coupon ──────────────────────────────────────────────── */
.pos-coupon-input-wrap {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.pos-coupon-field {
    width: 110px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--pos-border);
    border-radius: 6px;
    color: var(--pos-text);
    padding: 5px 8px;
    font-size: 12px;
    font-family: monospace;
    outline: none;
    text-transform: uppercase;
}
.pos-coupon-field:focus { border-color: var(--pos-cyan); }
.pos-btn-inline {
    background: rgba(0,229,255,0.1);
    border: 1px solid rgba(0,229,255,0.3);
    color: var(--pos-cyan);
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--pos-font);
}
.pos-btn-inline:hover { background: rgba(0,229,255,0.2); }

/* ── Invoice payment section ─────────────────────────────── */
.inv-payment { margin-bottom: 12px; }
.inv-payment-mode { font-size: 14px; font-weight: 700; color: #166534; margin-top: 4px; }

/* ── Fix 1: Print — hide EVERYTHING except the invoice ───── */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    /* Hide the entire page */
    body > * { display: none !important; }

    /* Hide theme header, footer, nav, announcement bar */
    header, footer, nav, .site-header, .site-footer,
    #masthead, #colophon, #site-navigation,
    .woocommerce-breadcrumb, .announcement-bar,
    [class*="header"], [class*="footer"], [class*="navbar"],
    [class*="nav-"], [class*="menu"], .wp-block-template-part { display: none !important; }

    /* Show ONLY the page content wrapper */
    body, html { background: white !important; margin: 0 !important; padding: 0 !important; }

    /* Show only the invoice card */
    #pos-invoice-print {
        display: block !important;
        position: fixed !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important;
        background: white !important;
        border: none !important;
        box-shadow: none !important;
        padding: 20px !important;
        z-index: 99999 !important;
    }

    /* Hide everything else in the POS app */
    .pos-header, .pos-left, .pos-cart-card, .pos-customer-card,
    .pos-payment-card, .pos-actions, .pos-toast, .pos-modal,
    .pos-print-actions, .no-print, #pos-toast,
    #sc-pos-app > *:not(.pos-body),
    .pos-body > .pos-left,
    .pos-right > *:not(#pos-invoice-wrap),
    #pos-invoice-wrap > .pos-print-actions { display: none !important; }

    #pos-invoice-wrap { display: block !important; }
    .pos-card.pos-invoice-card { display: block !important; }
}

/* ── Coupon ──────────────────────────────────────────────── */
.pos-coupon-input-wrap { display: flex; gap: 6px; align-items: center; }
.pos-coupon-field {
    width: 110px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--pos-border);
    border-radius: 6px;
    color: var(--pos-text);
    padding: 5px 9px;
    font-size: 12px;
    outline: none;
    font-family: monospace;
    letter-spacing: 1px;
}
.pos-coupon-field:focus { border-color: var(--pos-cyan); }
.pos-btn-inline {
    background: var(--pos-cyan);
    color: var(--pos-navy);
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

/* ── Payment modes ───────────────────────────────────────── */
.pos-payment-modes { display: flex; gap: 8px; margin-bottom: 4px; }
.pos-pay-mode {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--pos-border);
    border-radius: 8px;
    color: var(--pos-muted);
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--pos-font);
    transition: all 0.15s;
    text-align: center;
}
.pos-pay-mode:hover { border-color: var(--pos-cyan); color: var(--pos-text); }
.pos-pay-mode.active {
    background: rgba(0,229,255,0.12);
    border-color: var(--pos-cyan);
    color: var(--pos-cyan);
}

/* ── Invoice payment line ────────────────────────────────── */
.inv-payment { margin-bottom: 4px; }
.inv-payment-mode { font-size: 13px; font-weight: 600; color: #0f172a; margin-top: 3px; }

/* ── Sale success panel ──────────────────────────────────── */
.pos-sale-success-card {
    text-align: center;
    padding: 40px 24px;
}
.pos-success-icon {
    width: 64px;
    height: 64px;
    background: rgba(198,255,0,0.15);
    border: 2px solid var(--pos-volt);
    border-radius: 50%;
    font-size: 28px;
    color: var(--pos-volt);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.pos-success-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--pos-volt);
    margin-bottom: 8px;
}
.pos-success-inv {
    font-size: 13px;
    color: var(--pos-muted);
    margin-bottom: 6px;
    font-family: monospace;
}
.pos-success-total {
    font-size: 26px;
    font-weight: 800;
    color: var(--pos-text);
    margin-bottom: 28px;
}
.pos-success-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}
.pos-success-actions .pos-btn-complete {
    display: block;
    text-decoration: none;
    text-align: center;
}
