:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F9FAFB;
    --surface: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --danger: #EF4444;
    --success: #10B981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.nav-links {
    list-style: none;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.nav-links a.active {
    background-color: var(--primary);
    color: white;
}

.nav-links .icon {
    margin-right: 12px;
    font-style: normal;
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.content-wrapper {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Layouts */
.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    height: 100%;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-content: start;
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.product-card .name {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.product-card .price {
    color: var(--primary);
    font-weight: 700;
    margin-top: auto;
}

.product-card .stock {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.product-card.out-of-stock {
    opacity: 0.5;
    pointer-events: none;
}

/* Cart Section */
.cart-section {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.cart-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1.1rem;
}

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

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

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

.cart-item-name {
    font-weight: 500;
    font-size: 0.95rem;
}

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

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

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

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

.cart-footer {
    padding: 24px;
    background: var(--bg-color);
    border-top: 1px solid var(--border);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.btn-checkout {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.data-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-danger {
    background: #FEF2F2;
    color: var(--danger);
    border: 1px solid #FCA5A5;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

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

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    width: 400px;
    max-width: 90%;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

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

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Mobile Responsive Styles */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 16px;
    color: var(--text-main);
}

.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Add an explicit wrapper class for table horizontal scrolling */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-md);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
    
    .pos-layout {
        grid-template-columns: 1fr;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    /* generic 2 col grids */
    .grid-2-cols {
        grid-template-columns: 1fr !important;
    }
    
    .content-wrapper {
        padding: 16px;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    /* Make tables responsive */
    .data-table {
        min-width: 600px; /* Forces scroll on small screens */
    }
    
    .cart-section {
        margin-top: 16px;
    }
    
    .modal-content {
        width: 95% !important;
        padding: 16px !important;
    }
}
