:root {
    --primary-color: #6C63FF;
    --primary-dark: #4B0082;
    --bg-color: #F8F9FA;
    --white: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;

    --success-color: #2ECC71;
    --danger-color: #E74C3C;
    --warning-color: #F1C40F;
    --info-color: #3498DB;

    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;

    --secondary-color: #3498DB;
    /* Make consistent with info color or choose distinct */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    /* Desktop: Use block flow to handle fixed sidebar naturally */
    display: block;
    min-height: 100vh;
    position: relative;
    padding-right: 250px;
    /* Reserve space for fixed sidebar (RTL) */
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--white);
    padding: 2rem 1rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    right: 0;
    top: 0;
    z-index: 1001;
    /* High z-index for mobile overlap */
    transition: transform 0.3s ease-in-out;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    margin-bottom: 3rem;
    font-size: 1.2rem;
    padding: 0 1rem;
}

.sidebar ul {
    list-style: none;
    overflow-y: auto;
    /* Allow scroll if menu is long */
}

.sidebar li {
    padding: 1rem 1.2rem;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.sidebar li:hover {
    background-color: #F0F0FF;
    color: var(--primary-color);
}

.sidebar li.active {
    background-color: #8e44ad !important;
    color: var(--white);
    box-shadow: 0 4px 10px rgba(142, 68, 173, 0.4);
    font-weight: bold;
}

/* Mobile Toggle & Overlay */
.mobile-toggle {
    display: none;
    /* Hidden on desktop */
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1002;
    background: var(--white);
    border: none;
    padding: 10px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Main Content */
.content {
    /* No margin or calc width needed if container defines padding */
    width: 100%;
    padding: 2rem 3rem;
    transition: var(--transition);
}

/* Ensure mobile toggle is hidden on desktop */
.mobile-toggle {
    display: none !important;
}

header {
    margin-bottom: 1rem;
    text-align: center;
}


#reports-section header {
    margin-bottom: 0.5rem;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-overlay.hidden {
    display: none;
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.permissions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 8px;
    text-align: right;
}

.permissions-list label {
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.permissions-list input {
    width: auto;
}

header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
}

/* Modules & Animations */
.module {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.module.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards & Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    /* Reduced min-width */
    gap: 1.5rem;
}

.card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: var(--transition);
    overflow: hidden;
    /* Contain content */
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
}

.full-width {
    grid-column: 1 / -1;
    max-width: 100%;
}

.card-header {
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.highlight-revenue {
    color: var(--success-color);
}

.highlight-expense {
    color: var(--danger-color);
}

.highlight-primary {
    color: var(--primary-color);
}

/* Finance Action Cards */
.action-card {
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
}

.action-card:hover {
    border-color: var(--primary-color);
}

.icon-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.revenue-icon {
    background: var(--success-color);
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3);
}

.expense-icon {
    background: var(--danger-color);
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}

.cashier-icon {
    background: var(--primary-color);
    box-shadow: 0 4px 10px rgba(108, 99, 255, 0.3);
}

.payment-icon {
    background: #E67E22;
    box-shadow: 0 4px 10px rgba(230, 126, 34, 0.3);
}

.purchase-icon {
    background: #9b59b6;
    box-shadow: 0 4px 10px rgba(155, 89, 182, 0.3);
}

/* Finance Icons Grid - New Modern Design */
.finance-icons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.finance-icon-card {
    aspect-ratio: 1;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    color: white;
    padding: 1rem;
}

.finance-icon-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.finance-icon-card:active {
    transform: translateY(-2px) scale(0.98);
}

.finance-icon-card i {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.finance-icon-card span {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}


/* Forms & Inputs */
.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    background: #FAFAFA;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

input[readonly] {
    background-color: #EEE;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: 8px;
    color: var(--white);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-revenue {
    background-color: var(--success-color);
}

.btn-revenue:hover {
    background-color: #27ae60;
}

.btn-expense {
    background-color: var(--danger-color);
}

.btn-expense:hover {
    background-color: #c0392b;
}

.btn-back {
    background: rgba(108, 99, 255, 0.1);
    /* Light Primary Tint */
    border: 1px solid rgba(108, 99, 255, 0.2);
    color: var(--primary-color);
    /* Clear Primary Color */
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
    display: inline-flex;
    /* Better fitting */
    align-items: center;
    gap: 8px;
    width: auto;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    /* Pill Shape */
    transition: var(--transition);
}

.btn-back:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateX(-5px);
    /* Slide effect for 'back' */
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.25);
}

/* Hidden utilities */
.hidden-section {
    display: none;
}

.hidden {
    display: none;
}

/* Reports Table */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    flex: 1;
    min-width: 140px;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
    margin: 0 -1.5rem;
    /* Negative margin to let table check full width on mobile card */
    padding: 0 1.5rem;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    min-width: 600px;
    /* Ensure table doesn't squash too much */
}

.report-table th,
.report-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid #EEE;
    white-space: nowrap;
    /* Prevent awkward wrapping in cells */
}

.report-table th {
    background-color: #F8F9FA;
    color: var(--text-secondary);
    font-weight: 600;
}

.report-table tr:hover {
    background-color: #FDFDFD;
}

/* Status & Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.5s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 20001;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    bottom: 50px;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
    color: #333;
}

.status-indicator {
    position: absolute;
    top: 2rem;
    left: 2rem;
    background: white;
    padding: 8px 16px;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    z-index: 900;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ccc;
    transition: var(--transition);
}

.status-indicator.online .status-dot {
    background-color: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
}

.status-indicator.online #status-text {
    color: var(--success-color);
}

.status-indicator.offline .status-dot {
    background-color: #f39c12;
}

.status-indicator.offline #status-text {
    color: #f39c12;
}

#queue-badge {
    background: #e74c3c;
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

#queue-badge.hidden {
    display: none;
}

.summary-card {
    text-align: center;
    border-left: 5px solid var(--primary-color);
}

.summary-card h3 {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.summary-card .amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.invoice-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Multi-Order Tabs */
.active-order-tab {
    padding: 6px 12px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #555;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    border: 1px solid #ddd;
    transition: all 0.2s;
}

.active-order-tab:hover {
    background: #e0e0e0;
}

.active-order-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 2px 5px rgba(108, 99, 255, 0.3);
}

.active-order-tab .badge {
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 10px;
}

.active-order-tab.new-btn {
    background: #e8f5e9;
    color: #2ecc71;
    border-color: #a5d6a7;
    border-style: dashed;
}

.active-order-tab.new-btn:hover {
    background: #c8e6c9;
}

.total-field {
    font-weight: bold;
    color: var(--primary-dark);
    background-color: #f3e5f5 !important;
}

/* === RESPONSIVE DESIGN === */

/* Summary Mini Cards for External Reports */
.summary-mini-card {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    transition: var(--transition);
}

.summary-mini-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.summary-mini-card .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.summary-mini-card .value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-warning {
    color: #e67e22 !important;
}

.text-primary {
    color: var(--primary-color) !important;
}



@media (max-width: 900px) {
    .content {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .container {
        display: block !important;
        padding-right: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        min-height: auto;
        /* Allow auto height */
        height: auto;
    }

    html,
    body {
        height: auto !important;
        min-height: 100vh;
        overflow-x: hidden;
    }

    /* Sidebar becomes off-canvas */
    .sidebar {
        right: 0;
        transform: translateX(100%);
        width: 280px;
        height: 100vh;
        z-index: 1001;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .sidebar-overlay {
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .mobile-toggle {
        display: block;
    }

    /* Mobile Header (Top Purple Bar) */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(135deg, var(--primary-color) 0%, #5a52d5 100%);
        color: white;
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
        padding-top: env(safe-area-inset-top);
        box-shadow: 0 2px 10px rgba(108, 99, 255, 0.15);
        z-index: 1001;
    }

    .mobile-menu-btn,
    .mobile-notification-btn {
        background: none;
        border: none;
        color: white;
        font-size: 1.3rem;
        cursor: pointer;
        padding: 8px;
        border-radius: 8px;
        transition: background 0.2s;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-btn:active,
    .mobile-notification-btn:active {
        background: rgba(255, 255, 255, 0.1);
    }

    .mobile-brand {
        font-size: 1.3rem;
        font-weight: 700;
        letter-spacing: 0.5px;
        margin: 0;
        color: white;
    }

    /* Bottom Navigation */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
        padding: 8px 0;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 1000;
        justify-content: space-around;
    }

    .bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #94a3b8;
        font-size: 0.7rem;
        flex: 1;
        gap: 3px;
        transition: all 0.2s;
        padding: 5px;
        position: relative;
    }

    .bottom-nav .nav-item i {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .bottom-nav .nav-item.active {
        color: var(--primary-color);
        font-weight: 600;
    }

    .bottom-nav .nav-item.active i {
        transform: translateY(-2px);
    }

    .bottom-nav .nav-item:active {
        transform: scale(0.95);
    }

    .content {
        margin-right: 0;
        width: 100%;
        padding: 1rem;
        padding-top: 80px;
        /* Reduced from 110px */
        padding-bottom: 80px;
        /* Reduced from 200px */
        overflow-x: hidden;
        display: block;
        /* Ensure block layout */
        min-height: calc(100vh - 80px);
        /* Ensure it consumes space but doesn't force scroll */
    }

    /* Add extra margin to cards and forms to prevent overlap */
    .card {
        margin-bottom: 2rem;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    .form-section,
    .list-section {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    .form-group {
        width: 100%;
    }

    .btn {
        margin-bottom: 1.5rem;
    }

    /* Adjust Status Indicator */
    .status-indicator {
        position: fixed;
        top: 70px;
        left: 15px;
        font-size: 0.8rem;
        padding: 6px 12px;
        z-index: 900;
    }

    /* Stack Grids */
    .grid-2 {
        grid-template-columns: 1fr !important;
        width: 100%;
        gap: 1rem;
    }

    /* Tables */
    .report-table th,
    .report-table td {
        padding: 0.8rem;
        font-size: 0.9rem;
    }

    /* Typography */
    header h1 {
        font-size: 1.5rem;
    }
}

/* === Mobile Navigation === */
.mobile-header {
    display: none;
    /* Hidden on desktop */
}

.bottom-nav {
    display: none;
    /* Hidden on desktop */
}






.mobile-toggle {
    display: none !important;
}

/* Chat Modal Styles */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 1;
    pointer-events: all;
    transition: opacity 0.3s ease;
}

.chat-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Confirmation Modal - Always on top of other modals */
#confirm-modal {
    z-index: 20000;
}

/* Removed Animation to prevent ghosting issues */
.chat-container {
    background: white;
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    height: auto;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: none !important;
    opacity: 1 !important;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5a52d5 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 1rem 1rem 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f5f5f5;
}

.chat-message {
    display: flex;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.bot-message .message-content {
    background: white;
    border-bottom-left-radius: 0.25rem;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5a52d5 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message-content p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-input-container {
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 1rem 1rem;
    display: flex;
    gap: 0.75rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 2rem;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: var(--primary-color);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5a52d5 100%);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: transform 0.2s;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* === POS SYSTEM STYLES === */
.pos-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1rem;
    height: calc(100vh - 4rem);
    /* Full height minus header/padding */
    overflow: hidden;
}

/* Left Panel (Cart) */
.pos-left-panel {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    height: 100%;
}

.pos-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.pos-cart-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #eee;
}

.pos-cart-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 30px;
    padding: 0.8rem;
    background: #e9ecef;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.cart-item {
    display: grid;
    grid-template-columns: 80px 80px 60px 1fr;
    /* Total, Price, Qty, Item */
    padding: 8px 5px;
    border-bottom: 1px solid #eee;
    align-items: center;
    text-align: center;
    font-size: 0.95rem;
    background: white;
    margin-bottom: 0;
    border-radius: 0;
    cursor: pointer;
    position: relative;
}

.cart-item:hover {
    background: #f5f5f5;
}

/* Explicit class for Item Column to handle alignment */
.cart-item-col-name {
    text-align: right;
    /* Item name is Arabic, align Right meaning start of cell in RTL */
    padding-right: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

/* Order Number Badge color fix */
.order-number-badge {
    color: #000 !important;
    /* Force Black */
}

.cart-item:last-child {
    border-bottom: none;
}

.pos-totals {
    margin-top: 1rem;
    padding: 1rem;
    background: #e9ecef;
    border-radius: 8px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.pos-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-pos-action {
    height: 50px;
    font-size: 1rem;
}

/* Right Panel (Products) */
.pos-right-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    overflow: hidden;
}

.pos-categories-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
}

.cat-tab {
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    transition: all 0.2s;
}

.cat-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 8px rgba(108, 99, 255, 0.3);
}

.pos-sub-categories {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 40px;
}

.sub-cat-tab {
    padding: 0.5rem 1rem;
    background: #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
}

.sub-cat-tab.active {
    background: var(--secondary-color);
    color: white;
}

.pos-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.5rem;
    flex: 1;
}

.product-btn {
    aspect-ratio: 1.2;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    cursor: pointer;
    transition: transform 0.1s;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-primary);
    border-bottom: 4px solid #ddd;
}

.product-btn:active {
    transform: scale(0.95);
    border-bottom-width: 0;
    margin-top: 4px;
}

/* Dynamic Colors for Products based on Category (optional, handled in JS) */
.product-btn.color-1 {
    border-bottom-color: #E74C3C;
}

.product-btn.color-2 {
    border-bottom-color: #F1C40F;
}

.product-btn.color-3 {
    border-bottom-color: #2ECC71;
}

@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        height: auto;
        overflow: visible;
    }

    .pos-left-panel,
    .pos-right-panel {
        height: 600px;
        /* Fixed height for scrollable areas on mobile */
    }
}

/* Recipe Manager Sidebar Styles */
.product-list-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s, padding-right 0.2s;
    font-size: 0.95rem;
    color: #444;
}

.product-list-item:hover {
    background: #f9f9f9;
    padding-right: 20px;
    color: #e65100;
}

.product-list-item.active {
    background: #fff3e0;
    color: #e65100;
    border-right: 4px solid #e65100;
    font-weight: bold;
}

/* === POS V2 Styles === */

.pos-layout-v2 {
    display: grid;
    grid-template-columns: 1fr 350px;
    /* Products flexible, Order Panel fixed 350px - INCREASED! */
    grid-template-rows: minmax(0, 1fr);
    /* إجبار الصف على الارتفاع المحدد */
    gap: 12px;
    height: calc(100vh - 110px);
    overflow: hidden;
    /* إخفاء التمدد */
    padding: 8px;
}

/* Right Side: Products Panel */
.pos-products-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 5px;
    box-shadow: none;
}

/* POS Order Header Styling */
/* POS Order Header Styling - Split Container */
/* POS Order Header Styling - Unified Stacked Container */
/* POS Order Header Styling - Unified Stacked Container */
.pos-order-panel .pos-order-header {
    background: #ffffff !important;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    padding: 4px;
    margin: 0;
    /* FIXED: Removed negative margins that caused cutoff */
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid #ccc;
    direction: rtl;
}

/* Box 1: Invoice Info (Top Section) */
.pos-mode-info {
    background: transparent;
    padding: 0 0 2px 0;
    /* Minimal padding */
    border: none;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px dashed #ccc;
    /* Thinner separator */

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 0;
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 2px;
    /* Minimal margin */
}

/* Box 2: Address Info (Bottom Section) */
#delivery-customer-info {
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    width: 100%;
    text-align: right;
    /* Align address data to right */
}

/* Hide delivery search inputs */
#pos-delivery-search {
    display: none !important;
}

#pos-shift-num {
    color: #8e44ad;
    /* Purple */
    font-size: 1.2rem;
    font-weight: 800;
}

/* Flatten background */

/* Main Categories Rows */
.pos-main-cats-row,
.pos-main-cats-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 5px;
    padding: 2px;
}

.pos-sub-cats-row {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping to multiple rows */
    gap: 8px;
    /* Slightly more gap for wrapped rows */
    padding: 5px;
    justify-content: flex-start;
    /* Align items to start */
    max-height: 180px;
    /* ارتفاع تقريبي لـ 4 أسطر */
    overflow-y: auto;
    /* إضافة شريط تمرير عند الزيادة */
    align-content: flex-start;
    /* منع تمدد الأسطر */
}

.cat-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.8rem 1.2rem;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 1rem;
    user-select: none;
    white-space: nowrap;
    min-width: 100px;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
}

.cat-btn:hover {
    background: #f0f0f0;
}

.cat-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Specific styling for sub-cats */
.sub-cat-btn {
    background: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    text-align: center;
    border-radius: 15px;
    /* Pill shape */
    border: 1px solid #ddd;
    min-width: 80px;
    white-space: nowrap;
}

.sub-cat-btn.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-dark);
}

/* POS Sub Category Button (Matches JS Class) */
.pos-sub-cat-btn {
    background: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.6rem 1.2rem;
    text-align: center;
    border-radius: 8px;
    border: 1px solid #ddd;
    min-width: 90px;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    user-select: none;
    margin: 2px;
}

/* New Logic: If > 10 items, allow them to grow to fill space (react with space) */
.pos-sub-categories.auto-grow .pos-sub-cat-btn {
    flex-grow: 1;
}

/* Compact version when too many items (20% smaller) */
.pos-sub-cat-btn.mini {
    font-size: 0.75rem !important;
    padding: 0.45rem 0.9rem !important;
    min-width: 70px !important;
}

.pos-sub-cat-btn:hover {
    background: #f1efff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.pos-sub-cat-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 4px 10px rgba(108, 99, 255, 0.3);
    font-weight: bold;
    transform: translateY(-1px);
}


/* Products Grid V2 - FIXED: Increased gap to prevent overlap */
.pos-products-grid-v2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    /* Smaller minmax for more flexibility */
    gap: 16px;
    /* FIXED: Much larger gap to prevent overlap */
    overflow-y: auto;
    padding: 14px;
    flex: 1;
    align-content: start;
}

.product-btn-v2 {
    aspect-ratio: 1.05;
    /* Slightly adjusted ratio */
    border: none;
    border-radius: 8px;
    /* تقليل نصف القطر قليلاً */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.3rem;
    /* تقليل الحشو */
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
    /* تصغير الخط */
    /* Slightly reduced font */
    color: #444;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    /* Subtle base shadow */
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Alternating row shadows for visual comfort */
.product-btn-v2:nth-child(8n+1),
.product-btn-v2:nth-child(8n+2),
.product-btn-v2:nth-child(8n+3),
.product-btn-v2:nth-child(8n+4) {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    /* Lighter shadow for first row pattern */
}

.product-btn-v2:nth-child(8n+5),
.product-btn-v2:nth-child(8n+6),
.product-btn-v2:nth-child(8n+7),
.product-btn-v2:nth-child(8n+8) {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    /* Slightly darker shadow for second row pattern */
}

.product-btn-v2:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1) !important;
    /* Override alternating shadows on hover */
}

.product-btn-v2:active {
    transform: scale(0.97);
}

.product-btn-v2 span {
    pointer-events: none;
}

/* Product Colors based on index or category */
.p-color-1 {
    background-color: #f1c40f;
}

/* Yellow */
.p-color-2 {
    background-color: #2ecc71;
}

/* Green */
.p-color-3 {
    background-color: #e74c3c;
    color: white;
}

/* Red */
.p-color-4 {
    background-color: #e67e22;
    color: white;
}

/* Orange */
.p-color-5 {
    background-color: #9b59b6;
    color: white;
}

/* Purple */
.p-color-6 {
    background-color: #3498db;
    color: white;
}

/* Blue */
.p-color-7 {
    background-color: #6b7280;
    color: white;
}

/* Gray */
.p-color-8 {
    background-color: #92400e;
    color: white;
}

/* Brown */
.p-color-default {
    background-color: #ecf0f1;
}


/* Left Side: Order Panel */
.pos-order-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    /* إضافة هذا السطر لمنع التمدد */
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.pos-order-header {
    background: #333;
    color: #fff;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.pos-delivery-row {
    display: flex;
    gap: 5px;
    padding: 5px;
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
}

.pos-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 0;
}

/* Order Table */
.pos-order-table {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #ccc;
    margin: 5px;
    min-height: 0;
    /* ضروري للسماح بالانكماش وتفعيل الـ scroll */
}

.pos-order-thead {
    display: grid;
    grid-template-columns: 80px 80px 60px 1fr;
    /* Total, Price, Qty, Item Name */
    background: #e0e0e0;
    font-weight: bold;
    padding: 8px 5px;
    text-align: center;
    border-bottom: 2px solid #aaa;
    color: #000;
    /* لون أسود للعناوين */
}

.pos-order-tbody {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    min-height: 40vh;
    /* ارتفاع متجاوب مع الشاشة */
}

.order-row {
    display: grid;
    grid-template-columns: 80px 80px 60px 1fr;
    padding: 8px 5px;
    border-bottom: 1px solid #eee;
    text-align: center;
    cursor: pointer;
    font-size: 1rem;
    color: #000;
    /* لون أسود للنص لضمان الظهور */
}

.order-row:hover {
    background: #f5f5f5;
}

.order-row.selected {
    background: #3498db;
    color: white;
}

/* Order Summary */
.pos-order-summary {
    background: #f1f1f1;
    padding: 0.5rem 1rem;
    border-top: 2px solid #ccc;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    color: #000;
    /* لون أسود للإجمالي */
}

/* Controls Grid */
.pos-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 5px;
    padding: 5px;
    background: #e8e8e8;
}

.pos-ctrl-btn {
    border: none;
    padding: 1rem 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    color: #333;
    background: #dcdcdc;
    transition: background 0.2s;
}

.pos-ctrl-btn:hover {
    filter: brightness(0.9);
}

.pos-ctrl-btn:active {
    transform: translateY(2px);
}

.new-order {
    background: #fff;
    border: 1px solid #ccc;
}

.print-btn {
    background: #95a5a6;
    color: white;
}

.increase-btn {
    background: #2ecc71;
    color: white;
}

.decrease-btn {
    background: #e74c3c;
    color: white;
}

.edit-btn {
    background: #f39c12;
    color: white;
}

.delete-btn {
    background: #c0392b;
    color: white;
}

.save-btn {
    background: #27ae60;
    color: white;
    font-size: 1.1rem;
}

/* Responsive - Mobile Fix */
@media (max-width: 900px) {
    .pos-layout-v2 {
        grid-template-columns: 1fr !important;
        /* Single column on mobile */
        grid-template-rows: auto auto !important;
        /* Stack vertically */
        height: auto !important;
        gap: 10px !important;
        padding: 5px !important;
    }

    .pos-products-panel {
        height: 55vh !important;
        /* More height for products */
        min-height: 350px !important;
        order: 1 !important;
        /* Products first */
    }

    .pos-order-panel {
        height: auto !important;
        min-height: 300px !important;
        max-height: 45vh !important;
        order: 2 !important;
        /* Order panel second */
        overflow-y: auto !important;
    }

    /* Products Grid: Mobile optimized - FINAL FIX */
    .pos-products-grid-v2 {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)) !important;
        /* تصغير العرض الأدنى */
        /* أكثر مرونة */
        /* Force exactly 3 columns on mobile */
        column-gap: 4px !important;
        /* Horizontal gap (between columns) - very small */
        row-gap: 8px !important;
        /* تقليل المسافة العمودية */
        /* Vertical gap (between rows) - larger */
        padding: 5px !important;
    }

    /* Product Cards: Optimized for mobile */
    .product-btn-v2 {
        font-size: 0.65rem !important;
        /* تصغير الخط أكثر ليتناسب */
        padding: 0 !important;
        /* إزالة الحشو تماماً */
        min-height: 20px !important;
        /* تقليل الارتفاع 10px إضافية */
        max-height: 35px !important;
        aspect-ratio: auto !important;
        /* السماح بالتمدد */
        margin: 0 !important;
        border-radius: 6px !important;
    }

    /* Order header: No negative margins */
    .pos-order-panel .pos-order-header {
        margin: 0 !important;
    }
}

/* === Customer Panel Styles === */
.pos-customer-panel {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Takes same space as Products Grid */
}

.pos-customer-panel.hidden {
    display: none !important;
}

.panel-title {
    margin-bottom: 10px;
    color: var(--primary-dark);
    font-size: 1.2rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 10px;
}

.f-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.f-group label {
    font-size: 0.9rem;
    font-weight: bold;
    color: #555;
}

.f-group input,
.f-group select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.f-group input:focus,
.f-group select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

.span-2 {
    grid-column: span 2;
}

.span-full {
    grid-column: 1 / -1;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-save-cust {
    background: linear-gradient(135deg, #1abc9c, #16a085);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
}

.btn-save-cust:hover {
    filter: brightness(0.9);
}

.btn-new-addr {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
}

.btn-new-addr:hover {
    filter: brightness(0.9);
}

/* Premium Client Tab Button */
.client-tab-btn {
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    order: -1;
    /* Make it appear first if flex order is used, though we pretend it via DOM */
}

.client-tab-btn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.client-tab-btn.active {
    background: linear-gradient(135deg, #d35400 0%, #e67e22 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
}

/* Input Focus Effect */
.f-group input:focus,
.f-group select:focus {
    border: 2px solid #f39c12 !important;
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.5);
    background-color: #fef9e7;
    outline: none;
    transform: scale(1.01);
    transition: all 0.2s ease;
}

.hidden {
    display: none !important;
}

/* === Invoice Browser Modal Styles === */
.invoice-list-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 4px;
    margin-bottom: 4px;
}

.invoice-list-item:hover {
    background: #f8f9fa;
    transform: translateX(-2px);
}

.invoice-list-item.selected {
    background: linear-gradient(135deg, #e8f4fd 0%, #d4e9fc 100%);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.15);
}

.invoice-list-item.voided {
    opacity: 0.4;
    text-decoration: line-through;
    pointer-events: none;
}

.invoice-number {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .pos-sub-cats-row {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        padding-bottom: 2px;
        /* Scrollbar space fix */
    }

    /* Optional: Slightly smaller text for mobile sub-cats to fit more */
    .pos-sub-cat-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        min-width: 80px;
    }
}

.invoice-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success-color);
}

.invoice-preview-header {
    border-bottom: 2px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 1.5rem;
}

.preview-actions .btn {
    flex: 1;
}

/* Invoice Table Rows */
.invoice-table-row {
    cursor: pointer;
    transition: all 0.2s;
}

.invoice-table-row:hover {
    background: #f8f9fa !important;
}

.invoice-table-row.selected {
    background: linear-gradient(135deg, #e8f4fd 0%, #d4e9fc 100%) !important;
    border-left: 4px solid var(--primary-color);
}

.invoice-table-row td {
    padding: 12px 10px !important;
}

/* === Square Screen (1:1 Aspect Ratio) Fix - Radical Overhaul === */
@media (min-aspect-ratio: 4/5) and (max-aspect-ratio: 5/4) {

    /* 1. Free up space: Hide Sidebar and remove main padding */
    .sidebar {
        display: none !important;
    }

    .container {
        padding-right: 0 !important;
        /* Remove sidebar reserve space */
    }

    .content {
        padding: 5px !important;
        /* Minimal padding for content */
    }

    /* 2. Layout Proportions */
    .pos-layout-v2 {
        grid-template-columns: 1fr 340px !important;
        /* Fixed width for order panel, flexible for products */
        gap: 12px !important;
        padding: 5px !important;
        height: calc(100vh - 60px) !important;
        /* More height for content */
    }

    /* 3. Products Grid: High visibility, no overlap */
    .pos-products-grid-v2 {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)) !important;
        gap: 16px !important;
        /* Large gap to separate items clearly */
        padding: 12px !important;
    }

    /* 4. Product Cards: Square and clear */
    .product-btn-v2 {
        aspect-ratio: 1 !important;
        min-height: 90px !important;
        font-size: 0.95rem !important;
        padding: 0.4rem !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    /* Alternating shadows for eye comfort */
    .product-btn-v2:nth-child(8n+1),
    .product-btn-v2:nth-child(8n+2),
    .product-btn-v2:nth-child(8n+3),
    .product-btn-v2:nth-child(8n+4) {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
    }

    .product-btn-v2:nth-child(8n+5),
    .product-btn-v2:nth-child(8n+6),
    .product-btn-v2:nth-child(8n+7),
    .product-btn-v2:nth-child(8n+8) {
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12) !important;
    }

    /* 5. Order Panel: Fix Cutoff and sizing */
    .pos-order-panel {
        min-width: 320px !important;
        margin: 0 !important;
        overflow: hidden !important;
        border: 2px solid #ddd !important;
    }

    .pos-order-panel .pos-order-header {
        margin: 0 !important;
        border-radius: 8px 8px 0 0 !important;
    }

    /* Table columns */
    .pos-order-thead,
    .order-row {
        grid-template-columns: 60px 60px 45px 1fr !important;
        font-size: 0.85rem !important;
    }

    /* Controls */
    .pos-actions-grid-v2 {
        gap: 4px !important;
        padding: 5px !important;
    }

    .pos-ctrl-btn {
        padding: 0.5rem 0.2rem !important;
        font-size: 0.8rem !important;
    }

    .pos-ctrl-btn i {
        font-size: 0.9rem !important;
    }

    .pos-ctrl-btn span {
        font-size: 0.7rem !important;
    }

    /* Category Navigation */
    .cat-btn {
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
    }

    .pos-sub-cat-btn {
        padding: 0.4rem 0.7rem !important;
        font-size: 0.8rem !important;
    }
}

@media (min-aspect-ratio: 0.9/1) and (max-aspect-ratio: 1.1/1) {

    /* Scale down font size to shrink em/rem values */
    html {
        font-size: 13px;
        /* approx 80% of 16px */
    }

    /* Adjust Sidebar Width (250px * 0.8 = 200px) */
    .sidebar {
        width: 200px;
    }

    .container {
        padding-right: 200px;
    }

    /* Adjust POS Left Panel (350px * 0.8 = 280px) */
    .pos-layout {
        grid-template-columns: 280px 1fr;
    }

    /* Adjust POS right panel grid items if needed */
    .pos-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        /* smaller min-width */
    }
}

/* Inventory Tabs Styling */
.inventory-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    background: #eef2f7;
    padding: 6px;
    border-radius: 50px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    flex-wrap: wrap;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 24px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 600;
    color: #636e72;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.tab-btn:active {
    transform: translateY(1px);
}

@media (max-width: 600px) {
    .inventory-tabs {
        width: 100%;
        border-radius: 12px;
        gap: 5px;
    }

    .tab-btn {
        flex: 1;
        padding: 10px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

/* Fingerprint Modal Redesign */
.fp-header {
    background: linear-gradient(135deg, #7B61FF 0%, #6C63FF 100%);
    color: white;
}

.fp-clock {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 3rem;
    font-weight: 800;
    color: #6C63FF;
    line-height: 1;
    margin-bottom: 5px;
}

.fp-date {
    color: #888;
    font-size: 1rem;
    margin-bottom: 25px;
}

.fp-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fafafa;
    font-size: 0.95rem;
    color: #555;
    transition: all 0.3s ease;
}

.fp-input:focus {
    border-color: #6C63FF;
    background: white;
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

/* === Generic Modal Styles === */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    animation: modalFadeIn 0.3s;
}

/* When displayed via JS, flex will be set inline or via class, but usually JS sets display: block or flex. 
   If JS sets display: block, we need to ensure it uses flex for centering or use absolute positioning.
   Common pattern: class 'modal' is hidden, class 'modal show' is flex. 
   But report.js simply sets style.display = 'block'. 
   So we need to make sure .modal[style*="block"] behaves like a flex container or handle centering differently.
   Actually, if JS sets display: block, we can't use flex centering on the parent easily without !important or changing JS.
   Better: Change JS to set display: flex? Or use absolute centering.
   
   Let's use absolute centering for .modal-content if parent is block.
*/

.modal[style*="display: block"], 
.modal[style*="display:block"] {
    display: flex !important; /* Force flex even if JS sets block, to use flex centering */
}

.modal-content {
    background-color: white;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideUp 0.3s;
    position: relative;
    max-height: 90vh;
}

.modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close:hover {
    opacity: 1;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}