/* ============ Variables ============ */
:root {
    --primary-green: #4CAF50;
    --primary-dark: #2E7D32;
    --accent-orange: #FF9800;
    --background: #F5F5F5;
    --white: #FFFFFF;
    --text-dark: #333333;
    --text-light: #888888;
    --text-muted: #AAAAAA;
    --border-color: #E0E0E0;
    --badge-hit: #FFC107;
    --badge-sale: #F44336;
    --badge-recommend: #4CAF50;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body {
    padding-bottom: 70px;
    padding-top: 60px;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ============ Header ============ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--primary-dark);
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--white);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
}

.back-btn {
    font-size: 24px;
    color: var(--white);
    padding: 8px;
}

.cart-btn {
    position: relative;
    font-size: 24px;
    padding: 8px;
}

.cart-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-orange);
    color: var(--white);
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-badge:empty,
.cart-badge[data-count="0"] {
    display: none;
}

.clear-cart-btn {
    font-size: 20px;
    padding: 8px;
    color: var(--white);
}

.home-btn {
    font-size: 20px;
    padding: 8px;
}

/* ============ Search ============ */
.search-container {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--white);
}

.search-input {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--primary-green);
}

.search-btn {
    width: 44px;
    height: 44px;
    background: var(--primary-green);
    border-radius: 22px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============ Banners ============ */
.banners {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 16px;
}

.banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 60px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
    transition: var(--transition);
}

.banner:active {
    transform: scale(0.98);
}

.banner-sale {
    background: linear-gradient(135deg, var(--accent-orange), #F57C00);
}

.banner-hit {
    background: linear-gradient(135deg, var(--primary-green), var(--primary-dark));
}

.banner-icon {
    font-size: 20px;
}

/* ============ Sections ============ */
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.categories-section {
    padding: 16px;
}

.products-section {
    padding: 16px;
}

.products-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.filter-reset {
    font-size: 13px;
    color: var(--badge-sale);
    padding: 6px 12px;
    border: 1px solid var(--badge-sale);
    border-radius: 16px;
}

/* ============ Categories Scroll ============ */
.categories-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.categories-scroll::-webkit-scrollbar {
    display: none;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    cursor: pointer;
}

.category-image {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
    transition: var(--transition);
    overflow: hidden;
}

.category-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-card.active .category-image {
    border: 2px solid var(--primary-green);
}

.category-name {
    font-size: 12px;
    text-align: center;
    color: var(--text-dark);
}

/* ============ Products Grid ============ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #F9F9F9;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image .placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
}

.product-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--white);
}

.badge-hit {
    background: var(--badge-hit);
    color: var(--text-dark);
}

.badge-sale {
    background: var(--badge-sale);
}

.badge-recommend {
    background: var(--badge-recommend);
}

.product-favorite {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.product-favorite.active {
    color: var(--badge-sale);
}

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}

.price-current {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-green);
}

.price-old {
    font-size: 13px;
    color: var(--text-light);
    text-decoration: line-through;
}

.price-unit {
    font-size: 12px;
    color: var(--text-light);
}

.add-to-cart-btn {
    width: 100%;
    height: 36px;
    background: var(--primary-green);
    color: var(--white);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.add-to-cart-btn:active {
    background: var(--primary-dark);
}

.add-to-cart-btn.in-cart {
    background: var(--white);
    color: var(--primary-green);
    border: 1px solid var(--primary-green);
}

/* ============ Load More ============ */
.load-more {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.load-more-btn {
    padding: 12px 32px;
    background: var(--white);
    color: var(--primary-green);
    border: 1px solid var(--primary-green);
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
}

/* ============ Bottom Navigation ============ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--white);
    display: flex;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-light);
    transition: var(--transition);
}

.nav-item.active {
    color: var(--primary-green);
}

.nav-icon {
    font-size: 20px;
}

.nav-text {
    font-size: 11px;
}

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

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ Modal ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    transform: translateY(100%);
    transition: var(--transition);
    padding: 24px 16px;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: var(--background);
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ============ Product Modal ============ */
.product-modal-image {
    width: 100%;
    height: 250px;
    background: #F9F9F9;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.product-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-modal-name {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.product-modal-description {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.product-modal-price {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
}

.product-modal-price .price-current {
    font-size: 24px;
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.quantity-btn {
    width: 44px;
    height: 44px;
    background: var(--background);
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.unit-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    justify-content: center;
}

.unit-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
}

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

.modal-add-btn {
    width: 100%;
    height: 48px;
    background: var(--primary-green);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
}

/* ============ Empty State ============ */
.empty-state,
.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2,
.empty-cart h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.empty-state p,
.empty-cart p {
    color: var(--text-light);
    margin-bottom: 24px;
}

/* ============ Buttons ============ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 32px;
    background: var(--primary-green);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 32px;
    background: var(--white);
    color: var(--primary-green);
    border: 1px solid var(--primary-green);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
    margin-top: 12px;
}

/* ============ Status Filter ============ */
.status-filter {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.status-filter::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    transition: var(--transition);
}

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

/* ============ Orders List ============ */
.orders-container {
    padding: 16px;
}

.order-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.order-number {
    font-weight: 600;
}

.order-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-new {
    background: #E3F2FD;
    color: #1976D2;
}

.status-confirmed {
    background: #E8F5E9;
    color: #388E3C;
}

.status-preparing {
    background: #FFF3E0;
    color: #F57C00;
}

.status-ready {
    background: #E0F7FA;
    color: #0097A7;
}

.status-delivering {
    background: #F3E5F5;
    color: #7B1FA2;
}

.status-completed {
    background: #E8F5E9;
    color: #388E3C;
}

.status-cancelled {
    background: #FFEBEE;
    color: #D32F2F;
}

.order-date {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.order-items-preview {
    font-size: 13px;
    color: var(--text-dark);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-total {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-green);
}

.order-details-btn {
    font-size: 13px;
    color: var(--primary-green);
}

/* ============ Profile ============ */
.profile-container {
    padding: 16px;
}

.profile-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.profile-avatar {
    width: 60px;
    height: 60px;
    background: var(--background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.profile-info h2 {
    font-size: 18px;
    margin-bottom: 4px;
}

.profile-info p {
    font-size: 14px;
    color: var(--text-light);
}

.profile-menu {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.menu-icon {
    font-size: 20px;
    margin-right: 12px;
}

.menu-text {
    flex: 1;
    font-size: 15px;
}

.menu-arrow {
    color: var(--text-light);
}

.admin-item {
    background: #FFF3E0;
}

.shop-info {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.shop-info h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.shop-info p {
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 8px;
}

/* ============ FAQ ============ */
.faq-list {
    margin-top: 16px;
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
}

.faq-question {
    font-weight: 600;
    margin-bottom: 8px;
}

.faq-answer {
    font-size: 14px;
    color: var(--text-light);
}

/* ============ Contacts ============ */
.contacts-info {
    padding: 16px 0;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.contact-icon {
    font-size: 24px;
}

.contact-text {
    font-size: 15px;
}

/* ============ Favorites Container ============ */
.favorites-container {
    padding: 16px;
    padding-top: 76px;
}

/* ============ Responsive ============ */
@media (min-width: 400px) {
    .products-grid {
        gap: 16px;
    }
}

@media (min-width: 500px) {
    .modal-content {
        max-width: 480px;
        margin: 0 auto;
        border-radius: 20px;
    }
    
    .modal {
        align-items: center;
    }
    
    .modal.active .modal-content {
        transform: translateY(0);
    }
}
