/* =========================================
   1. CSS VARIABLES & RESET
========================================= */
:root {
    --primary-color: #007AFF; /* iOS Blue */
    --bg-color: #F2F2F7;     /* iOS Light Gray Background */
    --card-bg: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --border-color: #E5E5EA;
    
    --header-height: 60px;
    --bottom-nav-height: 65px; /* Includes safe area padding */
    
    /* Safe areas for notched phones */
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Removes blue tap highlight on Android */
}

html, body {
    height: 100%;
    /* System fonts make it look native on iOS and Android */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overscroll-behavior: none; /* Prevents pull-to-refresh browser default */
}

/* =========================================
   2. APP SHELL LAYOUT
========================================= */
.app-container {
    display: flex;
    flex-direction: column;
    /* 100dvh is crucial! It fixes the mobile browser address bar hiding/showing issue */
    height: 100dvh; 
    max-width: 600px; /* Optional: caps width on tablets/desktops to look like a phone */
    margin: 0 auto;
    background-color: var(--bg-color);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* =========================================
   3. TOP HEADER
========================================= */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    padding-top: var(--safe-area-top);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 16px;
    padding-right: 16px;
    flex-shrink: 0;
}

.app-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
}

.header-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    padding: 8px;
}

.cart-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: red;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   4. SCROLLABLE MAIN CONTENT
========================================= */
.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Enables momentum scrolling on iOS */
    padding: 16px;
    /* Add padding at the bottom so content isn't hidden behind the bottom nav */
    padding-bottom: calc(var(--bottom-nav-height) + 20px); 
}

/* Custom scrollbar (hidden for cleaner mobile look) */
.app-content::-webkit-scrollbar {
    display: none;
}

/* =========================================
   5. BOTTOM NAVIGATION
========================================= */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: var(--bottom-nav-height);
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 8px;
    /* Pushes the nav above the home indicator on notched phones */
    padding-bottom: var(--safe-area-bottom); 
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    gap: 4px;
    flex: 1;
    /* Minimum touch target size */
    min-height: 44px; 
    justify-content: center;
}

.nav-item.active {
    color: var(--primary-color);
}

/* Touch feedback (replaces :hover) */
.nav-item:active {
    opacity: 0.5;
    transform: scale(0.95);
    transition: all 0.1s ease;
}

/* =========================================
   6. REUSABLE COMPONENTS (Cards, Buttons)
========================================= */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
}

.btn-primary:active {
    background: #0056b3;
    transform: scale(0.98);
}

/* Section Titles */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
    margin-top: 8px;
}