/* --- 1. CORE VARIABLES & RESET --- */
:root { 
    --brand-color: #6A1B9A; 
    --money-green: #2ecc71; 
    --cream-bg: #F9F7F2;
    --gold: #d3a84c; 
    --olive-green: #4A5D23; 
    --text-dark: #2C3E50; 
    --alert-red: #c21807;
    --border-light: #eee;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent;
}

body { 
    font-family: 'Poppins', sans-serif; 
    background-color: var(--cream-bg); 
    margin: 0; 
    padding-bottom: 100px; 
    color: var(--text-dark); 
    overflow-x: hidden;
}

.container { 
    max-width: 450px; 
    margin: 0 auto; 
    min-height: 100vh; 
    position: relative;
}

/* --- 2. WEALTH BAR & HUD --- */
.wealth-bar { 
    background: var(--brand-color); 
    color: white;
    padding: 25px 5px 15px; 
    text-align: center; 
    border-bottom: 3px solid var(--gold); 
    position: sticky; 
    top: 0; 
    z-index: 999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.stats-row { 
    display: flex; 
    justify-content: space-around; 
    margin-bottom: 12px;
}

.wealth-val { 
    display: block; 
    font-size: 1.2rem; 
    font-weight: 700; 
}

.wealth-label { 
    font-size: 0.65rem;
    text-transform: uppercase; 
    opacity: 0.9; 
    letter-spacing: 0.5px;
}

.habit-status-line { 
    border-top: 1px solid rgba(255, 215, 0, 0.3);
    padding-top: 10px; 
    font-size: 0.8rem; 
    font-weight: 700; 
    color: var(--gold); 
}

/* --- 3. COMMON UI COMPONENTS --- */
.primary-btn { 
    width: 100%;
    background: var(--brand-color); 
    color: white; 
    padding: 18px; 
    border-radius: 12px; 
    border: none; 
    font-weight: 700; 
    cursor: pointer; 
    margin-top: 10px;
    transition: transform 0.1s ease, opacity 0.2s ease, background 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    font-family: inherit;
    font-size: 1rem;
}

.primary-btn:active { transform: scale(0.98); opacity: 0.9; }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none;
}

.pill-btn-outline { 
    background: transparent; 
    color: var(--alert-red); 
    border: 1px solid var(--alert-red); 
    padding: 6px 12px; 
    border-radius: 15px;
    font-size: 0.8rem; 
    font-weight: 600; 
    cursor: pointer; 
    font-family: inherit; 
    transition: all 0.2s ease;
}

.pill-btn-outline:hover { background: #fee2e2;
}

.card { 
    background: white; 
    padding: 20px; 
    border-radius: 25px; 
    margin-bottom: 15px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.view-section { display: none; }
.view-active { display: block !important; }
.content-padding { padding: 15px;
}

.pot-input { 
    width: 100%; 
    border-radius: 15px; 
    border: 2px solid #ddd; 
    padding: 15px; 
    text-align: center; 
    font-family: inherit;
    margin: 10px 0; 
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.pot-input:focus { border-color: var(--brand-color);
}

.drop-content { 
    display: none; 
    background: white; 
    border-radius: 15px; 
    padding: 15px; 
    border: 1px solid #eee; 
    margin-top: 5px;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0);
} }
.active-content { display: block !important; }

/* --- 4. AUTHENTICATION GATE & BRANDING --- */
.auth-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: white; z-index: 9999;
    display: flex; flex-direction: column; overflow-y: auto;
}

.auth-header {
    background-color: var(--olive-green);
    color: var(--gold);
    padding: 50px 20px 25px;
    display: flex; align-items: center; justify-content: center;
    gap: 15px;
}

.auth-chef-icon, .header-chef-icon {
    width: 60px; height: 60px; object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.header-chef-icon { width: 45px; height: 45px; margin: 0; }

.auth-card { padding: 40px 25px; flex: 1; }
.auth-card h2 { color: var(--text-dark);
    font-size: 1.8rem; margin: 0 0 5px 0; }
.auth-card p.instruction-text { color: #888; margin: 0 0 30px 0; font-size: 0.95rem;
}

.auth-input-group { margin-bottom: 20px; text-align: left; }
.auth-input-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-dark);
}
.auth-input-group input { width: 100%; padding: 16px; border: 2px solid #ddd; border-radius: 12px; font-family: inherit; font-size: 1rem; outline: none;
}
.auth-input-group input:focus { border-color: var(--olive-green); }

.auth-options { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; font-size: 0.85rem;
}
.remember-me { display: flex; align-items: center; gap: 8px; color: #666; cursor: pointer; }
.forgot-link, .signup-link { color: var(--gold); font-weight: 600;
    cursor: pointer; }

.auth-btn-primary { 
    width: 100%; background-color: var(--olive-green); color: white; padding: 18px; 
    border-radius: 12px; border: none;
    font-weight: 700; font-size: 1.1rem; cursor: pointer; 
    transition: transform 0.1s ease;
}
.auth-btn-primary:active { transform: scale(0.98);
}

.auth-btn-google { 
    width: 100%; background-color: white; color: var(--text-dark); padding: 16px; 
    border-radius: 12px; border: 2px solid #ddd;
    font-weight: 600; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    font-family: inherit; font-size: 1rem;
}

.auth-btn-google img { width: 20px; height: 20px; }
.auth-footer-text { text-align: center; margin-top: 25px; color: #666;
    font-size: 0.9rem; }

/* --- 5. SHOPPING & KITCHEN ROWS --- */
.input-row { display: flex; gap: 10px; align-items: center;
}

.shopping-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: white; 
    padding: 12px 15px; 
    border-radius: 15px;
    margin-bottom: 8px; 
    border: 1px solid #eee; 
    transition: all 0.2s ease;
}

.item-info { display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.qty-badge { 
    background: var(--brand-color); color: white; padding: 3px 8px; 
    border-radius: 8px; font-size: 0.75rem; font-weight: 700;
}

.control-group { display: flex; gap: 8px; }
.math-btn { 
    width: 38px; height: 38px; border-radius: 10px; border: none;
    font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; 
    font-size: 1.1rem; transition: transform 0.1s;
}
.math-btn:active { transform: scale(0.95);
}
.btn-plus { background: var(--brand-color); color: white; }
.btn-minus { background: #f0f0f0; color: #888; }
.btn-got { background: var(--money-green); color: white; width: 45px;
}

/* --- 6. COOKBOOK & MEAL CART --- */
.cookbook-item { 
    display: flex; align-items: center; background: white;
    padding: 15px; border-radius: 15px; margin-bottom: 12px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.04); cursor: pointer; 
    transition: transform 0.1s ease;
}
.cookbook-item:active { transform: scale(0.98); }

.cookbook-thumb { 
    width: 90px; height: 90px; border-radius: 12px; 
    object-fit: cover; margin-right: 15px;
    background: #f5f5f5; 
    border: 1px solid #eee;
}

.cookbook-info { flex: 1; }
.cookbook-info h3 { margin: 0; font-size: 1.1rem; color: var(--brand-color);
    line-height: 1.3; }

.scan-qty-controls { display: flex; align-items: center; gap: 12px; }
.qty-btn { 
    width: 32px; height: 32px;
    border-radius: 50%; border: 1px solid #ddd;
    background: white; font-weight: bold; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: background 0.2s;
    color: var(--brand-color);
}
.qty-btn:active { background: #f0f0f0; }

.sticky-search { position: sticky; top: 0; background: var(--cream-bg); padding-bottom: 10px;
    z-index: 10; margin-top: 15px; }

.floating-cart-btn {
    position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%);
    width: 90%;
    max-width: 400px; background: var(--money-green) !important;
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4); z-index: 2500;
    display: none; font-size: 1.1rem;
    padding: 18px; border-radius: 30px;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp { 
    0% { bottom: -100px; opacity: 0;
    } 
    100% { bottom: 25px; opacity: 1;
    } 
}

/* --- 7. ADMIN FACTORY (THE VAULT) --- */
.admin-card { 
    background: white; border-radius: 15px;
    padding: 15px; 
    margin-bottom: 15px; border: 1px solid var(--border-light); 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.admin-card h4 { margin: 0 0 8px 0; color: var(--brand-color); font-size: 1.1rem; }

.admin-card-stats { 
    display: flex;
    gap: 8px; font-size: 0.75rem; color: #888; 
    margin-bottom: 10px; flex-wrap: wrap; 
}

.admin-card-stats span { background: #f0f4f8; padding: 4px 8px; border-radius: 6px;
    color: var(--text-dark); font-weight: 600; }

.admin-card-actions { display: flex; gap: 8px; margin-top: 12px;
}
.admin-card-actions button { 
    flex: 1; padding: 10px; border-radius: 10px; border: none; 
    font-weight: 700; cursor: pointer;
    font-size: 0.8rem; transition: opacity 0.2s;
}
.admin-card-actions button:active { opacity: 0.8; }

.btn-approve { background: var(--money-green); color: white; }
.btn-edit { background: #f0f0f0;
    color: var(--text-dark); }
.btn-reject { background: #fee2e2; color: var(--alert-red); }

.edit-input-group { margin-bottom: 15px; text-align: left; }
.edit-input-group label { display: block;
    font-size: 0.8rem; font-weight: 700; margin-bottom: 4px; color: #888; }
.edit-field { 
    width: 100%; border: 1px solid #ddd;
    border-radius: 8px; 
    padding: 12px; font-family: inherit; font-size: 0.9rem;
    outline: none;
}
.edit-field:focus { border-color: var(--brand-color);
}

/* --- 8. RECEIPT SCANNER & STOCKTAKE --- */
.scan-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px; background: white; border-radius: 12px;
    margin-bottom: 10px; border-left: 5px solid var(--money-green);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* --- 9. NAVIGATION & OVERLAYS --- */
.nav-bar { 
    position: fixed; bottom: 0; left: 50%;
    transform: translateX(-50%); 
    width: 100%; max-width: 450px; background: white; 
    display: flex; justify-content: space-around; padding: 12px 0; 
    border-top: 1px solid #eee;
    z-index: 1000; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
}

.nav-item { 
    border: none; background: none; color: #ccc;
    font-weight: 600; 
    font-size: 0.75rem; text-align: center; cursor: pointer; padding: 5px 10px;
    transition: color 0.2s ease; font-family: inherit;
}
.nav-active { color: var(--brand-color); }

.overlay { 
    display: none; position: fixed; top: 0; left: 0; width: 100%;
    height: 100%; 
    background: var(--cream-bg); z-index: 2000; padding: 20px; overflow-y: auto; 
    animation: fadeIn 0.2s ease-in-out;
}

/* --- 10. PLANNER & MATRIX COMPONENTS --- */
.meal-tab-btn {
    width: auto; padding: 10px 18px; font-size: 0.85rem;
    background: white; border: 1px solid #ccc; color: var(--text-dark);
    border-radius: 15px; cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: all 0.2s ease;
    font-weight: 600;
}

.meal-time-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 5px; margin-bottom: 20px; }
.meal-time-row::-webkit-scrollbar { display: none;
}

.action-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.budget-pill { width: 100% !important; text-align: center; font-weight: 700;
    padding: 12px 0; border-radius: 10px; }

.goal-select { text-align: center; font-weight: 700; width: 100%; padding: 15px; }
.goal-selected { background: var(--olive-green) !important;
    color: white !important; border-color: var(--olive-green); box-shadow: 0 4px 10px rgba(74, 93, 35, 0.3); }

.btn-this-week { background: white; color: var(--brand-color);
    border: 2px solid var(--brand-color); margin-top: 0; }
.btn-this-week.active-gold {
    background: var(--gold) !important; color: white !important;
    border: 2px solid var(--gold);
    box-shadow: 0 4px 15px rgba(211, 168, 76, 0.4);
}

.switch { position: relative; display: inline-block; width: 52px;
    height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0;
    left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px;
    width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: var(--olive-green); }
input:checked + .slider:before { transform: translateX(24px); }

/* Pantry Grid */
.pantry-grid { display: grid;
    grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 15px; }
.pantry-item { 
    padding: 12px 5px; border-radius: 12px;
    border: 1px solid #ddd; 
    font-size: 0.65rem; text-align: center; font-weight: 700; cursor: pointer; background: white;
    transition: all 0.2s ease; user-select: none;
}
.pantry-active { background: var(--money-green) !important; color: white !important; border-color: var(--money-green); box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

/* Choice Cards (AI Results) */
.choice-card { 
    background: white; border-radius: 25px; padding: 25px; 
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); 
    text-align: center; border: 1px solid var(--border-light);
}

.cook-btn { 
    background: var(--money-green);
    color: white; border: none; 
    padding: 16px; border-radius: 15px; font-weight: 700; width: 100%; cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.2); transition: transform 0.1s;
}
.cook-btn:active { transform: scale(0.98);
}

/* Checkout logic */
.checkout-item { 
    padding: 14px; border-radius: 12px; margin-bottom: 10px; 
    display: flex; justify-content: space-between;
    align-items: center;
    font-weight: 600; font-size: 0.95rem;
}
.checkout-item-buy { background: #fff5f5; border: 1px solid #ffe3e3; color: var(--alert-red); }
.checkout-item-own { background: #f0fdf4;
    border: 1px solid #dcfce7; color: var(--money-green); }

/* --- 11. MINI COOKBOOK CAROUSEL & UPSELL --- */
#mini-cookbook-track::-webkit-scrollbar {
    display: none;
}
#mini-cookbook-track {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#zero-results-container, #mini-cookbook-container {
    animation: fadeIn 0.3s ease-in-out;
}

/* =========================================================
   NEW PHASE 1 STYLES: CHEF PERCY VISUAL FOUNDATION 
   ========================================================= */

/* The Global Percy Terminal Trigger */
.percy-floating-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: white;
    border: 3px solid var(--brand-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    z-index: 9999;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.percy-floating-btn:active {
    transform: scale(0.95);
}
.percy-floating-btn img {
    width: 35px;
    height: 35px;
    margin: 0;
}

/* The Wealth Center Progress Bar */
.goal-progress-container {
    width: 100%;
    height: 20px;
    background-color: #eee;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.goal-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, var(--gold), #f39c12);
    width: 0%;
    transition: width 0.5s ease-in-out;
}

/* =========================================================
   NEW PHASE 2 STYLES: SAVINGS HUB & MODAL SHEETS 
   ========================================================= */

.savings-shortcut-banner {
    background: var(--gold);
    color: white;
    text-align: center;
    padding: 10px;
    margin-top: 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}

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

.modal-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 85vh;
    background: white;
    z-index: 20000;
    border-radius: 25px 25px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    transition: bottom 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.modal-sheet.active {
    bottom: 0;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
}

.sheet-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    color: var(--brand-color);
    font-weight: 700;
}

.inventory-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 40px;
}

/* =========================================================
   NEW PHASE 3 STYLES: SMART SHOPPING LIST & QUICK-ADD PILLS 
   ========================================================= */

#quick-add-pills::-webkit-scrollbar {
    display: none;
}
#quick-add-pills {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.quick-add-pill {
    background: white;
    border: 1px solid var(--gold);
    color: var(--brand-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    user-select: none;
}

.quick-add-pill:active {
    transform: scale(0.95);
    background: var(--gold);
    color: white;
}

/* =========================================================
   NEW PHASE 4 STYLES: INVENTORY ASSET MANAGER (CARDS)
   ========================================================= */

.inventory-card {
    background: white;
    border-radius: 20px;
    padding: 18px;
    margin-bottom: 12px;
    border: 1px solid #f0f0f0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeIn 0.3s ease-out;
}

/* Card Header: Name and Price */
.inv-card-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.inv-item-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-dark);
    text-transform: capitalize;
    flex: 1;
}

.inv-item-price {
    font-weight: 700;
    color: var(--brand-color);
    font-size: 1rem;
    background: #f4f7f4;
    padding: 4px 10px;
    border-radius: 10px;
}

/* Card Metadata: Date and Freshness Labels */
.inv-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f9f9f9;
    padding-top: 10px;
}

.inv-date {
    font-size: 0.75rem;
    color: #95a5a6;
    font-weight: 500;
}

.freshness-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.freshness-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-fresh { color: #27ae60; }
.dot-fresh { background-color: #27ae60; box-shadow: 0 0 5px rgba(39, 174, 96, 0.4); }

.status-soon { color: #f39c12; }
.dot-soon { background-color: #f39c12; box-shadow: 0 0 5px rgba(243, 156, 18, 0.4); }

/* Card Controls: Integrated +/- Buttons */
.inv-card-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.inv-qty-display {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.inv-math-group {
    display: flex;
    gap: 12px;
}

/* Visual Feedback for Purchase Ceiling */
.math-btn.btn-disabled {
    background-color: #f0f0f0 !important;
    color: #ccc !important;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
}

/* =========================================================
   NEW: DEEP-ZOOM LIGHTBOX CSS
   ========================================================= */

#lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.95);
    z-index: 30000;
    opacity: 0;
    transition: opacity 0.3s ease;
    touch-action: none; /* Prevents browser pull-to-refresh while zooming */
}

#lightbox-overlay.active {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
}

#lightbox-zoom-wrapper {
    width: 100%;
    height: 100%;
    overflow: auto; /* Fallback for non-touch devices */
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-img {
    transition: transform 0.1s ease-out;
    transform-origin: center center;
    max-width: 90%;
    height: auto;
    cursor: zoom-in;
    border-radius: 4px;
}

.lightbox-controls {
    position: fixed;
    top: 20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 31000;
}

.zoom-btn {
    background: white;
    color: var(--brand-color);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.close-view-btn {
    background: var(--alert-red);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}