:root {
    --primary: #0d6efd;
    --secondary: #6c757d;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --light: #f8f9fa;
    --dark: #212529;
}

body {
    background-color: #f5f5f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding-top: 56px;
}

.category-nav {
    background-color: white;
    padding: 10px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1020;
    top: 56px;
}

.nav-scroll {
    display: flex;
    overflow-x: auto;
    padding: 0 15px;
    gap: 10px;
}

.category-btn {
    white-space: nowrap;
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    background-color: white;
    color: var(--dark);
    transition: all 0.3s;
    cursor: pointer;
}

.category-btn:hover, .category-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.menu-card {
    transition: transform 0.3s, box-shadow 0.3s;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    cursor: pointer;
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.menu-card .card-body {
    padding: 15px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-details {
    flex-grow: 1;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
}

.bill-card {
    border-left: 4px solid var(--primary);
    margin-bottom: 15px;
}

.bill-card.pending {
    border-left-color: var(--warning);
}

.bill-card.paid {
    border-left-color: var(--success);
}

/* Loading spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Alert positioning */
.alert.position-fixed {
    z-index: 9999;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .category-nav {
        top: 56px;
    }
    
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .cart-item-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
    
    .btn {
        min-height: 44px;
    }
}

/* Print styles */
@media print {
    .navbar, .category-nav, .btn {
        display: none !important;
    }
    
    body {
        background: white;
        padding-top: 0;
    }
}

/* Additional mobile fixes */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .menu-card {
        margin-bottom: 15px;
    }
    
    .category-btn {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .modal-dialog {
        margin: 10px;
    }
}

/* Ensure all buttons have proper cursor */
.btn, .category-btn {
    cursor: pointer;
}

/* Loading state for buttons */
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Install Prompt Styles */
#installPromptModal .modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#installPromptModal .modal-header {
    border-radius: 15px 15px 0 0;
}

#installPromptModal .modal-body {
    padding: 2rem;
}

#installPromptModal .modal-footer {
    border-radius: 0 0 15px 15px;
    border-top: 1px solid #dee2e6;
}

/* PWA Badge for already installed apps */
.pwa-badge {
    position: fixed;
    top: 70px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    z-index: 9999;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


/* Orientation-specific utility classes */
.landscape-mode .menu-card {
    transition: all 0.3s ease;
}

.landscape-mode .category-nav {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Better table layout for landscape bills */
.landscape-mode .bill-card .card-body {
    padding: 1rem;
}

.landscape-mode .bill-card .btn-group {
    flex-direction: row;
    gap: 5px;
}

/* Improved modal sizing for landscape */
.landscape-mode .modal-dialog {
    margin: 1rem auto;
}

/* Fix for virtual keyboard on mobile landscape */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .modal.show .modal-dialog {
        transform: none;
        margin: 10px auto;
    }
    
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }
}


/* Add Item Modal Styles */
#addItemModal .modal-xl {
    max-width: 95%;
}

#addItemModal .category-nav {
    position: relative;
    top: 0;
    background: transparent;
    border-bottom: 1px solid #dee2e6;
}

#addItemModal .menu-card {
    min-height: 120px;
}

#addItemModal .menu-card .card-body {
    padding: 12px;
}

#addItemModal .add-item-cart-item {
    padding: 8px 0;
}

#addItemModal .item-quantity {
    width: 70px;
}

#addItemCart {
    max-height: 300px;
    overflow-y: auto;
}

/* Print styles for added items */
@media print {
    body * {
        visibility: hidden;
    }
    
    .added-items-print, .added-items-print * {
        visibility: visible;
    }
    
    .added-items-print {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}

/* Split Bill Modal Styles */
.split-item-row {
    transition: background-color 0.2s ease;
}

.split-item-row:hover {
    background-color: #f8f9fa;
}

.split-item-row.bg-primary.bg-opacity-10 {
    border-left: 3px solid #0d6efd;
}

#splitSelectedItems .d-flex {
    padding: 8px;
    border-radius: 5px;
}

#splitSelectedItems .d-flex:hover {
    background-color: #f8f9fa;
}

.split-bill-btn {
    border-color: #ffc107;
    color: #856404;
}

.split-bill-btn:hover {
    background-color: #ffc107;
    color: #000;
}

/* Split bill modal specific */
#splitBillModal .modal-body {
    max-height: 80vh;
    overflow-y: auto;
}

#splitBillModal .card-header {
    border-radius: 0;
}

#splitBillModal .badge {
    font-size: 0.75rem;
}

/* ============================================
   LANDSCAPE RESPONSIVE FIXES FOR TABLETS
   ============================================ */

/* Split Bill Modal - Landscape Layout */
.split-bill-layout {
    display: flex;
    flex-wrap: wrap;
}

.split-items-col {
    flex: 0 0 58.333333%;
    max-width: 58.333333%;
}

.split-summary-col {
    flex: 0 0 41.666667%;
    max-width: 41.666667%;
}

/* Landscape mode for tablets (768px - 1366px) */
@media screen and (orientation: landscape) and (min-width: 768px) and (max-width: 1366px) {
    
    /* Split Bill Modal - Optimized for landscape */
    #splitBillModal .modal-dialog {
        max-width: 98%;
        margin: 0.5rem auto;
    }
    
    #splitBillModal .modal-body {
        max-height: 78vh;
        overflow-y: auto;
        padding: 0.75rem;
    }
    
    #splitBillModal .modal-header,
    #splitBillModal .modal-footer {
        padding: 0.5rem 1rem;
    }
    
    #splitBillModal .modal-header h5 {
        font-size: 1rem;
    }
    
    /* Two-column layout for split bill in landscape */
    .split-bill-layout {
        display: flex;
        flex-wrap: nowrap;
        gap: 10px;
    }
    
    .split-items-col {
        flex: 0 0 55%;
        max-width: 55%;
    }
    
    .split-summary-col {
        flex: 0 0 45%;
        max-width: 45%;
    }
    
    /* Reduce padding in landscape */
    #splitBillModal .card-body {
        padding: 0.5rem;
    }
    
    #splitBillModal .card-header {
        padding: 0.4rem 0.75rem;
    }
    
    #splitBillModal .card-header h6 {
        font-size: 0.85rem;
    }
    
    #splitBillModal .alert {
        padding: 0.4rem 0.75rem;
        margin-bottom: 0.5rem;
        font-size: 0.8rem;
    }
    
    #splitBillModal .alert .row > div {
        font-size: 0.8rem;
    }
    
    /* Split items list - compact */
    .split-items-body {
        max-height: 250px !important;
    }
    
    .split-item-row {
        padding: 0.35rem 0;
        margin-bottom: 0.35rem;
    }
    
    .split-item-row h6 {
        font-size: 0.85rem;
        margin-bottom: 0.15rem;
    }
    
    .split-item-row small {
        font-size: 0.7rem;
    }
    
    .split-item-row .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
    
    .split-item-row .btn-sm {
        padding: 0.15rem 0.4rem;
        font-size: 0.7rem;
    }
    
    /* Selected items list - compact */
    #splitSelectedItems .d-flex {
        padding: 0.3rem;
        margin-bottom: 0.3rem;
        font-size: 0.8rem;
    }
    
    #splitSelectedItems h6 {
        font-size: 0.8rem;
    }
    
    #splitSelectedItems small {
        font-size: 0.7rem;
    }
    
    /* Payment method radios - compact */
    #splitBillModal .form-check {
        margin-bottom: 0.25rem;
        font-size: 0.8rem;
    }
    
    #splitBillModal .form-check-label {
        font-size: 0.78rem;
    }
    
    /* Totals section - compact */
    #splitTotals .d-flex {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    #splitTotals .fs-5 {
        font-size: 0.95rem !important;
    }
    
    /* Combined payment input - compact */
    #splitCombinedSection .card-body {
        padding: 0.5rem;
    }
    
    #splitCombinedSection .form-control {
        padding: 0.25rem 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Service charge toggle - compact */
    #splitBillModal .form-switch .form-check-input {
        width: 2.5rem !important;
        height: 1.25rem !important;
    }
    
    /* Paid splits section - compact */
    #splitBillModal .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }
}

/* Small tablets landscape */
@media screen and (orientation: landscape) and (min-width: 768px) and (max-width: 1024px) {
    #splitBillModal .modal-dialog {
        max-width: 100%;
        margin: 0.25rem auto;
    }
    
    #splitBillModal .modal-body {
        max-height: 75vh;
        padding: 0.5rem;
    }
    
    .split-items-col {
        flex: 0 0 52%;
        max-width: 52%;
    }
    
    .split-summary-col {
        flex: 0 0 48%;
        max-width: 48%;
    }
    
    .split-items-body {
        max-height: 200px !important;
    }
    
    #splitBillModal .card-body {
        padding: 0.4rem;
    }
    
    #splitSelectedItems .d-flex {
        padding: 0.25rem;
        font-size: 0.75rem;
    }
    
    #splitBillModal .form-check {
        font-size: 0.75rem;
    }
    
    #splitBillModal .form-check-label {
        font-size: 0.72rem;
    }
}

/* Main app landscape optimizations for tablets */
@media screen and (orientation: landscape) and (min-width: 768px) and (max-width: 1366px) {
    
    /* Category navigation - more compact */
    .category-nav {
        padding: 6px 0;
    }
    
    .category-btn {
        padding: 6px 14px;
        font-size: 0.85rem;
    }
    
    /* Menu cards - better grid in landscape */
    .menu-card .card-body {
        padding: 10px;
    }
    
    .menu-card h5 {
        font-size: 0.95rem;
    }
    
    .menu-card .card-text {
        font-size: 0.8rem;
    }
    
    /* Stats bar - compact */
    .stats-bar {
        padding: 8px 15px;
        margin-bottom: 12px;
    }
    
    /* Cart modal - landscape optimization */
    #cartModal .modal-dialog {
        max-width: 90%;
    }
    
    #cartModal .modal-body {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* Bill modal - landscape optimization */
    #billModal .modal-dialog {
        max-width: 90%;
    }
    
    #billModal .modal-body {
        max-height: 75vh;
        overflow-y: auto;
    }
    
    /* Add item modal - landscape optimization */
    #addItemModal .modal-dialog {
        max-width: 98%;
        margin: 0.25rem auto;
    }
    
    #addItemModal .modal-body {
        max-height: 80vh;
        overflow-y: auto;
        padding: 0.75rem;
    }
    
    #addItemModal .card-body {
        padding: 0.5rem;
    }
    
    #addItemModal .menu-card {
        min-height: 100px;
    }
    
    #addItemModal .menu-card .card-body {
        padding: 8px;
    }
    
    #addItemModal .menu-card h6 {
        font-size: 0.85rem;
    }
    
    #addItemModal .menu-card .card-text {
        font-size: 0.75rem;
    }
    
    /* Item modal - landscape */
    #itemModal .modal-dialog {
        max-width: 500px;
        margin: 0.5rem auto;
    }
    
    #itemModal .modal-body {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* Toast container - landscape */
    .toast-container {
        top: auto !important;
        bottom: 10px !important;
        right: 10px !important;
    }
}

/* Very small landscape (phones) */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .split-bill-layout {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    
    .split-items-col {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .split-summary-col {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    #splitBillModal .modal-body {
        max-height: 70vh;
        padding: 0.35rem;
    }
    
    .split-items-body {
        max-height: 150px !important;
    }
    
    #splitBillModal .card-body {
        padding: 0.3rem;
    }
    
    #splitSelectedItems .d-flex {
        padding: 0.15rem;
        font-size: 0.7rem;
    }
    
    #splitBillModal .form-check {
        font-size: 0.7rem;
    }
    
    #splitBillModal .form-check-label {
        font-size: 0.68rem;
    }
    
    #splitTotals .d-flex {
        font-size: 0.72rem;
    }
    
    #splitTotals .fs-5 {
        font-size: 0.85rem !important;
    }
}

/* Portrait mode for tablets - keep two columns */
@media screen and (orientation: portrait) and (min-width: 768px) and (max-width: 1024px) {
    .split-items-col {
        flex: 0 0 55%;
        max-width: 55%;
    }
    
    .split-summary-col {
        flex: 0 0 45%;
        max-width: 45%;
    }
    
    #splitBillModal .modal-body {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* Fix for Bootstrap columns in split bill layout */
.split-bill-layout .col-lg-7,
.split-bill-layout .col-lg-5 {
    padding-left: 8px;
    padding-right: 8px;
}

/* Ensure buttons are touch-friendly in landscape */
@media screen and (orientation: landscape) {
    .split-item-row .btn-sm,
    #splitSelectedItems .btn-sm {
        min-height: 32px;
        min-width: 32px;
    }
    
    #splitBillModal .form-check-input {
        width: 1.1rem;
        height: 1.1rem;
    }
}

/* Fix for split bill modal in landscape - prevent overflow */
#splitBillModal .modal-content {
    max-height: 96vh;
    overflow: hidden;
}

#splitBillModal .modal-body {
    overflow-y: auto;
}

/* Make the split modal larger in landscape */
@media screen and (orientation: landscape) and (min-width: 1024px) {
    #splitBillModal .modal-dialog {
        max-width: 95%;
    }
    
    .split-items-col {
        flex: 0 0 60%;
        max-width: 60%;
    }
    
    .split-summary-col {
        flex: 0 0 40%;
        max-width: 40%;
    }
    
    .split-items-body {
        max-height: 350px !important;
    }
}