/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

html, body {
    height: auto;
    min-height: 100%;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh; /* fallback */
    position: relative;
    display: flex;
    flex-direction: column;
}

@supports (height: 100dvh) {
    .container {
        min-height: 100dvh; /* precise on mobile */
    }
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background-color: white;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.menu-btn, .back-btn, .cart-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 20px;
    height: 16px;
    cursor: pointer;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #333;
    transition: 0.3s;
    border-radius: 1px;
}

.menu-btn.active .hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-btn.active .hamburger span:nth-child(2) {
    opacity: 0;
}

.menu-btn.active .hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

.logo h1 {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

/* Logo image */
.logo {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0; /* Prevent flex item from overflowing */
}

.logo img {
    display: block;
    width: auto;
    height: auto;
    max-width: 200px;
    max-height: 60px;
    object-fit: contain;
}

.cart-btn {
    position: relative;
}

/* Ensure cart icon is black */
.cart-btn { color: #000; }
.cart-btn svg { color: #000; stroke: #000; }
.cart-btn svg path { stroke: #000; }

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #F30F58;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
}

.spacer {
    width: 40px;
}

/* Products Grid */
.products-grid {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 50px;
    width: 100%;
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    flex: 1;
    min-height: 0;
}

.product-card {
    background-color: white;
    border-radius: 0%;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
    padding: 12px 12px 0 12px;
    box-sizing: border-box;
}

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

.product-image {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    align-self: center;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    line-height: 0;
    padding: 0;
    box-sizing: border-box;
}

.product-image img {
    display: block;
    width: 360px;
    max-width: 100%;
    height: auto;
    aspect-ratio: 2/3;
    max-height: 55vh;
    max-height: 55dvh;
    object-fit: contain;
    border-radius: 12px;
    vertical-align: middle;
}

.product-info {
    padding: 15px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.product-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.product-price {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.buy-btn {
    width: 100%;
    background-color: #1a1a2e;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 0%;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

.buy-btn:hover {
    background-color: #16213e;
}

.buy-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Cart Styles */
.cart-main {
    padding: 20px;
    padding-bottom: 50px;
}

.cart-title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image {
    width: 60px;
    height: 60px;
    background-color: #f0f0f0;
    border-radius: 8px;
    margin-right: 15px;
    background-size: cover;
    background-position: center;
}

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

.cart-item-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.cart-item-price {
    font-size: 14px;
    color: #666;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.quantity-btn {
    background: none;
    border: 1px solid #ddd;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.quantity-btn:hover {
    background-color: #f5f5f5;
}

.quantity {
    font-size: 16px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.remove-btn {
    color: #ff4444;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
}

.cart-total {
    margin: 30px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 12px;
}

.total-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
}

/* Order Form */
.order-section {
    margin-top: 30px;
}

.order-title {
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 25px;
    color: #333;
}

.order-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group input,
.form-group textarea {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 0%;
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a1a2e;
}

.payment-methods {
    margin: 20px 0;
}

.payment-methods h4 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
}

.payment-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payment-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 0%;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.payment-option:hover {
    background-color: #f8f9fa;
}

.payment-option input[type="radio"] {
    margin-right: 10px;
}

.payment-label {
    font-size: 16px;
}

.confirm-btn {
    background-color: #1a1a2e;
    color: white;
    border: none;
    padding: 15px;
    border-radius: 2%;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.2s ease;
}

.confirm-btn:hover {
    background-color: #16213e;
}

.confirm-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Footer */
.footer {
    margin-top: 50px; /* spacing between content and footer */
    background-color: #ffffff;
    border-top: 1px solid #eee;
}

.footer-inner {
    max-width: inherit;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-right a {
    margin-left: 16px;
    color: #333;
    text-decoration: none;
}

.footer-right a:hover {
    text-decoration: underline;
}

/* Ensure main grows to push footer down */
.container > main {
    flex: 1;
}

/* Empty Cart */
.empty-cart {
    text-align: center;
    padding: 60px 20px;
}

.empty-cart p {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.continue-shopping {
    background-color: #1a1a2e;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 0%;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.continue-shopping:hover {
    background-color: #16213e;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1a1a2e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Menu Sidebar */
.menu-sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background-color: white;
    z-index: 1001;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.menu-sidebar.active {
    left: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.menu-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.close-menu {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    line-height: 1;
}

.menu-nav {
    flex: 1;
    padding: 20px 0;
}

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

.menu-nav li {
    margin: 0;
}

.menu-nav a {
    text-decoration: none;
    color: #333;
    font-size: 18px;
    display: block;
    padding: 15px 20px;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f5f5f5;
}

.menu-nav a:hover {
    background-color: #f8f9fa;
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 350px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content p {
    margin-bottom: 10px;
    color: #666;
}

.modal-btn {
    background-color: #1a1a2e;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 0%;
    font-size: 16px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.2s ease;
}

.modal-btn:hover {
    background-color: #16213e;
}

/* About Page Styles */
.about-main {
    padding: 20px;
    padding-bottom: 50px;
}

.about-content {
    max-width: 600px;
    margin: 0 auto;
}

.about-title {
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.about-section {
    margin-bottom: 30px;
}

.about-section h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.about-section p {
    font-size: 16px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 15px;
}

.contact-info {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-top: 40px;
}

.contact-info h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.contact-info p {
    font-size: 16px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 10px;
}

.contact-info a {
    color: #1a1a2e;
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
    }
    
    .header {
        padding: 10px 15px;
    }
    
    .logo img {
        max-width: 130px;
        max-height: 50px;
    }
    
    .products-grid {
        padding: 10px 15px;
        gap: 12px;
        height: auto;
        min-height: 0;
    }
    
    .product-card {
        width: 100%;
        max-width: 100%;
        min-height: 0;
        max-height: calc(100vh - 64px);
        max-height: calc(100dvh - 64px);
    }
    
    .product-image {
        width: fit-content;
        max-width: 100%;
    }
    
    .product-info {
        padding: 10px 12px;
    }
    
    .product-name {
        font-size: 16px;
        margin-bottom: 4px;
    }
    
    .product-price {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .buy-btn {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .cart-main {
        padding: 15px;
    }
    
    .about-main {
        padding: 15px;
    }
    
    .about-title {
        font-size: 24px;
    }
    
    .about-section h3 {
        font-size: 18px;
    }
    
    .menu-sidebar {
        width: 280px;
        left: -280px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 12px;
    }
    
    .logo h1 {
        font-size: 20px;
    }
    
    .logo img {
        max-width: 130px;
        max-height: 50px;
    }
    
    .products-grid {
        padding: 8px 12px;
        gap: 10px;
        height: auto;
        min-height: 0;
    }
    
    .product-card {
        width: 100%;
        max-width: 100%;
        min-height: 0;
        max-height: calc(100vh - 56px);
        max-height: calc(100dvh - 56px);
    }
    
    .product-image {
        width: fit-content;
        max-width: 100%;
    }
    
    .product-info {
        padding: 8px 10px;
    }
    
    .product-name {
        font-size: 15px;
        margin-bottom: 2px;
    }
    
    .product-price {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .buy-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .cart-main {
        padding: 12px;
    }
    
    .about-main {
        padding: 12px;
    }
    
    .menu-sidebar {
        width: 260px;
        left: -260px;
    }
    
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .cart-item-image {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .cart-item-controls {
        align-self: flex-end;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}


/* Tablet and up: widen container and switch products to grid */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
    .products-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        grid-auto-rows: auto;
        gap: 20px;
        height: auto;
        min-height: 0;
    }
    
    .product-card {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 0;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
    
    .logo img {
        max-width: 200px;
        max-height: 70px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        grid-auto-rows: auto;
        height: auto;
        min-height: 0;
    }
    
    .product-card {
        height: auto;
        min-height: 0;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    .logo img {
        max-width: 200px;
        max-height: 80px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        grid-auto-rows: auto;
        height: auto;
        min-height: 0;
    }
    
    .product-card {
        height: auto;
        min-height: 0;
    }
}

/* Desktop */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .logo img {
        max-width: 200px;
        max-height: 90px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        grid-auto-rows: auto;
        height: auto;
        min-height: 0;
    }
    
    .product-card {
        height: auto;
        min-height: 0;
    }
}

/* Safari iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .product-image {
        width: fit-content !important;
        max-width: 100% !important;
    }
    
    .product-image img {
        border-radius: 12px !important;
    }
    
    .product-card {
        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100vh - 72px) !important;
        max-height: calc(100dvh - 72px) !important;
    }
    
    .products-grid {
        height: auto !important;
        min-height: 0 !important;
    }
    
    @media (max-width: 768px) {
        .product-card {
            max-height: calc(100vh - 64px) !important;
            max-height: calc(100dvh - 64px) !important;
        }
    }
    
    @media (max-width: 480px) {
        .product-card {
            max-height: calc(100vh - 56px) !important;
            max-height: calc(100dvh - 56px) !important;
        }
    }
    
    @media (min-width: 576px) {
        .products-grid {
            grid-auto-rows: auto !important;
        }
    }
}
