:root {
    --header-height: 50px;
    --banner-height: 110px;
    --mobile-width: min(100vw, 390px);
    --sidebar-width: clamp(68px, 20vw, 80px);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #b1b1b1;
    min-height: 100vh;
}

.app-shell {
    width: var(--mobile-width);
    max-width: var(--mobile-width);
    min-height: 100vh;
    margin: 0 auto;
    position: relative;
}

/* Main container with 390px constraints */
.main-container {
    width: 100%;
    max-width: 100% !important;
    min-width: 100% !important;
    margin: 0;
    background: #fff;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Mobile-first: 390px fixed width */
@media (min-width: 1px) {
    .main-container {
        max-width: 100% !important;
        min-width: 100% !important;
    }
}

/* Header */
.header {
    background: #FFBC0D;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: var(--mobile-width);
    height: var(--header-height);
    margin: 0 auto;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.banner-container {
    width: 100%;
    padding-top: var(--header-height);
}

.banner {
    width: 100%;
    height: var(--banner-height);

    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 12px;
}

.banner-image-wrap {
    width: 100%;
    height: 100%;
    border-radius: 9px;
    overflow: hidden;
    position: relative;
}

.banner-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.45s ease;
}

.banner-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
}

.banner-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-loading .banner-image-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(237, 237, 237, 0.95) 0%,
        rgba(248, 248, 248, 0.95) 45%,
        rgba(230, 230, 230, 0.95) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
    z-index: 2;
}

.app-loading .banner-image {
    opacity: 0;
}

.logo h1 {
    font-size: 1rem;
    font-weight: bold;
    color: #333;
}

.cart-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 10px;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;

}

.cart-btn:hover {
    background: rgba(255,255,255,0.1);
}

.cart-icon {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
    -webkit-tap-highlight-color: transparent;

}

#cart-count {
    position: absolute;
    top: -2px;
    right: -5px;
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e60023;
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px #FFBC0D;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #D2691E, #A0522D);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    max-width: 360px;
    margin: 0 auto;
    margin-top: 80px;
}

.hero-content h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.hero-content p {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.cta-button {
    background: #8B4513;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.cta-button:hover {
    background: #654321;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 50%;
    transform: translateX(calc(var(--mobile-width) / -2));

    top: calc(var(--header-height) + var(--banner-height));
    height: calc(100vh - var(--header-height) - var(--banner-height));

    width: var(--sidebar-width);
    background: #ffffff;
    padding: 1rem 0.5rem;
    z-index: 99;

    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-btn {
    background: rgba(156 156 156 / 10%);
    color: rgb(34, 34, 34);
    border: none;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 10px;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;

}

.sidebar-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateX(2px);
}

.sidebar-settings-btn {
    margin-top: auto;
    background: rgb(156, 156, 156, 0.1);
    color: rgb(34, 34, 34);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    min-height: 42px;
    padding: 0.75rem 0.5rem;
    -webkit-tap-highlight-color: transparent;
}

/* Main Content */
.main-content {
    margin-left: 0;
    padding-left: 0;
}

/* Featured Products Section */
.featured-products {
    padding: 0rem 1rem 6rem;
    max-width: calc(var(--mobile-width) - var(--sidebar-width));
    margin: 0 0 0 var(--sidebar-width);
    margin-top: 10px;
}

.featured-products h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
    color: #8B4513;
}

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

.product-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.product-card:hover {
    transform: translateY(-2px);
}

.product-card.is-out-of-stock {
    background: #e9e9e9;
}

.product-card.is-skeleton {
    pointer-events: none;
}

.product-card.is-skeleton .product-image-wrap,
.product-card.is-skeleton .skeleton-line {
    position: relative;
    overflow: hidden;
    background: #ececec;
}

.product-card.is-skeleton .product-image-wrap::after,
.product-card.is-skeleton .skeleton-line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(236, 236, 236, 0.9) 0%,
        rgba(248, 248, 248, 0.95) 45%,
        rgba(228, 228, 228, 0.9) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
}

.product-image-wrap {
    position: relative;
    margin-bottom: 0.75rem;
}

.product-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    margin: 0 auto;
}

.out-of-stock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(90, 90, 90, 0.2);
    border-radius: 10px;
}

.out-of-stock-badge {
    width: 100%;
    max-width: 88px;
    object-fit: contain;
}

.product-card h4 {
    font-size: .8rem;
    margin-bottom: 0.25rem;
    color: #8B4513;
}

.skeleton-line {
    border-radius: 8px;
}

.skeleton-line-title {
    height: 14px;
    margin-bottom: 0.45rem;
}

.skeleton-line-price {
    width: 55%;
    height: 14px;
    margin-bottom: 0.6rem;
}

.skeleton-line-button {
    height: 32px;
}

.product-card .price {
    font-size: 1rem;
    font-weight: bold;
    color: #3a3a3a;
    margin-bottom: 0.5rem;
}

.add-to-cart {
    background: #FFBC0D;
    font-weight: bold;
    color: rgb(0, 0, 0);
    border: none;
    padding: 0.5rem .5rem;
    font-size: 11px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
    width: 100%;
    /*-webkit-tap-highlight-color: transparent;*/

}

.add-to-cart:disabled {
    background: #bdbdbd;
    color: #5a5a5a;
    cursor: not-allowed;
}



/* Cart Section */
.inventory-section,
.cart-section {
    display: none;
    padding: calc(var(--header-height) + 1rem) 1rem 1rem;
    max-width: var(--mobile-width);
    margin: 0;
    background: #ffffff;
    min-height: calc(100vh - var(--header-height));
}

.inventory-header,
.cart-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.inventory-back-btn,
.back-to-menu {
    background: rgba(156 156 156 / 12%);
    color: #333;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 0.55rem 0.75rem;
}

.inventory-section h3,
.cart-section h3 {
    color: #333;
    font-size: 1.15rem;
    line-height: 1;
}

.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.inventory-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 0.75rem;
}

.inventory-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
}

.inventory-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.inventory-item-name {
    color: #333;
    font-size: 0.82rem;
    font-weight: bold;
    line-height: 1.25;
}

.inventory-item-price,
.inventory-item-price-label {
    color: #8B4513;
    font-size: 0.82rem;
    font-weight: bold;
}

.inventory-price-editor {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.inventory-price-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.2rem;
}

.inventory-currency {
    color: #333;
    font-size: 0.82rem;
    font-weight: bold;
}

.inventory-price-input {
    width: 60%;
    height: 80%;
    min-width: 0;
    border: 1px solid #dddddd;
    border-radius: 4px;
    font-size: 80%;
    outline: none;
    padding: 0.45rem 0.55rem;
}

.inventory-toggle-btn {
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: bold;
    min-width: 90px;
    padding: 0.6rem 0.7rem;
}

.inventory-toggle-btn.is-on {
    background: #daf5de;
    color: #196b2d;
}

.inventory-toggle-btn.is-off {
    background: #f1d7dc;
    color: #9a1f33;
}

.cart-item {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.cart-item-image {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 10px;
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.cart-item-name {
    color: #333;
    font-size: 0.82rem;
    font-weight: bold;
    line-height: 1.25;
}

.cart-item-price {
    color: #8B4513;
    font-size: 0.85rem;
    font-weight: bold;
}

.quantity-control {
    display: grid;
    grid-template-columns: 28px 26px 28px;
    align-items: center;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    overflow: hidden;
}

.quantity-control button {
    width: 28px;
    height: 30px;
    background: #FFBC0D;
    color: #111;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
}

.quantity-control span {
    font-size: 0.8rem;
    font-weight: bold;
    text-align: center;
}

.empty-cart {
    background: #f8f9fa;
    border-radius: 10px;
    color: #777;
    font-size: 0.9rem;
    padding: 1rem;
    text-align: center;
}

.cart-total {
    display: flex;
    justify-content: flex-end;
    margin: 1.25rem 0;
    font-size: 1.15rem;
    color: #333;
}

.checkout-btn {
    background: #8B4513;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;

}

.checkout-btn:hover {
    background: #654321;
}

.bottom-cart-bar {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 120;
    width: calc(var(--mobile-width) - 24px);
    min-height: 58px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #111111;
    color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, calc(100% + 24px));
    transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.2s ease;
}

.bottom-cart-bar.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.bottom-cart-summary {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.2;
}

.bottom-cart-items {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
    font-weight: bold;
}

.bottom-cart-price {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 800;
}

.bottom-checkout-btn {
    background: #FFBC0D;
    color: #111111;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0.7rem 0.9rem;
    -webkit-tap-highlight-color: transparent;
}

/* Stats Section */
.stats-section {
    background: #8B4513;
    color: white;
    padding: 2rem 1rem;
    max-width: 280px;
    margin: 0 auto;
    margin-left: 90px;
}

.stats-container {
    display: flex;
    justify-content: space-around;
    max-width: 330px;
    margin: 0 auto;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #D2691E;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Footer */
.footer {
    background: #8B4513;
    color: white;
    padding: 1rem;
    text-align: center;
    max-width: 280px;
    margin: 0 auto;
    margin-left: 90px;
}

.footer-content p {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Modal */
.order-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.48);
}

.order-modal.is-open {
    display: flex;
    animation: modalFadeIn 0.18s ease-out;
}

.developer-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.48);
}

.developer-modal.is-open {
    display: flex;
    animation: modalFadeIn 0.18s ease-out;
}

.developer-modal-panel,
.order-modal-panel {
    width: min(330px, 100%);
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    text-align: center;
    animation: modalPopIn 0.22s cubic-bezier(0.2, 0.85, 0.3, 1.2);
}

.developer-modal-panel h3,
.order-modal-panel h3 {
    color: #333;
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

.developer-modal-text {
    color: #666;
    font-size: 0.88rem;
    margin-bottom: 0.85rem;
}

.developer-password-input {
    width: 100%;
    border: 1px solid #dddddd;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    padding: 0.8rem 0.9rem;
}

.developer-password-error {
    min-height: 1.2rem;
    color: #c1263f;
    font-size: 0.8rem;
    margin: 0.6rem 0 0.9rem;
}

.developer-modal-actions,
.order-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.developer-cancel-btn,
.developer-confirm-btn,
.modal-cancel-btn,
.modal-ok-btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 0.75rem 1rem;
    -webkit-tap-highlight-color: transparent;
}

.developer-cancel-btn,
.modal-cancel-btn {
    background: #eeeeee;
    color: #333;
}

.developer-confirm-btn,
.modal-ok-btn {
    background: #25D366;
    color: #ffffff;
}

@keyframes modalFadeIn {
    from {
        background: rgba(0, 0, 0, 0);
    }
    to {
        background: rgba(0, 0, 0, 0.48);
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Desktop styles */
@media (min-width: 769px) {
    .app-shell {
        width: var(--mobile-width);
        max-width: var(--mobile-width);
    }

    .main-container {
        max-width: 100% !important;
        min-width: 100% !important;
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
    }
    
    .header {
        width: var(--mobile-width);
        max-width: var(--mobile-width);
    }
    
    .sidebar {
        transform: translateX(calc(var(--mobile-width) / -2));
        width: var(--sidebar-width);
    }
    
    .sidebar-btn {
        font-size: 10px;
        padding: 0.75rem 0.5rem;
    }
    
    .hero-section,
    .featured-products,
    .stats-section,
    .footer {
        max-width: calc(var(--mobile-width) - var(--sidebar-width));
        margin-left: var(--sidebar-width);
    }

    .cart-section {
        max-width: 100%;
        margin-left: 0;
    }

    .bottom-cart-bar {
        width: calc(var(--mobile-width) - 24px);
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .modal-content {
        max-width: 500px;
    }
}
