:root {
    --bg-color: #ffffff; /* Matched to car image's pure white background */
    --text-dark: #374151;
    --text-light: #9ca3af;
    --primary-blue: #3b82f6;
    --temp-color: #f97316;
    --panel-bg: rgba(248, 250, 252, 0.95); /* Slightly off-white panels to contrast with pure white background */
    --border-color: #e5e7eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Prevent text/image selection highlight */
    -webkit-user-select: none;
    user-select: none;
}

button, a, .interactive {
    -webkit-tap-highlight-color: transparent;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    outline: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1f2937; /* Dark background so the app stands out */
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 428px;
    height: 90vh;
    max-height: 926px;
    background-color: #ffffff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 40px; /* Phone bezel look */
    border: 8px solid #000; /* Phone border */
}

/* Background lines */
.road-lines-container {
    position: absolute;
    top: 10%;
    left: 0;
    width: 100%;
    height: 80%;
    z-index: 1;
    pointer-events: none;
}

.line-mask {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, var(--bg-color) 0%, transparent 20%, transparent 80%, var(--bg-color) 100%);
    z-index: 2;
}

.road-line {
    position: absolute;
    top: 0;
    height: 100%;
    width: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    z-index: 1;
}

.road-line.left {
    left: 18%;
    transform: perspective(600px) rotateY(20deg) rotateZ(6deg);
}

.road-line.right {
    right: 18%;
    transform: perspective(600px) rotateY(-20deg) rotateZ(-6deg);
}

.dash {
    width: 100%;
    height: 15%;
    background: linear-gradient(to right, #cbd5e1, #94a3b8);
    opacity: 0.5;
    box-shadow: 1px 0 3px rgba(0,0,0,0.1);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    z-index: 10;
    position: relative;
}

.icon-btn {
    font-size: 24px;
    color: var(--text-dark);
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
}

.icon-btn:hover, .icon-btn:active {
    background-color: rgba(0,0,0,0.05);
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    gap: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%; /* Fix for Safari flex absolute children */
}

/* Sidebars */
.sidebar {
    position: absolute;
    top: 50px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    z-index: 10;
}

.left-sidebar {
    left: 24px;
}

.right-sidebar {
    right: 24px;
}

.side-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.side-item i, .p-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: transparent;
    transition: transform 0.2s, background-color 0.2s;
}

.side-item.active i, .side-item.active .p-icon {
    background-color: rgba(59, 130, 246, 0.1);
}

.side-item:active i, .side-item:active .p-icon {
    transform: scale(0.9);
}

.p-icon {
    font-size: 26px;
    font-weight: bold;
}

.label {
    font-size: 12px;
    color: var(--text-light);
}

.side-item.active .label {
    color: var(--primary-blue);
    font-weight: 500;
}

.icon-blue {
    color: var(--primary-blue);
}

.icon-gray {
    color: var(--text-light);
}

.side-item.active .p-icon {
    color: var(--primary-blue);
}
.side-item:not(.active) .p-icon {
    color: var(--text-light);
}

/* Car Display */
.car-display {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -60%);
    width: 70%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

.car-image {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.temperature {
    position: absolute;
    top: 18%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    font-weight: 700;
    color: var(--temp-color);
    text-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
    pointer-events: none;
    transition: color 0.2s;
}

/* Controls Wrapper */
.controls-wrapper {
    position: absolute;
    bottom: 80px; /* space for bottom nav */
    left: 20px;
    right: 20px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Primary Controls */
.primary-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    border-radius: 20px;
    padding: 12px 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    position: relative;
    height: 70px;
}

.control-btn {
    border: none;
    background: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    padding: 10px;
    transition: opacity 0.2s;
}

.control-btn i {
    font-size: 20px;
}

.control-btn:active {
    opacity: 0.6;
}

#unlock-btn {
    flex: 1;
    justify-content: flex-start;
}

#lock-btn {
    flex: 1;
    justify-content: flex-end;
}

/* Big Start Button */
.start-btn-wrapper {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f0f0f0, #d0d0d0);
    box-shadow: 
        0 8px 15px rgba(0,0,0,0.2),
        inset 0 2px 4px rgba(255,255,255,0.8),
        inset 0 -2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px;
    cursor: pointer;
    z-index: 30;
    transition: transform 0.1s;
}

.start-btn-wrapper:active {
    transform: translate(-50%, -50%) scale(0.95);
    box-shadow: 
        0 4px 10px rgba(0,0,0,0.2),
        inset 0 4px 8px rgba(0,0,0,0.2);
}

.start-btn-outer {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #e6e6e6, #f5f5f5);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
}

.start-btn-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at center, #ffffff 0%, #e0e0e0 100%);
    border: 1px solid rgba(255,255,255,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.8);
}

.start-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: 2px;
}

/* Secondary Controls */
.secondary-controls {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--panel-bg);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    position: relative;
    z-index: 40; /* Prevents the big start button's bounding box from overlapping the trunk button */
}

.sub-btn {
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-dark);
}

.sub-icon {
    font-size: 24px;
    color: #1e3a8a;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.sub-btn:active .sub-icon {
    background-color: rgba(30, 58, 138, 0.1);
}

.sub-btn span {
    font-size: 13px;
    font-weight: 500;
}

/* Bottom Nav */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-light);
    transition: color 0.3s;
}

.nav-item i {
    font-size: 24px;
}

.nav-item span {
    font-size: 12px;
}

.nav-item.active {
    color: var(--primary-blue);
}

.nav-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
}

/* Toast Notification */
.toast {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
}

/* Animations */
@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}
.spin-anim {
    animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* ========== Temperature Control Bar ========== */
.temp-control {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 8px 24px;
    z-index: 10;
    position: relative;
}

.temp-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: var(--panel-bg);
    color: var(--primary-blue);
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.temp-btn:active {
    transform: scale(0.9);
    background: rgba(59, 130, 246, 0.1);
}

.temp-display {
    display: flex;
    align-items: baseline;
    gap: 2px;
    min-width: 80px;
    justify-content: center;
}

.temp-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--temp-color);
    transition: all 0.2s;
}

.temp-unit {
    font-size: 18px;
    font-weight: 500;
    color: var(--temp-color);
    opacity: 0.7;
}

/* ========== Page System ========== */
.page {
    display: none;
    flex-direction: column;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.page.active {
    display: flex;
}

.page-home {
    flex: 1;
}

.page-inner {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    padding-bottom: 80px;
    -webkit-overflow-scrolling: touch;
}

/* ========== 虚拟账户 - 空状态 ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    gap: 16px;
    opacity: 0.5;
}

.empty-icon {
    font-size: 64px;
    color: var(--text-light);
}

.empty-text {
    font-size: 16px;
    color: var(--text-light);
}

/* ========== 我的 - 个人信息页 ========== */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0 28px;
    gap: 8px;
}

.avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.avatar i {
    font-size: 36px;
    color: #ffffff;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.profile-desc {
    font-size: 14px;
    color: var(--text-light);
}

/* 表单 */
.car-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    padding-left: 4px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-dark);
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.form-input::placeholder {
    color: #c0c6cf;
}

.form-input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-textarea {
    resize: none;
    line-height: 1.5;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

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

.submit-btn i {
    font-size: 20px;
}

/* 提交成功动画 */
@keyframes successPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.submit-success {
    animation: successPop 0.4s ease forwards;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

/* ========== 未激活提示 ========== */
.activation-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    margin: 0 auto;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 20px;
    color: #ef4444;
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    position: relative;
    width: fit-content;
}

.activation-badge i {
    font-size: 16px;
}

/* 车顶未激活标签 */
.car-inactive-badge {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.85);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 10px;
    letter-spacing: 1px;
    pointer-events: none;
    z-index: 6;
}

/* ========== 移动端适配 (iOS & Android) ========== */

/* 手机上全屏显示，去掉模拟手机框 */
@media screen and (max-width: 500px) {
    body {
        background-color: #ffffff;
        align-items: stretch;
    }

    .app-container {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    /* iOS 安全区域适配 */
    .header {
        padding-top: calc(20px + env(safe-area-inset-top));
        padding-left: calc(24px + env(safe-area-inset-left));
        padding-right: calc(24px + env(safe-area-inset-right));
    }

    .temp-control {
        padding-top: env(safe-area-inset-top);
    }

    .bottom-nav {
        height: calc(60px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
    }

    .controls-bar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* 触摸优化 */
.control-btn,
.start-btn-wrapper,
.nav-item,
.sub-btn,
.icon-btn,
.temp-btn {
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

/* iOS 滚动优化 */
.page-inner {
    -webkit-overflow-scrolling: touch;
}

/* 防止 iOS 长按弹出菜单 */
img {
    -webkit-touch-callout: none;
}

/* 防止 iOS 输入框自动缩放 */
input, select, textarea {
    font-size: 16px;
}

/* 修复 iOS Safari 100vh 问题 */
@supports (-webkit-touch-callout: none) {
    .app-container {
        height: -webkit-fill-available;
    }
}
