/* ==========================================================================
   CSS Variables & Multi-Design Theme Tokens
   ========================================================================== */

/* Design 1: Warm Artisan Bistro (Screenshot "Il Piatto" Aesthetic) */
:root, body.theme-d1 {
    --bg-main: #EFE8DE;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --text-primary: #1C1917;
    --text-secondary: #78716C;
    --text-muted: #A8A29E;
    --accent: #BA3A2A;
    --accent-light: #FDE8E5;
    --accent-green: #2E7D32;
    --accent-green-bg: #E8F5E9;
    --border-subtle: #E7DFD5;
    --btn-circle-bg: #FFFFFF;
    --btn-circle-color: #292524;
    --card-shadow: 0 4px 18px rgba(90, 70, 50, 0.06);
    --font-heading: 'Cinzel', 'Playfair Display', Georgia, serif;
    --font-body: 'Outfit', sans-serif;
    --tab-active-border: #BA3A2A;
    --header-bg: transparent;
}

/* Design 2: Midnight Luxury (Dark Charcoal & Royal Gold) */
body.theme-d2 {
    --bg-main: #121316;
    --bg-card: #1C1D22;
    --bg-input: #23252B;
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --accent: #E5B869;
    --accent-light: rgba(229, 184, 105, 0.15);
    --accent-green: #10B981;
    --accent-green-bg: rgba(16, 185, 129, 0.15);
    --border-subtle: #2C2D35;
    --btn-circle-bg: #22242B;
    --btn-circle-color: #E5B869;
    --card-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    --font-heading: 'Cinzel', 'Playfair Display', Georgia, serif;
    --font-body: 'Outfit', sans-serif;
    --tab-active-border: #E5B869;
    --header-bg: transparent;
}

/* Design 3: Fresh Organic Cafe (Sage Green & Minimalist White) */
body.theme-d3 {
    --bg-main: #F4F7F4;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --accent: #2E7D52;
    --accent-light: #E8F5EE;
    --accent-green: #16A34A;
    --accent-green-bg: #DCFCE7;
    --border-subtle: #E2E8F0;
    --btn-circle-bg: #FFFFFF;
    --btn-circle-color: #2E7D52;
    --card-shadow: 0 4px 16px rgba(46, 125, 82, 0.07);
    --font-heading: 'Cinzel', 'Playfair Display', Georgia, serif;
    --font-body: 'Outfit', sans-serif;
    --tab-active-border: #2E7D52;
    --header-bg: transparent;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Responsive Frame Container */
.app-viewport {
    width: 100%;
    max-width: 600px;
    min-height: 100vh;
    background-color: var(--bg-main);
    padding: 16px 20px 40px;
    position: relative;
    box-sizing: border-box;
    margin: 0 auto;
    transition: background-color 0.3s ease;
}

@media (max-width: 480px) {
    .app-viewport {
        padding: 14px 16px 36px;
    }
}

/* ==========================================================================
   Top App Navigation Bar
   ========================================================================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    margin-bottom: 18px;
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.table-pill i {
    font-size: 11px;
    color: var(--accent);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--btn-circle-bg);
    color: var(--btn-circle-color);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, background-color 0.2s ease;
}

.nav-icon-btn:active {
    transform: scale(0.92);
}

/* ==========================================================================
   Brand Header
   ========================================================================== */
.brand-section {
    text-align: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.brand-tagline {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 2px;
}

.brand-identity {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

.brand-logo {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 1.5px;
    color: var(--text-primary);
    text-align: center;
    text-transform: uppercase;
}

/* ==========================================================================
   Search Bar
   ========================================================================== */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

.search-container input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 10px 36px 10px 38px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-body);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.clear-search-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
}

/* ==========================================================================
   Category Horizontal Navigation
   ========================================================================== */
.category-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: -20px;
    margin-right: -20px;
    padding: 10px 20px 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: background-color 0.3s ease;
}

.category-menu-btn {
    background: none;
    border: none;
    font-size: 17px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 4px;
    display: flex;
    align-items: center;
}

.category-scroll-list {
    display: flex;
    align-items: center;
    gap: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
    padding: 2px 0;
}

.category-scroll-list::-webkit-scrollbar {
    display: none;
}

.category-tab-item {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 2px;
    position: relative;
    transition: color 0.2s ease;
    font-family: var(--font-body);
}

.category-tab-item.active {
    color: var(--text-primary);
    font-weight: 700;
}

.category-tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--tab-active-border);
    border-radius: 3px;
}

/* ==========================================================================
   Menu Section Header & Items
   ========================================================================== */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

.active-category-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.items-count-badge {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ==========================================================================
/* ==========================================================================
   Product Card Animations & Modern Styling
   ========================================================================== */
@keyframes productCardEnter {
    0% {
        opacity: 0;
        transform: translateY(16px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card {
    background-color: var(--bg-card);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    gap: 14px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-subtle);
    position: relative;
    overflow: hidden;
    animation: productCardEnter 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.2s ease;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.12);
}

.product-card:active {
    transform: scale(0.985);
}

.product-img-wrap {
    width: 100px;
    height: 100px;
    min-width: 100px;
    border-radius: 14px;
    overflow: hidden;
    background-color: #F0ECE4;
    position: relative;
}

.product-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.product-card:hover .product-img-wrap img {
    transform: scale(1.06);
}

.product-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.product-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 5px;
}

.product-category-chip {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    background-color: var(--border-subtle);
    padding: 2px 7px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

.product-tags-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.product-tag-chip {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background-color: var(--accent);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.product-tag-chip i {
    font-size: 8px;
    opacity: 0.85;
}

.product-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
    word-break: break-word;
    letter-spacing: -0.1px;
}

.product-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.35;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 2px;
}

.product-price {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: var(--text-primary);
}

.unit-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    background-color: var(--border-subtle);
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Modern Skeleton Loading & Shimmer
   ========================================================================== */
.loading-state {
    padding: 8px 0;
}

.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.skeleton-card {
    background-color: var(--bg-card);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    gap: 14px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--card-shadow);
}

.skeleton-img {
    width: 100px;
    height: 100px;
    min-width: 100px;
    border-radius: 14px;
}

.skeleton-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.skeleton-line {
    border-radius: 6px;
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-line.sm { width: 35%; height: 10px; }
.skeleton-line.md { width: 60%; height: 12px; }
.skeleton-line.lg { width: 85%; height: 16px; }

.skeleton-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.skeleton-shimmer {
    background: linear-gradient(90deg, var(--border-subtle) 0%, rgba(255, 255, 255, 0.7) 50%, var(--border-subtle) 100%);
    background-size: 200% 100%;
    animation: shimmerWave 1.4s infinite ease-in-out;
}

body.theme-d2 .skeleton-shimmer {
    background: linear-gradient(90deg, #22242B 0%, #30333D 50%, #22242B 100%);
    background-size: 200% 100%;
    animation: shimmerWave 1.4s infinite ease-in-out;
}

@keyframes shimmerWave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 38px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ==========================================================================
   Profile Modal / Bottom Sheet
   ========================================================================== */
.profile-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.profile-modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.profile-modal {
    width: 100%;
    max-width: 440px;
    background-color: var(--bg-card);
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    padding: 16px 24px 32px;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-modal-backdrop.active .profile-modal {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background-color: var(--border-subtle);
    border-radius: 4px;
    margin: 0 auto 16px;
}

.profile-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    position: relative;
}

.profile-avatar-wrap {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    overflow: hidden;
    background: #EFE8DE;
}

.profile-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-headline h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-badge {
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.modal-close-btn {
    position: absolute;
    right: 0;
    top: 4px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
}

.profile-details-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.profile-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    font-size: 13px;
}

.profile-row .row-icon {
    font-size: 16px;
    color: var(--accent);
    margin-top: 2px;
    width: 20px;
    text-align: center;
}

.profile-row strong {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
}

.profile-row p {
    color: var(--text-secondary);
    margin-top: 1px;
}

.profile-modal-footer {
    display: flex;
    gap: 12px;
}

.btn-primary {
    flex: 1;
    background-color: var(--accent);
    color: #FFFFFF;
    text-decoration: none;
    padding: 12px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--accent-light);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 480px) {
    .app-viewport {
        padding: 12px 16px 36px;
    }

    .category-nav {
        margin-left: -16px;
        margin-right: -16px;
        padding: 10px 16px 8px;
    }

    .brand-logo {
        font-size: 22px;
        letter-spacing: 1px;
    }

    .product-img-wrap {
        width: 86px;
        height: 86px;
        min-width: 86px;
    }
}

@media (min-width: 768px) {
    .app-viewport {
        max-width: 840px;
        padding: 24px 28px 60px;
    }

    .category-nav {
        margin-left: -28px;
        margin-right: -28px;
        padding: 12px 28px 10px;
    }

    .brand-logo {
        font-size: 30px;
        letter-spacing: 2px;
    }

    .product-list, .skeleton-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}
