:root {
    --primary: #008080;
    --secondary: #FFB300;
    --bg-color: #F7F9FA;
    --card-bg: #FFFFFF;
    --text-color: #2D3748;
    --destructive: #E53E3E;
    --border-radius: 8px;
    --spacing: 16px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.container {
    padding: var(--spacing);
    max-width: 1450px;
    margin: 0 auto;
}

/* Headers */
header {
    background-color: var(--card-bg);
    padding: var(--spacing);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 1px solid #E2E8F0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
    padding: 4px;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: transparent; /* Invisible overlay to catch clicks to close menu */
    z-index: 90;
}

.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    color: #4A5568;
    cursor: pointer;
    text-align: left;
    padding: 0 0 16px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #E2E8F0;
    width: 100%;
}

@media (max-width: 768px) {
    .hamburger-btn {
        display: block;
    }
    
    .mobile-close-btn {
        display: block !important;
    }
    
    .header-controls {
        position: fixed;
        top: 0;
        right: -260px; /* hidden off-screen */
        width: 260px;
        height: 100vh;
        background-color: var(--card-bg);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 24px;
        box-shadow: -4px 0 15px rgba(0,0,0,0.1);
        z-index: 100;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        gap: 16px;
    }

    .header-controls.active {
        right: 0;
    }

    header {
        flex-wrap: nowrap;
    }

    header h1 {
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60vw;
    }

    .mobile-menu-overlay.active {
        display: block;
    }

    .header-controls > *:not(.mobile-close-btn) {
        width: 100% !important;
        margin: 0;
        justify-content: center;
        text-align: center;
    }
}

header h1 {
    font-size: 1.2rem;
    color: var(--primary);
}

/* Buttons */
.btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    width: 100%;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.8;
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--text-color);
}

.btn-destructive {
    background-color: var(--destructive);
    color: white;
    text-decoration: none;
    border: 1px solid #CBD5E0;
}

.btn-small {
    padding: 13px 18px;
    font-size: 14px;
    width: auto;
}

/* Inputs */
input,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #E2E8F0;
    border-radius: var(--border-radius);
    font-size: 16px;
    /* Prevents zoom on iOS */
    background-color: var(--card-bg);
    color: var(--text-color);
    margin-bottom: var(--spacing);
}

input:focus,
select:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

/* Cards & Layouts */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    border: 1px solid #E2E8F0;
    margin-bottom: var(--spacing);
}

/* Shop Grid Layout */
.pos-container {
    display: flex;
    gap: 16px;
    flex-direction: column;
}

.pos-sidebar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid #E2E8F0;
}

.pos-sidebar .btn {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 8px;
    min-width: 0;
    flex: 1 1 calc(50% - 8px);
    flex-shrink: 0;
}

.pos-sidebar .bill-history-section {
    flex: 1 1 100%;
    max-height: 200px;
    display: flex;
    flex-direction: column;
    margin-top: 4px;
    margin-bottom: 0;
    overflow: hidden;
}

.pos-sidebar #bill-history-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-content: start;
}

.pos-sidebar #bill-history-container .history-card {
    margin-bottom: 0;
}

@media (max-width: 1023px) and (orientation: landscape) {
    .pos-sidebar #bill-history-container {
        grid-template-columns: 1fr 1fr;
    }
}



.pos-content {
    flex: 1;
}

.shop-layout {
    display: flex;
    flex-direction: column;
    gap: var(--spacing);
}


.cash-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .shop-layout {
        flex-direction: row;
    }

    .pos-container {
        flex-direction: row;
    }

    .pos-sidebar {
        flex-direction: column;
        flex-wrap: nowrap;
        min-width: 220px;
        padding-right: 16px;
        margin-bottom: 0;
        padding-bottom: 0;
        border-right: 1px solid #E2E8F0;
        border-bottom: none;
        position: sticky;
        top: 80px;
        height: calc(100vh - 100px);
    }

    .pos-sidebar .btn {
        padding: 16px 24px;
        font-size: 16px;
        width: 100%;
        flex: none;
    }

    .pos-sidebar .bill-history-section {
        flex: 1;
        max-height: none;
    }

    .pos-sidebar #bill-history-container {
        padding-right: 8px;
    }

    .cash-layout {
        grid-template-columns: 1fr 2fr;
    }

    .product-grid {
        order: 1;
        flex: 2.6;
    }

    .cart-section {
        order: 2;
        flex: 1;
        position: sticky;
        top: 80px;
        height: calc(100vh - 100px);
        overflow-y: auto;
        min-width: 350px;
    }
}



.history-card {
    background-color: var(--card-bg);
    border: 4px solid #E2E8F0;
    border-radius: var(--border-radius);
    padding: 10px;
    margin-bottom: 20px;
    font-size: 16px;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--primary);
}

.history-card-details {
    color: #718096;
    font-size: 12px;
    margin-bottom: 8px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.product-card {
    background-color: var(--card-bg);
    border: 1px solid #E2E8F0;
    border-radius: var(--border-radius);
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.product-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
    image-rendering: crisp-edges;
    /* Keep images crisp */
    background-color: #f0f0f0;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    word-break: break-word;
}

.product-price {
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}

/* Cart Item */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E2E8F0;
    padding: 8px 0;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 600;
    font-size: 14px;
}

.cart-item-price {
    font-size: 12px;
    color: #718096;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* Bill Summary */
.bill-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px dashed #E2E8F0;
}

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

.summary-total {
    font-weight: bold;
    font-size: 18px;
    color: var(--primary);
}

/* Login box */
.login-box {
    max-width: 400px;
    margin: 80px auto;
}

/* Tables for Admin */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #E2E8F0;
}

.admin-table th {
    background-color: var(--bg-color);
    font-weight: 600;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

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

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    margin-top: 8px;
}

/* Receipt Screen Layout and Controls */
.receipt-page-container {
    display: flex;
    flex-direction: column;
    max-width: 950px;
    margin: 30px auto;
    gap: 24px;
    padding: 0 16px;
}

@media (min-width: 1024px) {
    .receipt-page-container {
        flex-direction: row;
        align-items: flex-start;
    }

    .print-controls-panel {
        flex: 1.2;
        position: sticky;
        top: 30px;
    }

    .receipt-preview-section {
        flex: 0.8;
        display: flex;
        justify-content: center;
    }
}

.print-controls-panel {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border: 1px solid #E2E8F0;
}

.receipt-preview-section {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Receipt container for realistic screen mockup */
.receipt-preview-card {
    background: white;
    width: var(--receipt-preview-width, 300px);
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid #E2E8F0;
    position: relative;
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--receipt-preview-font-size, 11px);
    line-height: var(--receipt-preview-line-height, 1.3);
    color: #000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), font-size 0.2s ease, line-height 0.2s ease;
}

/* Serrated edge effect on screen for retail billing software */
.receipt-preview-card::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(-135deg, white 4px, transparent 0), linear-gradient(135deg, white 4px, transparent 0);
    background-size: 8px 8px;
}

.receipt-header {
    text-align: center;
    margin-bottom: 8px;
    border-bottom: 1px dashed #000;
    padding-bottom: 6px;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.receipt-total {
    border-top: 1px dashed #000;
    margin-top: 6px;
    padding-top: 6px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

/* Form Groups for controls */
.control-group {
    margin-bottom: 18px;
}

.control-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text-color);
}

.width-toggle-buttons {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    flex: 1;
    background: #F7FAFC;
    border: 1px solid #E2E8F0;
    padding: 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-color);
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: #EDF2F7;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.slider-value {
    font-size: 12px;
    font-weight: 600;
    min-width: 32px;
    text-align: right;
    color: #718096;
}

/* Toggle Switch */
.switch-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    justify-content: space-between;
}

.switch-input {
    display: none;
}

.switch-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: #CBD5E0;
    border-radius: 34px;
    transition: background-color 0.2s;
}

.switch-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch-input:checked+.switch-slider {
    background-color: var(--primary);
}

.switch-input:checked+.switch-slider::before {
    transform: translateX(20px);
}

/* Step by Step Printer Setup Guide */
.setup-guide-box {
    background: #F7FAFC;
    border: 1px solid #E2E8F0;
    border-radius: var(--border-radius);
    padding: 16px;
    margin-top: 16px;
    display: none;
    /* Controlled via JS */
    animation: fadeIn 0.3s ease;
}

.setup-guide-box.show {
    display: block;
}

.setup-step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.setup-step:last-child {
    margin-bottom: 0;
}

.step-num {
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    margin-right: 10px;
    flex-shrink: 0;
    margin-top: 2px;
}

.step-text {
    color: #4A5568;
}

.step-text strong {
    color: var(--text-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

/* Receipt Print Styles */
@media print {
    @page {
        margin: 0;
    }

    body {
        background-color: white;
    }

    body> :not(#receipt-container) {
        display: none !important;
    }

    #receipt-container {
        display: block !important;
    }

    #receipt-container {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: var(--print-width, 58mm);
        margin: 0 !important;
        padding: 0 var(--print-padding, 2mm) !important;
        font-family: 'Courier New', Courier, monospace !important;
        font-size: var(--print-font-size, 11px) !important;
        color: #000 !important;
        line-height: var(--print-line-height, 1.2) !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
    }

    /* Hide scrollbars, decorative serrated borders etc in print */
    #receipt-container::after {
        display: none !important;
    }

    .no-print {
        display: none !important;
    }

    .receipt-header {
        text-align: center;
        margin-bottom: 8px;
        border-bottom: 1px dashed #000;
        padding-bottom: 4px;
    }

    .receipt-item {
        display: flex;
        justify-content: space-between;
        margin-bottom: 4px;
    }

    .receipt-total {
        border-top: 1px dashed #000;
        margin-top: 4px;
        padding-top: 4px;
        font-weight: bold;
        display: flex;
        justify-content: space-between;
    }
}

/* ==========================================================================
   Sleek Modern Modal System (Glassmorphic Overlay & Responsive Containment)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.25s ease-in-out;
    border: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: var(--spacing);
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #F7FAFC;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #A0AEC0;
    line-height: 1;
    transition: color 0.15s ease;
}

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

.modal-body {
    padding: var(--spacing);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--spacing);
    border-top: 1px solid #E2E8F0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background-color: #F7FAFC;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* Offline Receipt Wrapper on Screen for print preview modal */
.receipt-modal-preview-box {
    display: flex;
    justify-content: center;
    background-color: #EDF2F7;
    padding: var(--spacing);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: var(--spacing);
    border: 1px inset #E2E8F0;
}

        .cart-qty-ctrl input::-webkit-outer-spin-button,
        .cart-qty-ctrl input::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
    
/* Login Page Styles extracted from inline CSS */
.login-title {
    text-align: center;
    color: var(--primary);
    margin-bottom: 24px;
}

.alert-error {
    background-color: #FED7D7;
    color: var(--destructive);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 14px;
}

.alert-success {
    background-color: #C6F6D5;
    color: #22543D;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    border: 1px solid #38A169;
}

.form-group-md {
    margin-bottom: 16px;
}

.form-group-lg {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.desktop-pos-view {
    min-width: 1024px;
    overflow-x: auto;
}
