:root {
    --primary-green: #1B3D31;
    --accent-green: #078C4C;
    --bg-light: #f3f4f6;
    --text-dark: #1f2937;
    --border-color: #e5e7eb;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

html,
body {
    background: var(--bg-light);
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* HEADER */
.app-header {
    height: 60px;
    background: linear-gradient(to right, #333, #009D51);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    color: white;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 20px;
}

.header-main-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.category-dropdown-wrapper {
    position: relative;
    width: 200px;
    margin-left: 20px;
}

.category-dropdown {
    background: white;
    color: var(--text-dark);
    padding: 10px 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.category-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    list-style: none;
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.category-list.show {
    display: block;
}

.category-option {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    transition: background 0.2s;
}

.category-option:hover {
    background: #f3f4f6;
}

.search-bar-wrapper {
    position: relative;
    flex: 1;
    max-width: 350px;
    margin-left: auto;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 20px;
}

.header-search-input {
    width: 100%;
    background: white;
    border: none;
    padding: 10px 16px 10px 42px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    outline: none;
}

.header-search-input::placeholder {
    color: #94a3b8;
}

.header-right {
    display: flex;
    gap: 12px;
    width: 350px;
    height: 100%;
    align-items: center;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    justify-content: space-between;
    padding-left: 20px;
}

.icon-btn {
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
}

.icon-btn.static-icon {
    cursor: default;
    pointer-events: none;
}

.icon-btn.danger {
    background: white;
    color: #ef4444;
}

.icon-btn.white {
    background: white;
    color: var(--text-dark);
}

.icon-btn.transparent {
    color: white;
}

.icon-group {
    display: flex;
    gap: 8px;
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: block;
    filter: brightness(0) saturate(100%) invert(18%) sepia(34%) saturate(738%) hue-rotate(106deg) brightness(97%) contrast(90%);
}

.icon-btn .material-icons {
    font-size: 24px;
}

/* WRAPPER */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar-groups {
    width: 80px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    gap: 20px;
    flex-shrink: 0;
    order: -2;
    /* Ensure sidebar is always on the far left */
}

.group-item {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-green);
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.group-item.active {
    background: linear-gradient(135deg, #333, #009D51);
    color: white;
    border-color: transparent;
}

.group-item:hover:not(.active) {
    transform: scale(1.1);
    background: #f0fdf4;
}

/* VIEW LOGIC */
.view-item {
    flex: 1;
    height: 100%;
    display: flex;
}

#view-payment {
    display: none;
}

/* Hidden by default */

body.payment-mode #view-menu {
    display: none;
}

body.payment-mode #view-payment {
    display: flex;
}

/* Success & Payment Common Layout */
body.payment-mode .sidebar-groups,
body.success-mode .sidebar-groups {
    display: none;
}

body.payment-mode .cart-panel,
body.success-mode .cart-panel {
    order: -1;
    border-left: none;
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
}

/* Screen visibility */
body.success-mode #view-menu,
body.success-mode #view-payment {
    display: none;
}

body.success-mode #view-success {
    display: flex;
}


body.payment-mode .summary-toggle-bar,
body.payment-mode .pay-button,
body.success-mode .summary-toggle-bar,
body.success-mode .pay-button {
    display: none;
}

body.payment-mode .grand-total {
    background: linear-gradient(to right, #333, #009D51);
    color: white !important;
    padding: 12px 16px;
    margin: 12px -16px -12px -16px;
    border-top: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


body.payment-mode #clear-cart-btn,
body.payment-mode #delivery-btn,
body.payment-mode #lightning-btn,
body.payment-mode #more-options-btn,
body.payment-mode .static-icon,
body.payment-mode .payment-header-bar .ph-cell:first-child,
body.payment-mode .payment-header-bar .ph-cell:nth-child(3),
body.payment-mode .payment-header-bar .ph-cell:nth-child(4) {
    display: none;
}

body.payment-mode .header-right {
    border-left: none;
}


/* PRODUCT GRID */
.product-grid-container {
    flex: 1;
    padding: 20px;
    background: white;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.product-grid-container::-webkit-scrollbar {
    display: none;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.product-card {
    cursor: pointer;
    transition: 0.2s;
    background: white;
    border-radius: 12px;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.product-img-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    background: #eee;
    border: 2px solid var(--primary-green);
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.price-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary-green);
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
}

.product-name {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 4px;
    color: #333;
}

/* PAYMENT VIEW */
.payment-container {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
}

.payment-header-bar {
    display: flex;
    justify-content: center;
    height: 70px;
    background: white;
    border-top: 4px solid var(--primary-green);
}

.ph-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #eee;
}

.ph-cell:last-child {
    border-right: none;
}

.payment-header-icon-btn {
    background: var(--accent-green);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-header-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary-green);
    letter-spacing: 1px;
}

.item-count-badge-header {
    background: white;
    color: var(--accent-green);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid #eee;
}

.header-fire {
    color: var(--accent-green) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 44px !important;
}

.payment-content {
    flex: 1;
    padding: 30px 60px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.payment-content::-webkit-scrollbar {
    display: none;
}

.payment-actions-top {
    display: flex;
    justify-content: flex-end;
}

.split-pay-btn {
    background: none;
    border: 2px solid #333;
    padding: 8px 24px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.payment-total-section {
    text-align: center;
    padding: 20px 0;
    font-size: 100px;
    font-weight: 800;
    color: #1a1a1a;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    letter-spacing: -2px;
}

.payment-methods-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.cash-row-container {
    display: flex;
    border: 2px solid #ddd;
    border-radius: 12px;
    height: 60px;
    overflow: hidden;
    background: white;
}

.cash-box {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.pm-main-icon {
    font-size: 24px;
    color: var(--primary-green);
}

.pm-name {
    font-weight: 600;
    font-size: 18px;
}

.pm-amount {
    margin-left: auto;
    font-weight: 700;
    color: #999;
    font-size: 18px;
}

.exact-btn {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 0 40px;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
}

.quick-cash-row {
    display: flex;
    gap: 16px;
}

.qc-btn {
    flex: 1;
    background: white;
    border: 2px solid var(--primary-green);
    height: 50px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
}

.other-pm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border: 2px solid #eee;
    border-radius: 12px;
    background: white;
    cursor: pointer;
}

.pm-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 17px;
}

.pm-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: #999;
    font-size: 17px;
}

.pm-sub-icon {
    color: var(--primary-green);
}

/* CART */
.cart-panel {
    width: 350px;
    background: white;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.cart-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.cust-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.tbl-row {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    color: #666;
}

.green-bold {
    color: var(--accent-green);
}

.cart-columns {
    display: flex;
    padding: 8px 16px;
    background: #f9fafb;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
}

.c-item {
    flex: 1;
}

.c-qty {
    width: 40px;
    text-align: center;
}

.c-amt {
    width: 60px;
    text-align: right;
}

.cart-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.cart-items-list::-webkit-scrollbar {
    display: none;
}

.section-header {
    background: #eee;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 800;
    color: #444;
}

.cart-item {
    padding: 8px 0;
    border-bottom: 1px solid #f1f1f1;
}

.cart-item-row {
    display: flex;
    font-size: 14px;
    font-weight: 600;
}

.item-name {
    flex: 1;
}

.item-qty {
    width: 40px;
    text-align: center;
}

.item-amt {
    width: 60px;
    text-align: right;
}

.cart-footer {
    border-top: 1px solid var(--border-color);
}

.summary-toggle-bar {
    background: linear-gradient(to right, #333, #009D51);
    color: white;
    padding: 10px 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.summary-content {
    overflow: hidden;
    max-height: 500px;
    transition: 0.3s;
}

.collapsed .summary-content {
    max-height: 0;
}

.staff-line {
    padding: 8px 16px;
    border-bottom: 1px solid #f1f1f1;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    color: #666;
}

.totals-area {
    padding: 12px 16px;
}

.t-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.green-text {
    color: var(--accent-green);
}

.grand-total {
    border-top: 1px solid #eee;
    padding-top: 8px;
    margin-top: 6px;
    font-size: 18px;
    font-weight: 800;
    color: #000;
}

.pay-button {
    width: 100%;
    background: white;
    border: none;
    border-top: 4px solid var(--primary-green);
    cursor: pointer;
    transition: all 0.2s;
}

.pay-button:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.pay-grid>*:hover {
    background: #f8fafc;
}

.pay-grid {
    display: grid;
    grid-template-columns: 70px 1fr 70px 70px;
    height: 70px;
    align-items: center;
}

.pay-grid-cell,
.p-cell,
.p-badge,
.p-label {
    border-right: 1px solid #ddd;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pay-grid>*:last-child {
    border-right: none;
}

#pay-expand-icon {
    background: var(--accent-green);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.p-label {
    font-size: 32px;
    font-weight: 800;
    color: #1B3D31;
    letter-spacing: 0px;
}

.badge-item {
    background: var(--accent-green);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.p-cell .fire-icon {
    color: var(--accent-green) !important;
    font-size: 46px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

/* diagnostic rule removed */

body.payment-mode #order-type-btn {
    display: none;
}

/* SUCCESS VIEW STYLES */
#view-success {
    display: none;
    /* Controlled by body.success-mode */
    justify-content: center;
    align-items: center;
    background: white;
}

.success-container {
    text-align: center;
    max-width: 500px;
    width: 100%;
    padding: 40px;
}

.success-icon-wrapper {
    margin-bottom: 20px;
}

.success-main-icon {
    width: 200px;
    height: auto;
}

.success-total-paid {
    font-size: 42px;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 40px;
    letter-spacing: -1px;
}

.success-total-paid span {
    color: var(--accent-green);
}

.success-payment-icons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
}

.success-pay-icon-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #f0fdf4;
    border: 3px solid var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-green);
}

.success-pay-icon-circle .material-icons {
    font-size: 60px;
}

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.receipt-btn {
    background: white;
    border: 2px solid #333;
    padding: 14px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.new-order-btn {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 12px;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.new-order-btn:hover {
    background: #06703b;
}

/* ==========================================================================
   RESPONSIVE STYLES (Preserves Desktop Layout)
   ========================================================================== */

/* TABLETS & SMALL LAPTOPS (Max width 1024px) */
@media screen and (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* TABLETS (Max width 768px) */
@media screen and (max-width: 768px) {
    .app-header {
        padding: 0 12px;
    }

    .header-main-controls {
        gap: 10px;
    }

    .category-dropdown-wrapper {
        width: 140px;
        margin-left: 10px;
    }

    .search-bar-wrapper {
        max-width: 200px;
    }

    .header-right {
        width: auto;
        padding-left: 10px;
    }

    .icon-group {
        gap: 4px;
    }

    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .cart-panel {
        width: 300px;
    }
}

/* MOBILE DEVICES (Max width 480px) */
@media screen and (max-width: 480px) {

    /* Main Layout Adjustments */
    #app {
        height: 100vh;
        overflow: hidden;
        position: relative;
    }

    .main-wrapper {
        flex-direction: column;
        position: relative;
        height: calc(100vh - 54px);
    }

    /* Sidebar to Horizontal Scroll */
    .sidebar-groups {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 10px;
        gap: 12px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        scrollbar-width: none;
        background: white;
        z-index: 10;
    }

    .sidebar-groups::-webkit-scrollbar {
        display: none;
    }

    .group-item {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        font-size: 14px;
    }

    /* Header adjustments for space */
    .header-main-controls {
        display: none;
    }

    .app-header {
        height: 54px;
        padding: 0 10px;
    }

    /* Product Grid */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .product-grid-container {
        padding: 12px;
        height: 100%;
    }

    /* CART - OVERLAY MODE */
    .cart-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        z-index: 999;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
    }

    body.cart-open .cart-panel {
        transform: translateX(0);
    }

    /* Payment View Adjustments */
    .payment-total-section {
        font-size: 48px;
        padding: 20px 0;
    }

    .payment-content {
        padding: 15px;
    }

    .quick-cash-row {
        gap: 8px;
    }

    .qc-btn {
        height: 44px;
        font-size: 14px;
    }

    .success-total-paid {
        font-size: 28px;
    }

    .success-main-icon {
        width: 120px;
    }

    .success-pay-icon-circle {
        width: 60px;
        height: 60px;
    }

    .success-pay-icon-circle .material-icons {
        font-size: 32px;
    }
}

/* Mobile Toggle Button Styles */
#mobile-cart-toggle-btn {
    display: none;
    position: relative;
    padding: 8px;
    color: white;
}

.mobile-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    width: 18px;
    height: 18px;
    font-size: 10px;
    border: 1px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    /* Changed to red for visibility */
    color: white;
    border-radius: 50%;
    font-weight: 700;
}

@media screen and (max-width: 480px) {
    #mobile-cart-toggle-btn {
        display: flex;
    }

    .header-right {
        width: auto !important;
        border-left: none !important;
        padding-left: 0 !important;
    }

    .header-right .icon-btn:not(#mobile-cart-toggle-btn):not(#hamburger-menu-btn) {
        display: none;
    }
}