/* =========================================
   Blue Mart POS - extracted from pos.html
   ========================================= */

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

:root {
    --primary: #0969e8;
    --primary-dark: #0756c7;
    --green: #16b95b;
    --green-dark: #0fa94f;
    --red: #e53935;
    --text: #182230;
    --muted: #788494;
    --border: #e7ebf0;
    --bg: #f7f9fc;
    --white: #ffffff;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* APPLICATION */
.app {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    height: 100vh;
    width: 100%;
}

/* SIDEBAR */
.sidebar {
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.logo {
    height: 88px;
    min-height: 88px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 25px;
    border-bottom: 1px solid #f0f2f5;
    background: linear-gradient(135deg, #0969e8 0%, #7c3aed 100%);
}

.logo-icon { font-size: 31px; }

.logo-text strong {
    display: block;
    color: #fff;
    font-size: 21px;
}

.logo-text span {
    color: rgba(255,255,255,.75);
    font-size: 11px;
    letter-spacing: .7px;
}

.menu {
    padding: 18px 10px;
    overflow-y: auto;
}

.menu-item {
    height: 52px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 17px;
    border-radius: 10px;
    margin-bottom: 5px;
    font-size: 14px;
    cursor: pointer;
    color: #252b34;
    text-decoration: none;
    transition: all .2s ease;
}

.menu-item:hover {
    background: color-mix(in srgb, var(--menu-color, #f2f6fc) 10%, transparent);
    color: var(--menu-color, #252b34);
}

.menu-item.active {
    background: var(--primary);
    color: #fff;
}

.menu-item.active .menu-icon {
    background: rgba(255,255,255,.2);
    border-radius: 8px;
}

.menu-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 18px;
    border-radius: 8px;
    transition: all .2s ease;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 15px;
}

.welcome-card {
    border: 1px solid #edf0f5;
    border-radius: 14px;
    padding: 20px 10px;
    text-align: center;
    margin-bottom: 15px;
    background: linear-gradient(180deg, #fff, #fafcff);
}

.cart-icon {
    font-size: 55px;
    margin-bottom: 10px;
}

.welcome-card small {
    color: #687383;
    font-size: 12px;
}

.welcome-card strong {
    color: var(--primary);
    display: block;
    margin: 5px 0;
    font-size: 13px;
}

.logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    font-size: 14px;
    cursor: pointer;
    color: #252b34;
    text-decoration: none;
}

.logout:hover { color: var(--red); }

/* MAIN */
.main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* HEADER */
.header {
    height: 88px;
    min-height: 88px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 25px;
    position: relative;
}

.mobile-menu { font-size: 24px; cursor: pointer; user-select: none; }

.search {
    flex: 1;
    min-width: 150px;
    height: 46px;
    border: 1px solid #e0e5ec;
    border-radius: 11px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.search span { color: #9aa4b2; font-size: 20px; }

.search input {
    border: none;
    outline: none;
    width: 100%;
    margin-left: 12px;
    font-size: 14px;
}

.scan-btn {
    height: 46px;
    padding: 0 20px;
    border: 1px solid #e2e7ed;
    border-radius: 10px;
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.header-btn {
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 10px;
    background: #f7f9fc;
    font-size: 19px;
    cursor: pointer;
    position: relative;
}

.header-btn.has-alert {
    background: #fff3f3;
}

.header-btn.has-alert::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 50%;
}

.notif-wrapper {
    position: relative;
}

.notif-panel {
    display: none;
    position: absolute;
    top: 54px;
    right: 0;
    width: 340px;
    max-height: 400px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    z-index: 1000;
    overflow: hidden;
}

.notif-panel.open {
    display: block;
}

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

.notif-header strong {
    font-size: 14px;
}

.notif-header span {
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.notif-list {
    max-height: 320px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid #f2f4f7;
}

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

.notif-img {
    font-size: 22px;
}

.notif-info {
    flex: 1;
    min-width: 0;
}

.notif-info strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-info small {
    color: var(--muted);
    font-size: 11px;
}

.notif-stock {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.notif-stock.low {
    background: #fff8e1;
    color: #f59e0b;
}

.notif-stock.out {
    background: #fff3f3;
    color: var(--red);
}

.notif-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--muted);
    font-size: 13px;
}

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

.user-info {
    text-align: right;
    font-size: 12px;
    color: #687383;
}

.user-info strong {
    display: block;
    font-size: 13px;
    color: var(--text);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* POS AREA */
.pos-area {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    overflow: hidden;
}

/* PRODUCTS */
.products-area {
    padding: 20px 18px 10px;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

.categories {
    display: flex;
    gap: 9px;
    margin-bottom: 18px;
    overflow-x: auto;
}

.category {
    white-space: nowrap;
    padding: 11px 17px;
    border: 1px solid #e1e6ed;
    border-radius: 9px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
}

.category:hover { background: #f2f6fc; }

.category.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* PRODUCT GRID */
.product-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 8px;
}

.product {
    background: #fff;
    border: 1px solid #e7ebf0;
    border-radius: 10px;
    padding: 8px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: .2s;
}

.product:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(20,40,70,.08);
}

.product-image {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
}

.product-name {
    font-size: 12px;
    font-weight: 600;
    margin: 6px 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-stock {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.product-stock.low { color: var(--red); font-weight: 600; }

.product-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.price { font-size: 13px; font-weight: 700; }

.add-btn {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 23px;
    cursor: pointer;
}

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

/* PAGINATION */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 15px 0;
}

.page {
    min-width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
}

.page.active {
    background: var(--primary);
    color: #fff;
}

/* CART */
.cart {
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.cart-header {
    background: var(--primary);
    color: #fff;
    height: 58px;
    min-height: 58px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cart-header strong { font-size: 17px; }

.clear-cart { cursor: pointer; font-size: 12px; }

.cart-items {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.cart-item {
    min-height: 72px;
    padding: 8px 14px;
    border-bottom: 1px solid #edf0f4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-image {
    width: 42px;
    height: 42px;
    min-width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 31px;
}

.cart-details { flex: 1; min-width: 0; }

.cart-details strong {
    font-size: 13px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-details small {
    color: #8a94a3;
    display: block;
    margin-top: 4px;
    font-size: 11px;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.qty-btn {
    width: 22px;
    height: 22px;
    border: 1px solid #dce2ea;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover { background: #f2f6fc; }

.qty-val {
    font-size: 12px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.cart-price {
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
}

.remove {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: none;
    border-radius: 7px;
    background: #f5f7fa;
    cursor: pointer;
}

/* CART SUMMARY */
.cart-summary {
    flex-shrink: 0;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #edf0f4;
}

.summary-box {
    background: #fafbfd;
    border: 1px solid #edf0f4;
    border-radius: 10px;
    padding: 11px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 9px;
    font-size: 12px;
}

.summary-row.discount strong { color: var(--green); }

.discount-input {
    width: 70px;
    height: 26px;
    border: 1px solid #dce2ea;
    border-radius: 6px;
    text-align: right;
    font-size: 12px;
    padding: 0 6px;
    outline: none;
}

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

.summary-total {
    border-top: 1px solid #e3e7ec;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 700;
}

.summary-total strong {
    color: var(--primary);
    font-size: 21px;
}

/* CART ACTIONS */
.cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.action-btn {
    height: 42px;
    background: #fff;
    border: 1px solid #e3e7ed;
    border-radius: 9px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
}

.action-btn:hover { background: #f7f9fc; }

/* PAY BUTTON */
.pay-btn {
    width: 100%;
    height: 50px;
    margin-top: 8px;
    border: none;
    border-radius: 9px;
    background: var(--green);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.pay-btn:hover { background: var(--green-dark); }

/* CUSTOMER SELECTOR */
.customer-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.customer-row select {
    flex: 1;
    height: 38px;
    border: 1px solid #dce2ea;
    border-radius: 8px;
    padding: 0 8px;
    font-size: 13px;
    outline: none;
}

/* HELD SALES PANEL */
.held-panel {
    display: none;
    margin-bottom: 8px;
}

.held-panel.show { display: block; }

.held-list {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #edf0f4;
    border-radius: 8px;
    margin-top: 6px;
}

.held-item {
    padding: 8px 10px;
    border-bottom: 1px solid #edf0f4;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.held-item:hover { background: #f2f6fc; }

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

/* FOOTER */
.footer {
    height: 50px;
    min-height: 50px;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    font-size: 12px;
}

.weather { color: #596575; }
.weather-loc {
    font-weight: 700;
    color: var(--primary);
    background: #e8f4ff;
    padding: 2px 8px;
    border-radius: 10px;
}
.terminal { font-weight: 600; }

.footer-right {
    display: flex;
    align-items: center;
    gap: 25px;
}

.online {
    color: var(--green);
    background: #ecfaf2;
    padding: 6px 12px;
    border-radius: 15px;
}

/* PAYMENT MODAL */
.payment-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 24, 40, .55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.payment-overlay.show { display: flex; }

.payment-modal {
    width: 460px;
    max-width: 100%;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 25px 70px rgba(0,0,0,.25);
    overflow: hidden;
}

.payment-header {
    background: var(--primary);
    color: #fff;
    padding: 20px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.payment-header h2 { font-size: 19px; }

.close-payment {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.payment-body { padding: 22px; }

.payment-total-card {
    background: #f3f7ff;
    border: 1px solid #dce8fb;
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    margin-bottom: 18px;
}

.payment-total-card span {
    display: block;
    color: #6c7888;
    font-size: 13px;
    margin-bottom: 6px;
}

.payment-total-card strong {
    display: block;
    color: var(--primary);
    font-size: 32px;
}

.payment-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 7px;
}

.amount-input {
    width: 100%;
    height: 52px;
    border: 2px solid #dce2ea;
    border-radius: 10px;
    padding: 0 15px;
    font-size: 21px;
    font-weight: 700;
    outline: none;
    text-align: right;
}

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

.quick-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin-top: 10px;
}

.quick-amount {
    height: 38px;
    border: 1px solid #dfe4eb;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.quick-amount:hover {
    background: #f2f6fc;
    border-color: var(--primary);
}

.balance-card {
    margin-top: 18px;
    padding: 15px;
    border-radius: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ecfaf2;
    border: 1px solid #ccefdc;
}

.balance-card.due {
    background: #fff3f3;
    border-color: #ffd2d2;
}

.balance-label { font-size: 13px; font-weight: 600; }

.balance-amount {
    font-size: 22px;
    font-weight: 800;
    color: var(--green);
}

.balance-card.due .balance-amount { color: var(--red); }

.payment-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 18px;
}

.method-btn {
    height: 45px;
    border: 1px solid #e0e5eb;
    background: #fff;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
}

.method-btn.active {
    border-color: var(--primary);
    background: #edf5ff;
    color: var(--primary);
}

.complete-payment {
    width: 100%;
    height: 52px;
    margin-top: 18px;
    border: none;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.complete-payment:disabled {
    background: #b8c1cc;
    cursor: not-allowed;
}

.payment-note {
    text-align: center;
    color: #8993a1;
    font-size: 11px;
    margin-top: 10px;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #182230;
    color: #fff;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: .3s;
}

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

/* RESPONSIVE */
@media(max-width:1200px) {
    .product-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
    .pos-area { grid-template-columns: minmax(0, 1fr) 340px; }
    .scan-btn { padding: 0 12px; }
}

@media(max-width:950px) {
    .app { grid-template-columns: 70px minmax(0, 1fr); }
    .logo { justify-content: center; padding: 0; }
    .logo-text, .menu-item span, .welcome-card, .logout span { display: none; }
    .menu-item { justify-content: center; padding: 0; }
    .pos-area { grid-template-columns: minmax(0, 1fr); }
    .cart { display: none; }
}

@media(max-width:650px) {
    .header { padding: 0 10px; gap: 8px; }
    .scan-btn, .header-btn { display: none; }
    .user-info { display: none; }
    .product-grid { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
    .products-area { padding: 12px; }

    .product { min-height: 120px; }
    .product-image { height: 60px; font-size: 40px; }
    .quick-amounts { grid-template-columns: repeat(2, 1fr); }
}

/* SIDEBAR TOGGLE - works on all screen sizes */
.sidebar {
    transition: transform .25s ease, width .25s ease;
}

/* Collapsed state (desktop: shrinks to icons, mobile: slides off-screen) */
.sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; }
.app.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }

.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    z-index: 9998;
}
.sidebar-overlay.show { display: block; }

@media(max-width:950px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 220px;
        z-index: 9999;
        transform: translateX(-100%);
        box-shadow: 2px 0 12px rgba(0,0,0,.15);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { width: 220px; min-width: 0; }
    .app.sidebar-collapsed { grid-template-columns: 70px minmax(0, 1fr); }
}
