:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --accent-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(16, 185, 129, 0.15);
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    color: var(--text-dark);
    min-height: 100vh;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

/* Navbar */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 5%;
    background: white;
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo h2 {
    margin: 0;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
    font-size: 1.5rem;
}

.logo h2 span {
    color: var(--accent-color);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-links a {
    color: var(--text-dark);
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.nav-links a:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-dark);
    border-radius: 3px;
    transition: all 0.3s ease;
}

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

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: white;
        padding: 1rem;
        gap: 0.5rem;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
        box-shadow: var(--shadow-md);
    }

    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }

    .nav-links a {
        width: 100%;
        text-align: center;
    }
}

/* Layout */
.container {
    padding: 2rem 5%;
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .container {
        padding: 1.5rem 4%;
    }
}

h1,
h2 {
    color: var(--text-dark);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

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

h3 {
    color: var(--text-dark);
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    padding: 1.2rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}

th {
    background: rgba(16, 185, 129, 0.08);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    color: var(--text-dark);
}

tr {
    transition: all 0.2s ease;
}

tr:hover {
    background: rgba(16, 185, 129, 0.05);
}

@media (max-width: 768px) {
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.8rem 0.5rem;
    }
    
    /* Stack table on very small screens */
    @media (max-width: 480px) {
        table, thead, tbody, th, td, tr {
            display: block;
        }
        
        thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }
        
        tr {
            margin-bottom: 1rem;
            border: 1px solid rgba(16, 185, 129, 0.2);
            border-radius: 12px;
            padding: 0.5rem;
            background: rgba(255, 255, 255, 0.5);
        }
        
        td {
            border: none;
            position: relative;
            padding-left: 50%;
        }
        
        td:before {
            position: absolute;
            left: 1rem;
            width: 45%;
            padding-right: 10px;
            white-space: nowrap;
            content: attr(data-label);
            font-weight: 600;
            color: var(--primary-color);
        }
    }
}

/* Forms */
input,
select,
textarea {
    width: 100%;
    padding: 0.9rem 1.2rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    color: var(--text-dark);
    font-size: 1rem;
    transition: all 0.3s ease;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    input, select, textarea {
        padding: 0.8rem 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.9rem 1.8rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
}

button.secondary {
    background: white;
    color: var(--text-dark);
    border: 2px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
}

button.secondary:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

@media (max-width: 768px) {
    button {
        padding: 0.8rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* Quantity controls */
.qty-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.2rem;
    min-width: unset;
}

/* Utilities */
.flex {
    display: flex;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

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

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

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

/* Responsive Grid */
@media (max-width: 1024px) {
    .flex.gap-2 {
        flex-direction: column;
    }
    
    .flex.gap-2 > div {
        width: 100% !important;
        flex: unset !important;
    }
}

/* Dashboard Cards */
.stat-card {
    text-align: center;
    padding: 2rem;
}

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

@media (max-width: 768px) {
    .stat-value {
        font-size: 2rem;
    }
}

/* Print Styles - Optimized for Thermal Printer (48mm and 72mm paper) */
@media print {
    body * {
        visibility: hidden;
    }

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

    #receipt-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 79mm; /* Default to 72mm width */
        max-width: 79mm;
        padding: 2mm;
        margin: 0;
        color: black !important;
        background: white !important;
        display: block !important;
        font-size: 10px;
        line-height: 1.3;
    }

    /* Support for 48mm paper width - uncomment to use 48mm */
    /* 
    #receipt-container {
        width: 48mm !important;
        max-width: 48mm !important;
        font-size: 8px !important;
    }
    @page {
        size: 48mm 297mm;
        margin: 0;
    }
    */

    /* Support for 72mm paper width (default) */
    @page {
        size: 72mm 297mm;
        margin: 0;
    }

    nav,
    .nav-links,
    button,
    #productSearch,
    .logo,
    .container>h1,
    .container>h2,
    .glass-card h1,
    .glass-card h2 {
        display: none !important;
    }

    /* Ensure receipt header elements are visible and styled */
    .receipt-header,
    .receipt-header *,
    .receipt-table,
    .receipt-table *,
    .receipt-footer,
    .receipt-footer * {
        visibility: visible !important;
        display: block !important;
    }

    .receipt-table {
        display: table !important;
    }

    .receipt-table thead,
    .receipt-table tbody {
        display: table-row-group !important;
    }

    .receipt-table tr {
        display: table-row !important;
    }

    .receipt-table th,
    .receipt-table td {
        display: table-cell !important;
    }

    .receipt-header h2 {
        display: block !important;
        visibility: visible !important;
        font-size: 14px !important;
        margin: 2mm 0 !important;
        line-height: 1.2 !important;
        color: black !important;
    }

    .receipt-header p {
        display: block !important;
        visibility: visible !important;
        font-size: 9px !important;
        margin: 1mm 0 !important;
        line-height: 1.2 !important;
        color: black !important;
    }

    .receipt-header hr {
        display: block !important;
        visibility: visible !important;
        margin: 2mm 0 !important;
        border: none;
        border-top: 1px dashed #000;
    }

    .receipt-table {
        display: table !important;
        visibility: visible !important;
        font-size: 9px !important;
        margin: 2mm 0 !important;
        width: 100% !important;
    }

    .receipt-table th,
    .receipt-table td {
        display: table-cell !important;
        visibility: visible !important;
        padding: 1mm 0 !important;
        font-size: 9px !important;
        color: black !important;
    }

    .receipt-table th {
        font-size: 10px !important;
        font-weight: bold !important;
        border-bottom: 1px solid #000 !important;
        padding: 1.5mm 0 !important;
    }

    .total-line {
        display: block !important;
        visibility: visible !important;
        font-size: 12px !important;
        padding-top: 2mm !important;
        margin-top: 2mm !important;
        margin-bottom: 3mm !important;
        color: black !important;
    }

    #receiptSavings {
        display: block !important;
        visibility: visible !important;
        font-size: 10px !important;
        margin: 0 !important;
        margin-bottom: 1mm !important;
        text-align: left !important;
        font-weight: 600 !important;
        color: black !important;
    }

    .receipt-footer {
        display: block !important;
        visibility: visible !important;
        margin-top: 2mm !important;
        padding-top: 2mm !important;
        border-top: 1px dashed #ccc;
    }

    .receipt-footer p {
        display: block !important;
        visibility: visible !important;
        font-size: 9px !important;
        margin: 1mm 0 !important;
        line-height: 1.2 !important;
        color: black !important;
    }
}

#receipt-container {
    display: none;
    font-size: 10px;
    padding: 2mm;
    background: white;
    color: black;
    max-width: 72mm;
    margin: 0 auto;
    line-height: 1.3;
}

.receipt-header {
    text-align: center;
    margin-bottom: 2mm;
}

.receipt-footer {
    text-align: center;
    margin-top: 2mm;
    border-top: 1px dashed #ccc;
    padding-top: 2mm;
    font-style: italic;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2mm 0;
}

.receipt-table th {
    text-align: left;
    border-bottom: 1px solid #000;
    padding: 1.5mm 0;
    font-size: 10px;
    font-weight: bold;
    color: black;
}

.receipt-table td {
    padding: 1mm 0;
    font-size: 9px;
    color: black;
}

.total-line {
    font-weight: bold;
    border-top: 2px solid #000;
    padding-top: 2mm;
    margin-top: 2mm;
    margin-bottom: 3mm;
    text-align: right;
    font-size: 12px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Links */
a {
    color: var(--primary-color);
    transition: all 0.3s ease;
}

a:hover {
    color: var(--accent-color);
}

/* Alert/Flash Messages */
.flash-message {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease;
    color: var(--text-dark);
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(16, 185, 129, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Card Grid Responsive */
@media (max-width: 768px) {
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* Enhanced Hover Effects */
.glass-card a,
.glass-card button {
    position: relative;
    z-index: 1;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .container {
        padding: 1rem 3%;
    }
    
    .glass-card {
        padding: 1.5rem;
        border-radius: 16px;
    }
    
    nav {
        padding: 1rem 4%;
    }
    
    .logo h2 {
        font-size: 1.2rem;
    }
}