:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: var(--text-color);
    line-height: 1.6;
}

/* Font Size Utilities */
body.font-small {
    font-size: 14px;
}

body.font-medium {
    font-size: 16px;
}

body.font-large {
    font-size: 18px;
}

body.font-extra-large {
    font-size: 20px;
}

button {
    font-size: inherit;
}

input,
select,
textarea {
    font-size: inherit;
}

/* Light Theme (Default) */
body.theme-light {
    background-color: #ffffff;
    color: var(--text-color);
}

body.theme-light .navbar {
    background-color: var(--primary-color);
    color: white;
}

body.theme-light .sidebar {
    background-color: var(--light-bg);
    border-right: 2px solid var(--border-color);
}

/* Dark Theme */
body.theme-dark {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.theme-dark .navbar {
    background-color: #000;
    color: white;
}

body.theme-dark .sidebar {
    background-color: #222;
    border-right: 2px solid #444;
}

body.theme-dark .card {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background-color: #333;
    color: #e0e0e0;
    border-color: #555;
}

/* High Contrast Theme */
body.theme-highcontrast {
    background-color: #ffffff;
    color: #000000;
}

body.theme-highcontrast .navbar {
    background-color: #000;
    color: #ffff00;
    border: 3px solid #ffff00;
}

body.theme-highcontrast .btn {
    border: 3px solid #000;
    font-weight: bold;
}

body.theme-highcontrast .sidebar {
    background-color: #ffff00;
    color: #000;
    border-right: 3px solid #000;
}

body.theme-highcontrast input,
body.theme-highcontrast select,
body.theme-highcontrast textarea {
    background-color: #ffffff;
    color: #000;
    border: 3px solid #000;
}

/* Layout */
.navbar {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar h1 {
    font-size: 1.8rem;
    margin: 0;
}

.navbar-menu {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.navbar-menu a {
    color: inherit;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.navbar-menu a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.container {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 250px;
    padding: 2rem 1rem;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: inherit;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    min-height: 50px;
    min-width: 50px;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #229954;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #d68910;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.2em;
    min-height: 60px;
    min-width: 60px;
}

.btn-xl {
    padding: 1.5rem 2.5rem;
    font-size: 1.5em;
    min-height: 80px;
    min-width: 80px;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* Cards */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

.card-body {
    margin-top: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin-right: 0.5rem;
    cursor: pointer;
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.form-check label {
    margin: 0;
    margin-left: 0.5rem;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.table th {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: bold;
    font-size: 1.1rem;
}

.table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background-color: var(--light-bg);
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 5px solid;
    border-radius: 4px;
    font-size: 1rem;
}

.alert-success {
    background-color: #d4edda;
    border-color: var(--success-color);
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: var(--danger-color);
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: var(--warning-color);
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: var(--secondary-color);
    color: #0c5460;
}

/* POS Specific */
.pos-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    height: 100%;
}

.pos-cart {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.product-card {
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.product-card:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.product-name {
    font-weight: bold;
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.product-price {
    color: var(--success-color);
    font-size: 1.3rem;
    font-weight: bold;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.cart-item-name {
    font-weight: 600;
}

.cart-item-qty {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.qty-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
    min-width: 30px;
    min-height: 30px;
}

.cart-summary {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 1.1rem;
}

.summary-total {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav a,
.sidebar-nav button {
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    background: none;
    border: none;
    text-align: left;
    border-radius: 4px;
    cursor: pointer;
    font-size: inherit;
    transition: background-color 0.3s;
}

.sidebar-nav a:hover,
.sidebar-nav button:hover {
    background-color: rgba(52, 152, 219, 0.2);
    color: var(--secondary-color);
}

.sidebar-nav a.active {
    background-color: var(--secondary-color);
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

.modal-footer {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Mobile Navigation */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .navbar {
        flex-wrap: wrap;
        padding: 0.8rem 1rem;
    }

    .navbar-menu {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        background-color: var(--primary-color);
        margin-top: 1rem;
        border-radius: 8px;
        overflow: hidden;
    }

    body.theme-dark .navbar-menu {
        background-color: #000;
    }

    .navbar-menu.active {
        display: flex;
    }

    .navbar-menu a {
        width: 100%;
        padding: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0;
    }

    .navbar-menu a:last-child {
        border-bottom: none;
    }

    .container {
        flex-direction: column;
    }

    .sidebar {
        display: none;
        /* Hide sidebar on mobile */
    }

    .main-content {
        padding: 1rem;
    }

    .pos-container {
        grid-template-columns: 1fr;
        padding-top: 0;
    }

    /* Sticky Search Header */
    .pos-search-header-mobile {
        position: sticky;
        top: 60px;
        /* Below navbar */
        background: white;
        z-index: 900;
        /* Reduced from 1001 to ensure modals stay on top */
        padding: 0.5rem;
        margin: -1rem -1rem 1rem -1rem;
        border-bottom: 2px solid var(--border-color);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    }

    body.theme-dark .pos-search-header-mobile {
        background: #1a1a1a;
    }

    .product-grid {
        display: none !important;
        /* Hide grid on mobile as requested */
    }

    /* Mobile Search Dropdown */
    .search-results-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border: 2px solid var(--secondary-color);
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        z-index: 2000;
        max-height: 300px;
        overflow-y: auto;
    }

    body.theme-dark .search-results-dropdown {
        background: #222;
        border-color: #444;
    }

    .search-result-item {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .search-result-item:last-child {
        border-bottom: none;
    }

    .search-result-item:hover {
        background-color: var(--light-bg);
    }

    .product-card {
        padding: 0.8rem;
    }

    .btn-xl {
        padding: 1rem;
        font-size: 1.2rem;
        min-height: 60px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Floating Cart Button for Mobile if needed, but for now we'll stick to basic stack */
    /* Mobile Action Bar */
    .mobile-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        display: flex;
        justify-content: space-around;
        padding: 0.5rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        border-top: 1px solid var(--border-color);
    }

    body.theme-dark .mobile-action-bar {
        background: #222;
        border-top-color: #444;
    }

    .mobile-action-bar .btn {
        flex: 1;
        margin: 0 0.5rem;
        padding: 0.5rem;
        font-size: 0.9rem;
        flex-direction: column;
        height: auto;
        min-height: 55px;
        gap: 2px;
    }

    .mobile-action-bar .btn span {
        font-size: 0.75rem;
    }

    /* Adjust main content padding to account for action bar */
    .main-content {
        padding-bottom: 80px;
    }

    /* Make cards more compact on mobile */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card-header {
        font-size: 1.1rem;
        padding-bottom: 0.5rem;
    }

    /* Fixed POS Summary for Mobile */
    .pos-mobile-summary {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 0.8rem;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
        z-index: 999;
        max-height: 50vh;
        /* Reduced from 80vh */
        overflow-y: auto;
        border-top: 3px solid var(--secondary-color);
        display: none;
    }

    body.theme-dark .pos-mobile-summary {
        background: #222;
        border-top-color: var(--secondary-color);
    }

    .pos-mobile-summary .summary-row {
        padding: 0.3rem 0;
        font-size: 1rem;
    }

    .pos-mobile-summary .summary-total {
        font-size: 1.3rem;
    }

    /* Adjust padding for POS container on mobile */
    .pos-container {
        padding-bottom: 140px;
        /* Further reduced from 220px */
    }

    /* Cart Item compact styles for mobile */
    .cart-item {
        padding: 0.4rem;
        gap: 0.4rem;
    }

    #cart-items {
        max-height: 55vh !important;
    }

    .pos-mobile-summary .btn-xl,
    .pos-mobile-summary .btn-lg {
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.desktop-only {
    display: inherit;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }
}

.pos-cart.mobile-margin-top {
    margin-top: 1.5rem;
}

/* Ensure cart items list is scrollable and visible */
#cart-items {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .pos-cart .card-header {
        margin-top: 1rem;
        /* Space from sticky search */
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.p-1 {
    padding: 0.5rem;
}

.p-2 {
    padding: 1rem;
}

.p-3 {
    padding: 1.5rem;
}

.hidden {
    display: none;
}

.flex {
    display: flex;
    align-items: center;
}

.flex-between {
    justify-content: space-between;
}

.flex-center {
    justify-content: center;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

.text-muted {
    color: #6c757d;
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-warning {
    color: var(--warning-color);
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .flex-responsive {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .flex-responsive.gap-1 {
        gap: 0.5rem;
    }

    .flex-responsive.gap-2 {
        gap: 1rem;
    }

    .flex-responsive.gap-3 {
        gap: 1.5rem;
    }

    .flex-responsive>* {
        width: 100% !important;
    }
}

/* Table Responsive Fixes */
.table-responsive {
    width: 100%;
    margin-bottom: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
    margin-bottom: 0;
    min-width: 600px;
    /* Force scroll on small screens */
}