/* ========================================
   AMILANO POS — Cashier System Styles
   ======================================== */

:root {
    --bg-primary: #08080d;
    --bg-secondary: #0f0f17;
    --bg-card: #161620;
    --bg-card-hover: #1e1e2c;
    --bg-input: #131320;
    --gold: #c9a84c;
    --gold-light: #e2c97e;
    --gold-dark: #a8873a;
    --gold-glow: rgba(201, 168, 76, 0.12);
    --text-primary: #f0ece4;
    --text-secondary: #a0a0b0;
    --text-muted: #5a5a6e;
    --border: #252535;
    --border-light: #303045;
    --green: #2ecc71;
    --green-bg: rgba(46, 204, 113, 0.1);
    --blue: #3498db;
    --blue-bg: rgba(52, 152, 219, 0.1);
    --orange: #e67e22;
    --orange-bg: rgba(230, 126, 34, 0.1);
    --red: #e74c3c;
    --red-bg: rgba(231, 76, 60, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ══════════════════════════════════════
   HEADER
   ══════════════════════════════════════ */
.pos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.pos-header-right,
.pos-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pos-back {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: var(--transition);
}

.pos-back:hover {
    color: var(--gold-light);
}

.pos-logo {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 5px;
    color: var(--gold);
}

.pos-badge {
    font-size: 0.65rem;
    background: var(--gold-glow);
    color: var(--gold-light);
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 600;
}

.pos-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.pos-site-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78rem;
    transition: var(--transition);
}

.pos-site-link:hover {
    color: var(--gold-light);
}

/* ══════════════════════════════════════
   POS LAYOUT (3-Column)
   ══════════════════════════════════════ */
.pos-layout {
    display: grid;
    grid-template-columns: 160px 1fr 340px;
    flex: 1;
    overflow: hidden;
}

/* ── Categories Panel (Right) ── */
.pos-categories {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    padding: 16px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-categories h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-align: center;
}

.cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.cat-btn:hover {
    background: var(--gold-glow);
    border-color: var(--border);
    color: var(--gold-light);
}

.cat-btn.active {
    background: linear-gradient(135deg, var(--gold-glow), rgba(201, 168, 76, 0.06));
    border-color: var(--gold-dark);
    color: var(--gold);
    font-weight: 700;
}

.cat-btn .cat-emoji {
    font-size: 1.6rem;
}

.cat-btn .cat-count {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Products Panel (Center) ── */
.pos-products {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
}

.pos-products-header {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.pos-search {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition);
}

.pos-search:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.pos-search::placeholder {
    color: var(--text-muted);
}

.pos-add-custom-btn {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--gold);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.pos-add-custom-btn:hover {
    background: var(--gold-glow);
    border-color: var(--gold-dark);
}

.pos-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    padding-bottom: 10px;
}

/* ── Product Item (Clickable) ── */
.pos-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.pos-item:hover {
    border-color: var(--gold-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.1);
}

.pos-item:active {
    transform: scale(0.97);
}

.pos-item-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    background: var(--bg-input);
}

.pos-item-placeholder {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-input), var(--bg-card-hover));
    font-size: 2rem;
}

.pos-item-info {
    padding: 10px 12px;
}

.pos-item-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-item-price {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--gold);
    margin-top: 4px;
}

.pos-item-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--gold);
    color: var(--bg-primary);
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 8px;
}

.pos-item-added {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--green);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* Custom item card */
.pos-item.custom-item {
    border-style: dashed;
    border-color: var(--gold-dark);
}

/* ══════════════════════════════════════
   CART PANEL (Left)
   ══════════════════════════════════════ */
.pos-cart {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.cart-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.cart-clear-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.4;
    transition: var(--transition);
}

.cart-clear-btn:hover {
    opacity: 1;
}

/* ── Cart Items ── */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
}

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 8px;
}

.cart-empty span {
    font-size: 2.5rem;
    opacity: 0.3;
}

.cart-empty p {
    font-size: 0.85rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    animation: slideIn 0.25s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.cart-item-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-price {
    font-size: 0.72rem;
    color: var(--gold);
    margin-top: 2px;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-family: inherit;
}

.qty-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.qty-btn.remove:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-bg);
}

.qty-value {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    color: var(--text-primary);
}

.cart-item-total {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--gold-light);
    min-width: 70px;
    text-align: left;
}

/* ── Cart Summary ── */
.cart-summary {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.total-row {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold);
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.items-count {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ── Checkout Button ── */
.checkout-btn {
    margin: 14px;
    padding: 16px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkout-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
}

.checkout-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ══════════════════════════════════════
   MODALS
   ══════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-sm {
    max-width: 400px;
}

.modal-invoice {
    max-width: 480px;
}

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

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.modal-body {
    padding: 20px 24px 24px;
}

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

.btn-print {
    padding: 6px 14px;
    background: var(--gold);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-print:hover {
    background: var(--gold-light);
}

/* ── Checkout Sections ── */
.checkout-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.checkout-section:last-of-type {
    border-bottom: none;
}

.checkout-section h3 {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
}

/* Phone search */
.phone-input-wrapper {
    display: flex;
    gap: 8px;
}

.phone-input-wrapper input {
    flex: 1;
}

.phone-search-btn {
    width: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.phone-search-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.customer-found {
    margin-top: 8px;
    padding: 10px 14px;
    background: var(--green-bg);
    border: 1px solid rgba(46, 204, 113, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.found-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--green);
}

.found-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.found-orders {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-right: auto;
}

/* ── Source & Payment Selectors ── */
.source-selector,
.payment-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.source-option,
.payment-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.source-option input,
.payment-option input {
    display: none;
}

.source-option:hover,
.payment-option:hover {
    border-color: var(--gold-dark);
}

.source-option.active,
.payment-option.active {
    border-color: var(--gold);
    background: var(--gold-glow);
}

.source-icon,
.payment-icon {
    font-size: 1.6rem;
}

.source-text,
.payment-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.source-option.active .source-text,
.payment-option.active .payment-text {
    color: var(--gold);
}

/* ── Checkout Items ── */
.checkout-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.checkout-item .c-name {
    color: var(--text-primary);
    font-weight: 500;
}

.checkout-item .c-qty {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.checkout-item .c-price {
    color: var(--gold);
    font-weight: 700;
}

.checkout-total {
    display: flex;
    justify-content: space-between;
    padding: 12px 0 0;
    margin-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold);
}

/* ── Confirm Payment ── */
.confirm-payment-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--green), #27ae60);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.confirm-payment-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(46, 204, 113, 0.3);
}

/* ══════════════════════════════════════
   INVOICE (Printable)
   ══════════════════════════════════════ */
.invoice-content {
    padding: 24px;
}

.invoice {
    background: #fff;
    color: #1a1a1a;
    border-radius: var(--radius);
    overflow: hidden;
}

.invoice-top {
    text-align: center;
    padding: 24px 20px 16px;
    border-bottom: 2px dashed #ddd;
}

.invoice-brand {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 6px;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.invoice-sub {
    font-size: 0.72rem;
    color: #888;
    letter-spacing: 1px;
}

.invoice-info {
    padding: 14px 20px;
    font-size: 0.78rem;
    color: #555;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    border-bottom: 1px solid #eee;
}

.invoice-info span {
    display: block;
}

.invoice-info .label {
    font-weight: 700;
    color: #333;
}

.invoice-table {
    width: 100%;
    padding: 0 20px;
    border-collapse: collapse;
}

.invoice-table th {
    padding: 10px 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #888;
    text-align: right;
    border-bottom: 1px solid #eee;
}

.invoice-table td {
    padding: 8px 0;
    font-size: 0.8rem;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
}

.invoice-total-section {
    padding: 14px 20px;
    border-top: 2px dashed #ddd;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 4px;
}

.invoice-total-row.grand {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1a1a1a;
    padding-top: 8px;
    margin-top: 6px;
    border-top: 1px solid #ddd;
}

.invoice-footer {
    text-align: center;
    padding: 16px 20px;
    font-size: 0.7rem;
    color: #aaa;
    border-top: 2px dashed #ddd;
}

.invoice-source-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 6px;
}

.invoice-source-badge.store {
    background: #f0f0f0;
    color: #666;
}

.invoice-source-badge.website {
    background: #e8f4fd;
    color: #2980b9;
}

/* ══════════════════════════════════════
   TOAST
   ══════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    animation: toastIn 0.35s ease;
}

.toast.success {
    border-color: var(--green);
}

.toast.error {
    border-color: var(--red);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ══════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════ */
@media print {
    body * {
        visibility: hidden;
    }

    .invoice-content,
    .invoice-content * {
        visibility: visible;
    }

    .invoice-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        padding: 0;
    }

    .modal-header,
    .invoice-actions-header {
        display: none !important;
    }
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .pos-categories {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-left: none;
        border-bottom: 1px solid var(--border);
        padding: 10px;
        gap: 6px;
    }

    .pos-categories h3 {
        display: none;
    }

    .cat-btn {
        flex-direction: row;
        padding: 8px 14px;
        white-space: nowrap;
        font-size: 0.72rem;
    }

    .cat-btn .cat-emoji {
        font-size: 1.1rem;
    }

    .cat-btn .cat-count {
        display: none;
    }

    .pos-cart {
        border-right: none;
        border-top: 1px solid var(--border);
        max-height: 45vh;
    }

    .pos-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

@media (max-width: 480px) {
    .pos-header {
        padding: 0 12px;
        gap: 8px;
    }

    .pos-back {
        display: none;
    }

    .pos-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}