/* Base Variables */
:root {
    /* Primary brand colors */
    --primary: #E74C3C;
    --primary-hover: #C0392B;
    --secondary: #F39C12;
    --accent: #27AE60;

    /* Layout */
    --radius: 10px;
    --nav-height: 60px;
    --bottom-nav-height: 65px;
    --transition: 0.2s ease;
}

/* Light Theme (Default) */
.theme-light {
    --bg-app: #F8F9FA;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --text-main: #2C3E50;
    --text-muted: #7F8C8D;
    --border: #E0E6ED;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    --hover-overlay: rgba(0, 0, 0, 0.03);
    --pos-cart-bg: #FFFFFF;
}

/* Dark Theme */
.theme-dark {
    --bg-app: #1A1A2E;
    --bg-card: #16213E;
    --bg-input: #0F3460;
    --text-main: #EAEAEA;
    --text-muted: #9BA4B5;
    --border: #2C3A5A;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    --hover-overlay: rgba(255, 255, 255, 0.05);
    --pos-cart-bg: #16213E;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    transition: background-color var(--transition), color var(--transition);
    overflow-x: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.text-center {
    text-align: center;
}

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

.text-sm {
    font-size: 0.85rem;
}

.w-full {
    width: 100%;
}

.w-50 {
    width: 48%;
}

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

.gap-2 {
    gap: 0.5rem;
}

.bold {
    font-weight: 700;
}

/* Typography */
h1,
h2,
h3,
h4 {
    color: var(--text-main);
}

.danger {
    color: var(--primary);
}

/* Navigation Top */
.navbar {
    height: var(--nav-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
}

.nav-brand svg {
    width: 24px;
    height: 24px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    padding: 5px;
}

/* App Container */
.app-container {
    height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    padding-bottom: var(--bottom-nav-height);
}

.view-section {
    display: none;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Shared Component */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* POS Layout (Split Screen) */
.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    height: calc(100vh - var(--nav-height) - 3rem);
}

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

/* Catalog */
.pos-catalog {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: hidden;
}

.catalog-header {
    display: flex;
    gap: 1rem;
}

.search-input,
.select-input,
.text-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.search-input {
    flex: 1;
}

.search-input:focus,
.select-input:focus,
.text-input:focus {
    border-color: var(--primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
    user-select: none;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:active {
    transform: scale(0.95);
}

.product-card:hover {
    border-color: var(--primary);
}

.product-card.no-stock {
    opacity: 0.5;
    filter: grayscale(1);
    pointer-events: none;
}

.prod-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 0.5rem;
    background: var(--hover-overlay);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.prod-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
    flex: 1;
}

.prod-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.prod-stock {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

/* Cart */
.pos-cart {
    background: var(--pos-cart-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

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

.text-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

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

.empty-cart-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    border-bottom: 1px dashed var(--border);
}

.ci-info {
    flex: 1;
}

.ci-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.ci-price {
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    font-weight: bold;
    cursor: pointer;
}

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

.ci-qty {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.cart-summary {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--hover-overlay);
    border-radius: 0 0 var(--radius) var(--radius);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.summary-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--primary);
}

/* Buttons */
.primary-btn,
.secondary-btn,
.danger-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
}

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

.danger-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.danger-btn:hover {
    background: var(--primary);
    color: #fff;
}

.checkout-btn {
    width: 100%;
    margin-top: 1rem;
    font-size: 1.1rem;
    padding: 1rem;
}

.btn-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.data-table tbody tr:hover {
    background: var(--hover-overlay);
}

.table-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
}

.table-action:hover {
    color: var(--primary);
}

/* Reports */
.report-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.list-group {
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.list-group li {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.list-group li:last-child {
    border-bottom: none;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.alert.warning {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid var(--secondary);
    color: var(--secondary);
}

/* Bottom Navbar (Mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav .nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    flex: 1;
    height: 100%;
    cursor: pointer;
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-app);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

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

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

/* Payment Details */
.payment-total {
    text-align: center;
    margin-bottom: 1.5rem;
}

.huge-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 0.5rem;
}

.payment-methods {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.method-btn {
    flex: 1;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
}

.method-btn.active {
    border-color: var(--primary);
    background: rgba(231, 76, 60, 0.1);
    color: var(--primary);
}

.huge {
    font-size: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.quick-cash-btns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.qc-btn {
    padding: 0.8rem 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
}

.qc-btn:hover {
    border-color: var(--primary);
}

.change-calc {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--hover-overlay);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.change-val {
    color: var(--accent);
}

.qris-box {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    display: inline-block;
    color: #000;
}

.qris-img {
    width: 200px;
    height: 200px;
}

/* Receipt Print styling */
.receipt-paper {
    background: #fff;
    color: #000;
    padding: 1.5rem;
    font-family: monospace;
    font-size: 0.85rem;
    margin: 0 auto;
    max-width: 350px;
}

.receipt-divider {
    margin: 0.5rem 0;
    text-align: center;
}

.receipt-items {
    margin: 1rem 0;
}

.receipt-item-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

@media print {
    body * {
        visibility: hidden;
    }

    #printable-receipt,
    #printable-receipt * {
        visibility: visible;
    }

    #printable-receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
    }

    .receipt-paper {
        max-width: 100%;
        box-shadow: none;
    }
}