/* BASE LAYOUT */
.hidden { display: none !important; }

html, body {
    height: 100%; width: 100%;
    margin: 0; padding: 0;
    overflow: hidden; /* Lock body */
    position: fixed; /* Stop iOS bounce */
}

#app {
    display: flex; flex-direction: column;
    height: 100%; width: 100%;
    background: #fff;
    position: relative;
    overflow: hidden;
}

/* SCROLLABLE AREA */
#main-view {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px; /* Space for nav */
}

/* FIXED BOTTOM NAV */
.bottom-nav {
    height: 65px; /* Fixed height for content */
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid #eee;
    display: flex; justify-content: space-around; align-items: center;
    z-index: 100;
    position: absolute; bottom: 0; left: 0; right: 0;
    
    /* CRITICAL: Safe Area Handling */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(65px + env(safe-area-inset-bottom, 0px)); 
    box-sizing: border-box; /* Include padding in height */
}

/* LOADING */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; }
.spinner { width: 40px; height: 40px; border: 4px solid #f9fafb; border-top-color: #facc15; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* DESKTOP WRAPPER (Centered Phone) */
@media (min-width: 480px) {
    body {
        background: #f3f4f6;
        display: flex; align-items: center; justify-content: center;
    }
    #app {
        width: 100%; max-width: 420px;
        height: 100vh; max-height: 900px;
        box-shadow: 0 0 50px rgba(0,0,0,0.1);
        border: 1px solid #eee;
    }
}
.toast-msg {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: #16a34a; color: #fff; padding: 12px 24px; border-radius: 30px;
    font-size: 13px; font-weight: bold; box-shadow: 0 5px 20px rgba(22,163,74,0.4);
    z-index: 9999; animation: fadeInUp 0.3s forwards; display: flex; align-items: center; gap: 8px;
}
.toast-msg::before { content: '✓'; font-weight: 900; font-size: 14px; }
@keyframes fadeInUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
.btn-add-yellow {
    background: #facc15; color: #000; border: none; padding: 8px 16px; border-radius: 10px; font-weight: bold; font-size: 12px; cursor: pointer; transition: 0.2s;
}
.btn-add-yellow:active { transform: scale(0.95); background: #eab308; }
.btn-add-yellow {
    position: relative; z-index: 10; cursor: pointer !important;
}
/* --- APP-LIKE FEEL (NO SELECT) --- */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
input, textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
}
/* FIX: STRICT SCROLL CONTROL */
#main-view {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain; /* جلوگیری از انتقال اسکرول به بادی */
}

/* جلوگیری از کشیده شدن هدر */
.status-bar-container, .nav-bar, .bottom-nav {
    touch-action: none; /* غیرفعال کردن تاچ روی هدر و فوتر */
}
.toast-success {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background: #10b981; color: #fff; padding: 15px 30px;
    border-radius: 30px; font-weight: bold; box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
    z-index: 10000; animation: slideDown 0.3s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}
@keyframes slideDown { from { top: -50px; opacity: 0; } to { top: 20px; opacity: 1; } }
#main-view { padding-bottom: 90px !important; }