/* ─── Apple-Style Carpool App CSS ─── */

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

:root {
    --blue: #007AFF;
    --orange: #FF9500;
    --green: #34C759;
    --red: #FF3B30;
    --gray1: #8E8E93;
    --gray2: #AEAEB2;
    --gray3: #C7C7CC;
    --gray4: #D1D1D6;
    --gray5: #E5E5EA;
    --gray6: #F2F2F7;
    --bg: #F2F2F7;
    --card-bg: #FFFFFF;
    --text: #1C1C1E;
    --text2: #3C3C43;
    --text3: #8E8E93;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    user-select: none;
}

#app {
    height: 100%;
    position: relative;
}

/* ─── Status Bar ─── */
.status-bar {
    height: var(--safe-top);
    min-height: 20px;
    background: transparent;
}

/* ─── Pages ─── */
.page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
}

.page.active {
    transform: translateX(0);
    z-index: 2;
}

.page-content {
    padding: 20px 20px calc(20px + var(--safe-bottom));
    min-height: 100%;
}

/* ─── Home ─── */
.home-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
}

.logo-area {
    text-align: center;
    margin-bottom: 60px;
}

.logo-icon {
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.app-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

.app-subtitle {
    font-size: 17px;
    color: var(--text3);
    margin-top: 6px;
    font-weight: 400;
}

/* ─── Buttons ─── */
.button-group {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.btn-primary {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 18px 20px;
    border: none;
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.btn-primary:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 14px;
}

.btn-driver .btn-icon { background: linear-gradient(135deg, #007AFF, #5856D6); }
.btn-passenger .btn-icon { background: linear-gradient(135deg, #FF9500, #FF2D55); }

.btn-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.btn-label {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.btn-desc {
    font-size: 13px;
    color: var(--text3);
    margin-top: 2px;
}

.btn-arrow {
    font-size: 22px;
    color: var(--gray3);
    font-weight: 300;
    margin-left: 8px;
}

/* ─── Nav Bar ─── */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(var(--safe-top) + 12px);
    background: rgba(242, 242, 247, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--blue);
    font-size: 17px;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 400;
}

.nav-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.nav-right {
    width: 60px;
}

/* ─── Section Header ─── */
.section-header {
    margin-bottom: 28px;
    margin-top: 8px;
}

.section-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.section-header p {
    font-size: 15px;
    color: var(--text3);
    margin-top: 6px;
}

/* ─── Route Cards ─── */
.route-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.route-card {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
}

.route-card:active {
    transform: scale(0.97);
    background: var(--gray6);
}

.route-card-icon {
    margin-right: 16px;
    flex-shrink: 0;
}

.route-card-text {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.route-from { color: var(--blue); }
.route-to { color: var(--orange); }
.route-arrow {
    color: var(--gray2);
    font-weight: 300;
    font-size: 20px;
}

/* ─── Route Badge ─── */
.route-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, rgba(0,122,255,0.1), rgba(88,86,214,0.1));
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--blue);
}

/* ─── Form ─── */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 4px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    z-index: 1;
}

.form-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    font-size: 17px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    outline: none;
    transition: box-shadow 0.2s;
    font-family: inherit;
}

.form-input:focus {
    box-shadow: 0 0 0 3px rgba(0,122,255,0.25);
}

.form-input::placeholder {
    color: var(--gray3);
}

/* ─── Time Picker Display ─── */
.time-display {
    display: flex;
    align-items: center;
    padding: 14px 16px 14px 44px;
    font-size: 17px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: box-shadow 0.2s;
    position: relative;
}

.time-display:active {
    box-shadow: 0 0 0 3px rgba(0,122,255,0.25);
}

.time-display .input-icon {
    position: absolute;
    left: 14px;
}

.time-display #time-display-text {
    flex: 1;
    color: var(--gray3);
}

.time-display.has-value #time-display-text {
    color: var(--text);
}

/* ─── Submit Button ─── */
.btn-submit {
    width: 100%;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    color: white;
    background: var(--blue);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
    font-family: inherit;
}

.btn-submit:active {
    transform: scale(0.97);
    opacity: 0.85;
}

.btn-submit:disabled {
    background: var(--gray3);
    cursor: not-allowed;
}

/* ─── Driver List ─── */
.driver-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.driver-card {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.driver-card:active {
    transform: scale(0.97);
}

.driver-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #5856D6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.driver-avatar svg {
    width: 24px;
    height: 24px;
}

.driver-info {
    flex: 1;
}

.driver-plate {
    font-size: 13px;
    font-weight: 600;
    color: #007AFF;
    background: rgba(0, 122, 255, 0.08);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

/* Plate input: fixed prefix + editable suffix */
.plate-input-wrapper {
    display: flex;
    align-items: center;
}

.plate-prefix {
    font-size: 17px;
    font-weight: 600;
    color: #000;
    padding: 0 2px 0 4px;
    white-space: nowrap;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.plate-suffix {
    letter-spacing: 2px;
    font-weight: 500;
    text-transform: uppercase;
}

.driver-phone {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.driver-phone a {
    color: var(--blue);
    text-decoration: none;
}

.driver-time {
    font-size: 14px;
    color: var(--text3);
    display: flex;
    align-items: center;
    gap: 4px;
}

.driver-call {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.driver-call:active {
    transform: scale(0.9);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text3);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    line-height: 1.5;
}

/* ─── Time Picker Modal ─── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.time-picker-modal {
    width: 100%;
    background: #F2F2F7;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}

.modal-overlay.show .time-picker-modal {
    transform: translateY(0);
}

/* ─── Header ─── */
.tp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #F2F2F7;
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
}

.tp-header-title {
    font-size: 17px;
    font-weight: 600;
    color: #000;
}

.tp-header-btn {
    background: none;
    border: none;
    font-size: 17px;
    cursor: pointer;
    padding: 4px 2px;
    font-family: inherit;
}

.tp-cancel { color: #007AFF; }
.tp-done { color: #007AFF; font-weight: 600; }

/* ─── Date Row ─── */
.tp-date-row {
    display: flex;
    justify-content: center;
    padding: 12px 16px 8px;
    background: #F2F2F7;
}

.tp-date-chip {
    background: #E8E8ED;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: #007AFF;
    cursor: pointer;
    padding: 5px 14px;
    border-radius: 14px;
    font-family: inherit;
}

.tp-date-chip:active {
    background: #D1D1D6;
}

/* ─── Wheels Container ─── */
.tp-wheels-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0 24px;
    background: #F2F2F7;
    gap: 0;
}

.tp-wheel-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tp-wheel-label {
    font-size: 12px;
    font-weight: 600;
    color: #8E8E93;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.tp-wheel-separator {
    font-size: 28px;
    font-weight: 300;
    color: #3C3C43;
    padding: 0 4px;
    margin-top: 22px;
}

/* ─── Individual Wheel ─── */
.tp-wheel {
    width: 80px;
    height: 216px; /* shows ~5 items at 40px each + padding */
    overflow: hidden;
    position: relative;
    border-radius: 8px;
    /* Gradient fade top/bottom for iOS feel */
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 20%,
        black 80%,
        transparent 100%
    );
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 20%,
        black 80%,
        transparent 100%
    );
}

.tp-wheel-inner {
    /* Will be positioned by JS */
    transition: transform 0.15s ease-out;
}

.tp-wheel-item {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 400;
    color: #3C3C43;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.1s, font-weight 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.tp-wheel-item.selected {
    font-weight: 600;
    color: #000;
}

/* Selection highlight bar */
.tp-wheel::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 4px;
    right: 4px;
    height: 36px;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    pointer-events: none;
    z-index: 1;
    border-top: 0.5px solid rgba(0,0,0,0.08);
    border-bottom: 0.5px solid rgba(0,0,0,0.08);
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
    text-align: center;
    max-width: 80%;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ─── Loading ─── */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.6);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.loading-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray5);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Responsive ─── */
@media (min-width: 500px) {
    .page-content {
        max-width: 480px;
        margin: 0 auto;
    }
}
