:root {
    --primary-bg: #121212;
    --secondary-bg: #1E1E1E;
    --primary-accent: #00AFFF;
    --text-primary: #FFFFFF;
    --text-secondary: #B3B3B3;
    --border-color: #2c2c2c;
    --font-family: 'Poppins', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 1. Lock the base scroll behavior */
html {
    background-color: var(--primary-bg);
    overscroll-behavior-y: none;
}

/* 2. Pin the body to the screen so it cannot shift */
body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden !important;
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--primary-bg);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
}

/* 3. The container fills the locked body */
.app-container {
    width: 100%;
    height: 100dvh;
    max-width: 450px;
    margin: 0 auto;
    position: relative;
    background-color: var(--primary-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Screen Management */
.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Remove padding here, handle it in the scrollable content */
}
.screen.active {
    display: flex;
    opacity: 1;
    z-index: 10;
}

/* 4. This is the designated scroll area */
.screen-content {
    flex-grow: 1;
    padding: 20px;
    padding-bottom: calc(90px + env(safe-area-inset-bottom)); /* Clear the nav menu */
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
}
.screen-content.no-padding { 
    padding: 0; 
    padding-bottom: calc(110px + env(safe-area-inset-bottom)); 
}
.screen-content.centered { justify-content: center; align-items: center; text-align: center; }

/* Headers */
.app-header {
    padding: 15px 20px;
    text-align: center;
}
.logo { height: 100px; width: auto; }
.screen-header { display: flex; align-items: center; padding: 15px; background-color: var(--secondary-bg); }
.screen-header h2 { flex-grow: 1; text-align: center; margin: 0; font-size: 1.2rem; font-weight: 500; }
.back-icon { font-size: 1.5rem; cursor: pointer; position: absolute; }

/* Buttons */
.btn { padding: 15px 20px; border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; font-family: var(--font-family); cursor: pointer; transition: background-color 0.2s ease, transform 0.1s ease; text-align: center; text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background-color: var(--primary-accent); color: var(--primary-bg); }
.btn-primary:disabled { background-color: #555; color: #999; cursor: not-allowed; }
.btn-secondary { background-color: var(--secondary-bg); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-large { padding: 18px 20px; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* Bottom Navigation */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(70px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background-color: var(--secondary-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-color);
    z-index: 100;
}
.nav-item { display: flex; flex-direction: column; align-items: center; color: var(--text-secondary); text-decoration: none; font-size: 0.7rem; transition: color 0.2s ease; }
.nav-item i { font-size: 1.5rem; margin-bottom: 4px; }
.nav-item.active { color: var(--primary-accent); }

/* Map */
.map-container, .map-container-full { width: 100%; background-color: var(--secondary-bg); border-radius: 12px; }
.map-container { height: 250px; }
.map-container-full { flex-grow: 1; border-radius: 0; }
.location-footer { padding: 20px; background-color: var(--secondary-bg); display: flex; flex-direction: column; gap: 15px; }

/* Forms & Inputs */
.modern-input, .modern-select { width: 100%; padding: 15px; background-color: #2a2a2a; border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); font-size: 1rem; font-family: var(--font-family); }
.modern-input::placeholder { color: var(--text-secondary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
#cc-name, #cc-number { grid-column: 1 / -1; }

/* Photo Upload */
.instruction-text { color: var(--text-secondary); text-align: center;}
#photo-thumbnails { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.thumbnail { position: relative; width: 100px; height: 100px; }
.thumbnail img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.remove-photo { position: absolute; top: -5px; right: -5px; background: #ff4d4d; color: white; width: 24px; height: 24px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; font-size: 0.8rem; border: 2px solid var(--primary-bg); }
.progress-bar { width: 100%; height: 8px; background-color: #333; border-radius: 4px; overflow: hidden; }
.progress-bar-inner { width: 0%; height: 100%; background-color: var(--primary-accent); transition: width 0.3s ease; }

/* Service Selection */
.section-title { margin-bottom: 0; font-weight: 500; }
.service-options { display: flex; justify-content: space-around; padding: 10px; background-color: var(--secondary-bg); border-radius: 12px; font-size: 0.8rem; }
.service-guide-item span { color: var(--primary-accent); font-weight: 600; }
.count-selector { display: flex; gap: 10px; }
.count-selector .count-box { flex-grow: 1; padding: 15px; border: 1px solid var(--border-color); border-radius: 8px; text-align: center; cursor: pointer; transition: all 0.2s ease; }
.count-selector .count-box.selected { background-color: var(--primary-accent); color: var(--primary-bg); border-color: var(--primary-accent); font-weight: 700; }
.rv-service-item .modern-select { flex-grow: 1; }
.rv-service-item { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rv-service-item label { font-weight: 500; flex-shrink: 0; width: 55px; }

/* Footer & Total */
.screen-footer-fixed {
    position: absolute;
    bottom: calc(70px + env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(18,18,18,1) 70%, rgba(18,18,18,0));
    padding: 20px 20px 10px 20px;
    z-index: 20;
}
.total-display { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.total-display h3, .total-display span { font-size: 1.4rem; font-weight: 700; }
#total-amount { color: var(--primary-accent); }

/* Give the service screen heavy bottom padding so inputs can scroll above keyboard */
#service-screen .screen-content {
    padding-bottom: 250px; 
}

/* Status Screens */
.spinner i { font-size: 4rem; color: var(--primary-accent); }
.status-text { margin-top: 20px; font-size: 1.5rem; font-weight: 500; }

/* Progress Screen */
.provider-info-card { position: absolute; bottom: 80px; left: 10px; right: 10px; background-color: var(--secondary-bg); border-radius: 12px; padding: 15px; display: flex; justify-content: space-between; align-items: center; gap: 15px; border: 1px solid var(--border-color); z-index: 20; }
.provider-details { display: flex; align-items: center; gap: 15px; }
.provider-avatar { width: 50px; height: 50px; border-radius: 50%; }
.provider-eta { font-size: 0.9rem; color: var(--text-secondary); }
.provider-name { font-size: 1.1rem; font-weight: 600; margin: 0; }
.map-label { text-align: center; color: var(--text-secondary); font-weight: 500; font-size: 0.9rem; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); margin-bottom: -10px; }
.map-label i { color: var(--primary-accent); margin-right: 8px; }

/* Schedule Scroller Styles */
.scroller-container { position: relative; display: flex; height: 250px; width: 100%; margin: auto 0; }
.scroller-column { flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory; -ms-overflow-style: none; scrollbar-width: none; }
.scroller-column::-webkit-scrollbar { display: none; }
.scroller-item { height: 50px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-secondary); scroll-snap-align: center; transition: color 0.3s ease, font-size 0.3s ease; white-space: nowrap; }
.scroller-padding { height: 100px; flex-shrink: 0; }
.scroller-item.selected { color: var(--text-primary); font-weight: 600; font-size: 1.4rem; }
.scroller-selection-overlay { position: absolute; top: 100px; left: 0; right: 0; height: 50px; border-top: 2px solid var(--primary-accent); border-bottom: 2px solid var(--primary-accent); pointer-events: none; border-radius: 8px; }
#date-scroller { flex: 2; }
#hour-scroller, #minute-scroller { flex: 1; }

@keyframes fa-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Form Styles */
.auth-form { width: 100%; display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }
.auth-title { font-size: 1.8rem; font-weight: 600; text-align: center; color: var(--text-primary); }
.form-links { display: flex; flex-direction: column; align-items: center; gap: 15px; margin-top: 20px; }
.form-links a { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; }
.form-links a strong { color: var(--primary-accent); }

#login-screen .screen-content, #register-screen .screen-content, #forgot-password-screen .screen-content { justify-content: flex-start; padding-top: 40px; overflow-y: auto; }
#login-screen .app-header { padding-top: 40px; }
#login-screen .logo { height: 150px; width: auto; }
#register-screen .auth-title, #forgot-password-screen .auth-title { margin-bottom: -20px; }

/* Account Screen Styles */
.account-main-title { text-align: left; font-size: 2rem; font-weight: 700; padding: 10px 20px; }
.screen-header.no-border { border-bottom: none; background-color: var(--primary-bg); }
.account-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 30px; }
.account-grid-item { background-color: var(--secondary-bg); padding: 20px; border-radius: 12px; text-align: center; cursor: pointer; transition: background-color 0.2s ease; }
.account-grid-item:active { background-color: #333; }
.account-grid-item i { font-size: 2.5rem; color: var(--primary-accent); margin-bottom: 10px; }
.account-grid-item span { display: block; font-weight: 500; }
.account-list { display: flex; flex-direction: column; gap: 5px; }
.account-list-item { display: flex; align-items: center; padding: 18px 15px; background-color: var(--secondary-bg); border-radius: 8px; color: var(--text-primary); text-decoration: none; font-weight: 500; }
.account-list-item i { font-size: 1.2rem; color: var(--text-secondary); width: 40px; text-align: center; }

/* Sub-Screen Styles */
.history-item { background-color: var(--secondary-bg); padding: 15px; border-radius: 8px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.history-item-info h4 { margin: 0 0 5px; }
.history-item-info p { margin: 0; font-size: 0.8rem; color: var(--text-secondary); }
.history-item-total { font-size: 1.2rem; font-weight: 600; color: var(--primary-accent); }
#vehicle-photo-preview { width: 100%; height: auto; border-radius: 8px; margin-top: 15px; object-fit: cover; }
.legal-content h3 { color: var(--primary-accent); margin-top: 20px; }
.legal-content p { color: var(--text-secondary); white-space: pre-wrap; line-height: 1.6; }
.legal-content hr { border-color: var(--border-color); margin: 20px 0; }

/* Referral Screen */
#referral-code-box { font-size: 2rem; font-weight: 700; letter-spacing: 4px; padding: 20px 30px; border: 2px dashed var(--primary-accent); border-radius: 12px; margin: 20px 0; color: var(--primary-accent); }
#qr-code-container { padding: 15px; background-color: white; border-radius: 8px; margin-bottom: 20px; }
#profile-form, #vehicle-form, #support-form { display: flex; flex-direction: column; gap: 15px; }
#btn-logout { margin-top: 20px; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: none; justify-content: center; align-items: center; z-index: 1000; opacity: 0; transition: opacity 0.3s ease; }
.modal-content { background-color: var(--secondary-bg); padding: 25px; border-radius: 16px; width: 90%; max-width: 350px; text-align: center; border: 1px solid var(--border-color); transform: scale(0.95); transition: transform 0.3s ease; }
.modal-title { margin-top: 0; margin-bottom: 10px; font-size: 1.4rem; font-weight: 600; color: var(--text-primary); }
.modal-message { margin-bottom: 25px; color: var(--text-secondary); line-height: 1.6; }

/* Services List */
#service-selection-list { display: flex; flex-direction: column; gap: 15px; }
.service-option-item { background-color: var(--secondary-bg); border: 2px solid var(--border-color); padding: 20px; border-radius: 12px; cursor: pointer; transition: all 0.2s ease; }
.service-option-item h4 { margin: 0; font-size: 1.2rem; }
.service-option-item span { font-size: 1.1rem; color: var(--primary-accent); font-weight: 600; }
.service-option-item.selected { border-color: var(--primary-accent); background-color: #2a2a2a; }

/* Rates */
.rate-icon { border-radius: 50%; height: 80px; margin-bottom: 10px; }
.star-rating { text-align: center; margin-bottom: 20px; }
.star-rating i { font-size: 2.5rem; color: #555; margin: 0 5px; cursor: pointer; transition: all 0.2s ease; }
.star-rating i.fas { color: #FFC107; transform: scale(1.1); }
.tip-options { display: flex; gap: 10px; }
.tip-box { flex-grow: 1; padding: 15px; border: 1px solid var(--border-color); border-radius: 8px; text-align: center; cursor: pointer; transition: all 0.2s ease; font-weight: 600; }
.tip-box.selected { background-color: var(--primary-accent); color: var(--primary-bg); border-color: var(--primary-accent); }
#password-form { display: flex; flex-direction: column; gap: 15px; }
.history-item.in-progress-job { cursor: pointer; border-left: 4px solid var(--primary-accent); padding-left: 11px; transition: background-color 0.2s ease; }
.history-item.in-progress-job:active { background-color: #2a2a2a; }

/* iOS Keyboard Overrides */
.app-container.keyboard-visible .bottom-nav,
.app-container.keyboard-visible .screen-footer-fixed {
    display: none;
}
/* Notice we REMOVED the rule here that shrunk the padding on #service-screen! */
/* ===========================================================================
   PHASE 2 FIXES — appended 2026-08-14
   =========================================================================== */

/* Modals had no max-height and no overflow. Combined with
   body{overflow:hidden !important} above, a tall modal's OK button became
   unreachable — there was no way to scroll to it. */
.modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6vh 16px calc(6vh + env(safe-area-inset-bottom));
}
.modal-content {
    max-height: 86dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: auto 0;
}

/* Horizontal safe areas for landscape and notched devices. */
.screen-content {
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
}

/* Long addresses and emails were pushing content off-screen; with
   overflow:hidden on the container that content was clipped, not scrollable. */
.history-item > div,
.account-list-item,
.service-option-item { min-width: 0; }
.history-item h4,
.history-item p,
.service-option-item h4,
.legal-content p { overflow-wrap: anywhere; }

/* Removes the iOS 300ms double-tap delay. */
.btn, .nav-item, .account-list-item, .account-grid-item,
.back-icon, .tip-box, .service-option-item, .star-rating i {
    touch-action: manipulation;
}

/* The back arrow was a bare glyph, well under the 44px minimum target. */
.back-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
}
.back-icon:active { background-color: rgba(255,255,255,.08); }

/* The service screen used a hardcoded 250px bottom padding to clear the
   keyboard, which is brittle across devices. The keyboard-visible class (set
   from visualViewport in app.js) now drives it instead. */
#service-screen .screen-content { padding-bottom: 180px; }
.app-container.keyboard-visible #service-screen .screen-content { padding-bottom: 24px; }

.screen-content { overscroll-behavior: contain; }
