/* ==========================================================================
   Base Styles & Variables
   ========================================================================== */
   :root {
    /* Color Palette */
    --bg-dark: #f8f9fa;
    --bg-darker: #e9ecef;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-solid: #ffffff;
    --surface-light: #f1f3f5;
    
    --primary: #800000; /* Maroon */
    --primary-hover: #600000;
    --secondary: #000000; /* Black */
    --secondary-hover: #333333;
    
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    
    --text-main: #212529;
    --text-muted: #6c757d;
    --text-inverse: #ffffff;
    
    --border: rgba(0, 0, 0, 0.1);
    --border-light: rgba(0, 0, 0, 0.05);
    
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 15px rgba(245, 158, 11, 0.3);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
    
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(128, 0, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(0, 0, 0, 0.03) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
}

/* ==========================================================================
   Utilities & Common Components
   ========================================================================== */
.text-accent { color: var(--accent); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-success-dark { color: #064e3b; }
.text-muted { color: var(--text-muted); }

.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    font-family: var(--font-sans);
    font-size: 0.875rem;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.5);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text-inverse);
    border: 1px solid var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    border-color: var(--secondary-hover);
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

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

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

.icon-btn {
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--surface-solid);
    border-color: var(--border-light);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-sans);
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
#input-kot-printer-manual {
    transition: all var(--transition);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-main) !important;
}

.checkbox-label input {
    width: 1.2rem;
    height: 1.2rem;
}

/* Screen Management */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    height: 100%;
}

.view.active {
    display: block;
}

/* ==========================================================================
   Login Screen
   ========================================================================== */
#login-screen {
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    text-align: center;
}

.brand {
    margin-bottom: 2rem;
}

.brand i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: var(--shadow-glow);
}

.brand h1 {
    font-size: 2rem;
    letter-spacing: -0.02em;
}

.brand span {
    font-weight: 300;
    opacity: 0.8;
}

.pin-display input {
    width: 100%;
    text-align: center;
    font-size: 2rem;
    letter-spacing: 0.5em;
    padding: 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    margin-bottom: 1.5rem;
    outline: none;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.num-btn {
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 600;
    padding: 1rem 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.num-btn:hover {
    background: var(--surface-solid);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.num-btn:active {
    transform: translateY(0);
}

.action-btn {
    background: rgba(0, 0, 0, 0.05);
}

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

/* ==========================================================================
   App Layout Structure
   ========================================================================== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    margin: 1rem;
    height: 70px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
}

.header-nav {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.05);
}

.nav-btn.active {
    background: var(--surface-light);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.shift-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    background: var(--surface-light);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.app-main {
    flex: 1;
    overflow: hidden;
    padding: 0 1rem 1rem 1rem;
}

/* ==========================================================================
   Shift Screen
   ========================================================================== */
#shift-screen {
    align-items: center;
    justify-content: center;
}

#shift-screen.active {
    display: flex;
}

.shift-container {
    padding: 3rem;
    text-align: center;
    max-width: 400px;
}

.shift-container h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.shift-container p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.shift-container hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* ==========================================================================
   POS View
   ========================================================================== */
.pos-layout {
    display: flex;
    gap: 1rem;
    height: 100%;
}

.menu-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-filters {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scrollbar-width: thin;
}

.category-filters::-webkit-scrollbar {
    height: 4px;
}
.category-filters::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

.cat-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.cat-btn:hover {
    background: var(--surface-light);
    color: var(--text-main);
}

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

.menu-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding-right: 0.5rem;
    align-content: start;
}

.menu-grid::-webkit-scrollbar {
    width: 6px;
}
.menu-grid::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.product-card {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    min-height: 220px;
}

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

.product-img-wrap {
    height: 140px;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--surface-light) 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-img {
    transform: scale(1.1);
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    opacity: 0.6;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
}

.no-image i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.stock-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-main);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.stock-badge.low {
    background: rgba(239, 68, 68, 0.8);
}

.product-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.product-title {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.125rem;
}

/* Cart Section */
.cart-section {
    width: 350px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h3 {
    margin: 0;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-cart-msg {
    text-align: center;
    color: var(--text-muted);
    margin-top: 2rem;
    font-style: italic;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.cart-item-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

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

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: var(--surface-light);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.cart-item-qty {
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
}

.cart-summary {
    padding: 1.5rem;
    background: var(--surface-light);
    border-top: 1px solid var(--border);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.summary-row.total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-checkout {
    margin-top: 1.5rem;
    height: 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
}

/* ==========================================================================
   Admin View
   ========================================================================== */
.admin-layout {
    display: flex;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}

.admin-sidebar {
    width: 260px;
    background: var(--surface-light);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.admin-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-nav-item {
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.admin-nav-item:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

.admin-nav-item.active {
    background: var(--surface-solid);
    color: var(--primary);
    border-left-color: var(--primary);
}

.admin-nav-item i {
    width: 1.25rem;
    font-size: 1.1rem;
    text-align: center;
}

.admin-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.admin-panel {
    display: none;
    height: 100%;
    flex-direction: column;
}

.admin-panel.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-container {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    background: var(--surface-solid);
    z-index: 10;
}

.data-table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

.tb-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-darker);
}

.action-btns {
    display: flex;
    gap: 0.5rem;
}

/* Global Visibility Defaults */
.pos-mobile-tabs, .pos-mobile-cart-bar, .mobile-back-btn {
    display: none !important;
}

/* Layout */
.app-container {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Reports */
.report-container {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.report-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.report-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.report-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--surface-light);
    padding: 1rem;
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 0.5rem;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

#product-form, #staff-form {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Image Upload specific styles */
.image-upload-group {
    margin-top: 1rem;
}

.image-preview-container {
    width: 100%;
    height: 150px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-light);
    cursor: pointer;
    transition: all var(--transition);
}

.image-preview-container:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    gap: 0.5rem;
}

.upload-placeholder i {
    font-size: 2rem;
}

#product-image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--surface-solid);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

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

@keyframes fadeOut {
    to { opacity: 0; visibility: hidden; }
}

/* ==========================================================================
   Responsive Media Queries
   ========================================================================== */
/* ==========================================================================
   Bilingual Thermal Receipt Styles
   ========================================================================== */
.receipt-print {
    display: none;
    width: 80mm;
    padding: 5mm;
    background: white;
    color: black;
    font-family: 'Inter', sans-serif; /* Fallback to standard for browser, but browser print will handle it */
    font-size: 12px;
    line-height: 1.4;
}

@media print {
    body * { visibility: hidden; }
    #receipt-print-container, #receipt-print-container * { visibility: visible; }
    #receipt-print-container {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
    }
    .kot-print, .kot-print * { visibility: hidden; }
}

.receipt-logo {
    text-align: center;
    margin-bottom: 5px;
}

.receipt-logo i {
    font-size: 40px;
}

.receipt-header {
    text-align: center;
    margin-bottom: 15px;
}

.receipt-header h1 {
    font-size: 16px;
    margin-bottom: 2px;
    font-weight: 800;
}

.receipt-header p {
    font-size: 11px;
    margin: 0;
}

.bilingual-label {
    display: flex;
    justify-content: center;
    gap: 5px;
    font-size: 11px;
    color: #333;
    margin-bottom: 2px;
}

.invoice-no {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}

.receipt-info-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
}

.receipt-info-row .label {
    font-size: 10px;
    color: #444;
}

.receipt-info-row .value {
    font-size: 13px;
    font-weight: 700;
}

.receipt-meta-grid-bilingual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
    border-top: 1px dashed #ccc;
    padding-top: 10px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.receipt-items-bilingual {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
}

.receipt-items-bilingual th {
    font-size: 10px;
    padding: 5px 2px;
    border-bottom: 1px solid #ccc;
}

.receipt-items-bilingual td {
    padding: 5px 2px;
    font-size: 11px;
}

.receipt-totals-bilingual {
    margin-top: 10px;
}

.total-row-bilingual {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.total-row-bilingual .label-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 1;
}

.total-row-bilingual .value-col {
    width: 80px;
    text-align: right;
    font-weight: bold;
}

.grand-total {
    border-top: 1px solid #000;
    padding-top: 5px;
    margin-top: 5px;
    font-size: 14px;
}

.receipt-footer-bilingual {
    text-align: center;
    margin-top: 20px;
    font-size: 10px;
    font-style: italic;
}

/* ==========================================================================
   Responsive Media Queries
   ========================================================================== */

/* Tablet & Smaller (1024px and down) */
@media (max-width: 1024px) {
    body {
        overflow-y: auto; /* Allow scrolling for the whole page if needed on tablets */
    }

    .app-header {
        margin: 0.5rem;
        padding: 0.5rem 0.75rem;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .header-brand {
        justify-content: flex-start;
        gap: 0.5rem;
    }

    .header-nav {
        justify-content: flex-end;
        gap: 0.25rem;
    }

    .header-user {
        justify-content: space-between;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-light);
    }

    .pos-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .menu-section {
        overflow: visible;
    }

    .menu-grid {
        overflow: visible;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .cart-section {
        width: 100%;
        height: auto;
        max-height: none;
        margin-top: 1rem;
        position: sticky;
        bottom: 0;
        z-index: 100;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .cart-items {
        max-height: 300px;
    }

    .admin-layout {
        flex-direction: column;
        height: auto;
    }

    .admin-sidebar {
        width: 100%;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--surface);
    }

    .admin-nav {
        display: flex;
        flex-direction: row;
        padding: 0.5rem;
    }

    .admin-nav-item {
        padding: 0.75rem 1rem;
        white-space: nowrap;
        border-left: none !important;
        border-bottom: 3px solid transparent;
    }

    .admin-nav-item.active {
        border-bottom-color: var(--primary) !important;
        background: rgba(59, 130, 246, 0.05);
    }

    .admin-content {
        height: auto;
        min-height: 500px;
    }
}

/* Mobile Devices (768px and down) */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .app-main {
        padding: 0 0.5rem;
        height: calc(100vh - 80px); /* Adjust based on header height */
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .pos-layout {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .menu-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .menu-grid {
        flex: 1;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 100px; /* Room for mobile cart toggle if any */
    }

    .cart-section {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 2000;
        background: var(--surface-solid) !important;
        display: none;
        flex-direction: column;
    }

    .cart-section.active {
        display: flex;
    }

    /* Cart Header & Selectors stay at top */
    .cart-header, .order-type-selector, .payment-method-selector {
        flex-shrink: 0;
        padding: 0.5rem 1rem !important;
        margin-bottom: 0 !important;
    }

    .order-type-selector .btn, .payment-method-selector .btn {
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
    }

    .cart-items {
        flex: 1 1 auto;
        overflow-y: auto !important;
        padding: 0.5rem 1rem !important;
        min-height: 200px;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .cart-summary, .checkout-footer {
        flex-shrink: 0;
        background: var(--bg-darker);
        padding: 0.75rem 1rem;
        border-top: 1px solid var(--border);
    }

    .checkout-footer {
        padding-bottom: 2.5rem;
    }

    .cart-summary .summary-row {
        margin-bottom: 0.25rem;
        font-size: 0.9rem;
    }

    .admin-layout {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        height: 100%;
    }

    .admin-content {
        flex: 1;
        overflow-y: auto !important;
        padding: 0.5rem;
    }

    .table-container {
        width: 100%;
        overflow-x: auto !important;
        background: var(--surface);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
    }

    .data-table {
        min-width: 600px; /* Force scroll on small screens */
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 1rem;
        margin: auto;
    }

    .admin-panel {
        padding: 1rem !important;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .report-card {
        padding: 1rem !important;
    }

    .report-stat-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-box .stat-value {
        font-size: 1.5rem;
    }

    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        width: 100%;
        padding: 0.75rem 1rem;
    }
}

/* Extra Small Devices (480px and down) */
@media (max-width: 480px) {
    .header-brand h2 {
        font-size: 1.1rem;
    }
    
    .cat-btn {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }

    .btn-checkout {
        font-size: 1rem;
    }

    /* Horizontal Product Cards on Mobile */
    .menu-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .product-card {
        flex-direction: row !important;
        height: 100px !important;
        align-items: center !important;
    }

    .product-img-wrap {
        width: 100px !important;
        height: 100% !important;
        flex-shrink: 0 !important;
    }

    .product-info {
        padding: 1rem !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
    }

    .product-title {
        font-size: 1rem !important;
        margin-bottom: 0.25rem !important;
    }

    .product-price {
        font-size: 1.1rem !important;
    }
}

/* Landscape Mobile & Small Height Screens */
@media (max-height: 600px) {
    .login-container {
        padding: 1rem;
    }
    .brand {
        margin-bottom: 1rem;
    }
    .brand i {
        font-size: 2rem;
    }
}

/* ==========================================================================
   Print Styles for Receipts
   ========================================================================== */
.receipt-print, .kot-print {
    display: none;
    color: black;
    font-family: 'Courier New', Courier, monospace;
    width: 75mm;
    margin: 0 auto;
}

@media print {
    @page {
        margin: 0;
        size: 80mm auto;
    }
    
    /* Hide everything in the body by default during print */
    body > * {
        display: none !important;
    }
    
    /* Explicitly show ONLY the relevant container based on body class */
    body.print-receipt #receipt-print-container {
        display: block !important;
        position: relative;
        width: 75mm;
        padding: 4mm 2mm;
        margin: 0;
        background: white;
    }

    body.print-kot #kot-print-container {
        display: block !important;
        position: relative;
        width: 75mm;
        padding: 4mm 2mm;
        margin: 0;
        background: white;
    }

    /* Hide the OTHER one strictly */
    body.print-receipt #kot-print-container,
    body.print-kot #receipt-print-container {
        display: none !important;
    }
    
    /* Ensure all elements inside the active container are visible and BOLD BLACK */
    body.print-receipt #receipt-print-container *,
    body.print-kot #kot-print-container * {
        visibility: visible !important;
        color: #000 !important;
        font-weight: 900 !important;
        -webkit-print-color-adjust: exact;
    }
    
    .receipt-header h1, .receipt-header div {
        font-weight: 900 !important;
    }

    .receipt-items-bilingual th, .receipt-items-bilingual td {
        border: none !important;
        padding: 4px 0 !important;
        color: #000 !important;
    }

    .receipt-totals-bilingual {
        border-top: 2px solid #000 !important;
    }

    .total-row-bilingual {
        margin-bottom: 2px !important;
    }

    .grand-total {
        border-top: 2px solid #000 !important;
        padding-top: 5px !important;
        font-size: 20px !important;
    }
    
    .receipt-items {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 5px;
    }
    
    .receipt-items th {
        font-weight: 900;
        font-size: 16px;
        padding-bottom: 5px;
        border-bottom: 2px solid #000;
    }
    
    .receipt-items td {
        padding: 5px 0;
        font-size: 16px;
        font-weight: 800;
        border-bottom: 1px solid #000;
    }
    
    .text-left {
        text-align: left;
    }
    
    .text-right {
        text-align: right;
    }
    
    .receipt-totals {
        margin: 10px 0;
        border-top: 2px solid #000;
        padding-top: 5px;
    }
    
    .r-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 5px;
        font-size: 16px;
        font-weight: 800;
    }
    
    .total-row {
        font-size: 22px;
        font-weight: 900;
        margin-top: 10px;
        border-top: 2px solid #000;
        padding-top: 10px;
    }
    
    .receipt-meta-grid {
        font-size: 14px;
        margin: 8px 0;
        font-weight: 800;
    }
    
    .receipt-footer {
        text-align: center;
        margin-top: 5px;
    }
    
    .thank-you {
        font-weight: bold;
        font-size: 14px;
        letter-spacing: 1px;
        margin-bottom: 10px;
    }
    
    .barcode-dummy {
        display: flex;
        justify-content: center;
        height: 40px;
        margin: 0 auto;
        width: 80%;
        gap: 2px;
    }
    
    .barcode-dummy span {
        background: black;
        display: inline-block;
        height: 100%;
    }
    
    .barcode-dummy span:nth-child(even) { width: 2px; }
    .barcode-dummy span:nth-child(odd) { width: 4px; }
    .barcode-dummy span:nth-child(3n) { width: 1px; }
    .barcode-dummy span:nth-child(5n) { width: 6px; }
}

/* Offline Overlay */
.offline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    backdrop-filter: blur(10px);
}

.offline-overlay.active {
    display: flex;
}

.offline-content i {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.offline-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: white;
}

.offline-content p {
    color: var(--text-muted);
}

/* Install Button */
.btn-install {
    background: var(--accent) !important;
    color: var(--bg-dark) !important;
    font-weight: bold !important;
    border-radius: 20px !important;
    padding: 0.5rem 1.2rem !important;
    margin-left: 1rem !important;
}

.btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* ==========================================================================
   Mobile Sidebar & Responsive Navigation
   ========================================================================== */
.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Hidden by default */
    width: 280px;
    height: 100vh;
    background: var(--surface-solid);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--border);
}

.app-sidebar.active {
    transform: translateX(280px);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header .brand h1 {
    font-size: 1.5rem;
}

.sidebar-close-btn {
    background: var(--surface-light);
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-nav-btn i {
    font-size: 1.25rem;
}

.sidebar-nav-btn:hover {
    background: var(--surface-light);
    color: var(--text-main);
}

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

.sidebar-nav-btn.sub-item {
    margin-left: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.sidebar-nav-btn.sub-item.active {
    background: var(--surface-light);
    color: var(--primary);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-weight: 600;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
}

.sidebar-user-section {
    background: var(--surface-light);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.sidebar-shift-info {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Hide Mobile Elements by Default (Desktop) */
.pos-mobile-tabs, .pos-mobile-cart-bar, .sidebar-toggle-btn {
    display: none !important;
}

/* Responsive Overrides (Mobile) */
@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: block !important;
    }

    .header-nav {
        display: none !important; /* Hide header nav on mobile */
    }

    .app-header {
        padding: 0.5rem 1rem;
        margin: 0.5rem;
    }

    .header-user .user-info span {
        display: none; /* Hide username on mobile header */
    }

    .shift-info {
        display: none !important; /* Hide shift info on mobile header */
    }
    
    .pos-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 120px);
    }
    
    /* Mobile POS Specifics */
    .pos-mobile-tabs {
        display: flex !important;
        background: var(--surface-solid);
        border-bottom: 1px solid var(--border);
        margin: -1rem -1rem 0 -1rem; /* Removed bottom margin for categories */
        position: sticky;
        top: -1rem;
        z-index: 10;
    }

    .mobile-tab {
        flex: 1;
        padding: 1rem;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        border-bottom: 2px solid transparent;
        cursor: pointer;
    }

    .mobile-tab.active {
        color: var(--primary);
        border-bottom-color: var(--primary);
        background: rgba(128, 0, 0, 0.03);
    }

    /* Horizontal Category Pills */
    .category-filters {
        display: flex !important;
        overflow-x: auto;
        padding: 1rem;
        gap: 0.75rem;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none;  /* IE and Edge */
        background: var(--bg-dark);
        margin: 0 -1rem 1rem -1rem;
    }

    .category-filters::-webkit-scrollbar {
        display: none; /* Chrome, Safari and Opera */
    }

    .cat-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        background: var(--surface-light);
        border: 1px solid var(--border);
        padding: 0.6rem 1.2rem;
        border-radius: 25px;
        font-size: 0.875rem;
        color: var(--text-muted);
        transition: all var(--transition);
    }

    .cat-btn.active {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
        box-shadow: 0 4px 12px rgba(128, 0, 0, 0.2);
    }

    .mobile-tab .badge {
        background: var(--primary);
        color: white;
        font-size: 0.7rem;
        padding: 0.1rem 0.4rem;
        border-radius: 10px;
    }

    /* Toggle sections on mobile */
    .menu-section, .cart-section {
        display: none !important;
    }

    .menu-section.active, .cart-section.active {
        display: flex !important;
        flex-direction: column;
    }

    .mobile-back-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        width: 100%;
        padding: 0.875rem;
        background: var(--surface-light);
        border: 1px dashed var(--primary);
        border-radius: var(--radius-md);
        color: var(--primary);
        font-weight: 600;
        margin-bottom: 1.5rem;
        cursor: pointer;
    }

    .cart-section.active {
        position: fixed;
        top: 115px; /* Header + Tabs height */
        left: 0;
        width: 100%;
        height: calc(100vh - 115px);
        max-height: none;
        z-index: 50;
        margin: 0;
        border-radius: 0;
        padding: 1.5rem;
        padding-bottom: 100px; /* Space for bottom checkout */
        overflow-y: auto;
    }

    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .product-card {
        min-height: 190px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
        border: 1px solid var(--border);
    }

    .product-card:active {
        transform: scale(0.96);
    }

    .product-img-wrap {
        height: 110px;
    }

    .product-info {
        padding: 0.875rem;
    }

    .product-title {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
    }

    .product-price {
        font-size: 1.125rem;
        font-weight: 700;
    }

    /* Cart Item Card Styling for Mobile */
    .cart-item {
        background: var(--surface-light);
        padding: 1rem;
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        box-shadow: 0 2px 8px rgba(0,0,0,0.03);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

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

    .cart-item-name {
        font-weight: 600;
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .cart-item-price {
        color: var(--primary);
        font-weight: 700;
    }

    .cart-item-actions {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .qty-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: var(--surface-solid);
        border: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        cursor: pointer;
    }

    .btn-remove {
        color: var(--danger);
        background: rgba(239, 68, 68, 0.1);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .pos-mobile-cart-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--surface-solid);
        padding: 1rem 1.5rem;
        box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
        z-index: 100;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid var(--border);
        backdrop-filter: blur(15px);
        border-radius: 20px 20px 0 0;
    }

    .pos-mobile-cart-bar:not(.active) {
        display: none !important;
    }

    .bar-info {
        display: flex;
        flex-direction: column;
    }

    .bar-label {
        font-size: 0.75rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .bar-total {
        font-size: 1.5rem;
        font-weight: 800;
        color: var(--primary);
    }

    .cart-summary {
        background: var(--surface-light);
        padding: 1.5rem;
        border-radius: var(--radius-lg);
        margin-top: 1rem;
        margin-bottom: 2rem;
    }
}
