/* --- 1. CORE STYLES & VARIABLES --- */
:root {
    --brand-dark: #2c5234; 
    --brand-light: #71b33c;
    --bg-color: #ffffff;
    --text-main: #333333;
    --gray-light: #f4f7f6;
}

/* --- CRITICAL S23 SCROLL FIX START --- */
html {
    height: auto;
    min-height: 100%;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    color: var(--text-main);
    line-height: 1.6;
    /* Unlock Scrolling */
    height: auto; 
    min-height: 100%;
    overflow-y: scroll !important; 
    -webkit-overflow-scrolling: touch;
}

.container, .tab-content {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px;
    
    /* FORCE SPACE AT BOTTOM */
    padding-bottom: 200px !important; 
    
    box-sizing: border-box;
    display: block;
}

.scroll-spacer {
    display: block !important;
    width: 100%;
    height: 150px !important;
    min-height: 150px !important;
    background: transparent;
    clear: both;
    flex-shrink: 0;
}
/* --- CRITICAL S23 SCROLL FIX END --- */


/* --- 2. LOGO & SPLASH SCREEN --- */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

.splash-logo {
    width: 150px;
    margin-bottom: 20px;
    animation: pulse 1.5s infinite ease-in-out;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--brand-light);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.fade-out { opacity: 0; visibility: hidden; }

/* --- 3. INPUTS & BUTTONS --- */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#item-input {
    flex-grow: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

#item-input:focus { border-color: var(--brand-light); }

.add-btn {
    background: var(--brand-light);
    color: white;
    border: none;
    padding: 0 25px;
    border-radius: 12px;
    font-size: 24px;
    cursor: pointer;
}

.asda-btn {
    display: block;
    width: 100%;
    padding: 18px;
    background-color: var(--brand-light);
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(113, 179, 60, 0.2);
    margin-bottom: 10px;
    transition: transform 0.1s;
}

.asda-btn:active { transform: scale(0.98); }

.button-grid {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.button-grid button { flex: 1; }

.clear-style {
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    padding: 18px;
}

/* --- 4. LISTS --- */
#preview-list {
    padding: 0;
    max-height: 300px; /* Taller on mobile */
    overflow-y: auto;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    list-style: none;
}

#preview-list li {
    background: white;
    margin-bottom: 8px;
    padding: 14px;
    border-radius: 10px;
    border-left: 5px solid var(--brand-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* --- 5. BOTTOM NAV --- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: white;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 999;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.75rem;
    cursor: pointer;
    width: 50%;
    height: 100%;
}

.nav-btn.active { color: var(--brand-light); font-weight: bold; }
.nav-icon { font-size: 1.4rem; margin-bottom: 2px; }

/* --- 6. SHOPPING MODE --- */
.aisle-header {
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--brand-dark);
    font-size: 1rem;
    border-left: 5px solid var(--brand-dark);
    padding: 12px 0 12px 15px;
    background-color: rgba(255, 255, 255, 0.95);
    font-weight: 800;
    text-transform: uppercase;
}

.shop-button {
    background-color: white;
    color: #333;
    border: 2px solid var(--brand-light);
    padding: 18px;
    margin-bottom: 12px;
    width: 100%;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: left;
}

.shop-button.in-trolley {
    background-color: #f1f8e9;
    border-color: #cfd8dc;
    color: #90a4ae;
    text-decoration: line-through;
    opacity: 0.7;
}

/* --- 7. SUCCESS OVERLAY --- */
#success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    z-index: 10000;
}
#success-overlay.active { opacity: 1; visibility: visible; }

#success-card {
    display: none;
    position: fixed;
    bottom: -100%; 
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    max-width: 380px;
    background: white;
    padding: 40px 20px;
    border-radius: 30px;
    text-align: center;
    z-index: 10001;
    transition: bottom 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
#success-card.active { display: block; bottom: 50px; }

.big-check {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    margin: 0 auto 20px;
}