/* ========== 全局主题变量 ========== */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #121826;
    --bg-card: #1a2234;
    --text-primary: #e8edf5;
    --text-secondary: #8b95a7;
    --text-muted: #5a6478;
    --border-color: #242d3f;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.15);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* 主题：深邃黑 */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #141414;
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #525252;
    --border-color: #262626;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.15);
}

/* 主题：高级灰 */
[data-theme="gray"] {
    --bg-primary: #18181b;
    --bg-secondary: #212126;
    --bg-card: #2a2a31;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border-color: #3f3f46;
    --accent: #64748b;
    --accent-hover: #475569;
    --accent-light: rgba(100, 116, 139, 0.15);
}

/* 主题：简约白 */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.1);
}

/* 主题：樱花粉 */
[data-theme="pink"] {
    --bg-primary: #1a0f17;
    --bg-secondary: #241620;
    --bg-card: #2e1d29;
    --text-primary: #fce7f3;
    --text-secondary: #f9a8d4;
    --text-muted: #be185d;
    --border-color: #4a243b;
    --accent: #ec4899;
    --accent-hover: #db2777;
    --accent-light: rgba(236, 72, 153, 0.15);
}

/* 主题：暗夜紫 */
[data-theme="purple"] {
    --bg-primary: #0f0a1a;
    --bg-secondary: #181028;
    --bg-card: #221838;
    --text-primary: #ede9fe;
    --text-secondary: #a78bfa;
    --text-muted: #7c3aed;
    --border-color: #3b2a5c;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-light: rgba(139, 92, 246, 0.15);
}

/* 主题：极光绿 */
[data-theme="green"] {
    --bg-primary: #0a1714;
    --bg-secondary: #0f211c;
    --bg-card: #172e27;
    --text-primary: #d1fae5;
    --text-secondary: #6ee7b7;
    --text-muted: #059669;
    --border-color: #1f4237;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: rgba(16, 185, 129, 0.15);
}

/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-primary);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ========== 顶部导航栏 ========== */
.navbar {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.navbar .back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 15px;
    cursor: pointer;
    padding: 6px 0;
    position: absolute;
    left: 16px;
}

.navbar .title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

/* ========== 按钮 ========== */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:active {
    background: var(--accent-hover);
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    width: 100%;
    padding: 13px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:active {
    background: var(--accent-light);
}

/* ========== 输入框 ========== */
.input-field {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

.input-field:focus {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ========== 登录注册页 ========== */
.auth-container {
    flex: 1;
    padding: 60px 24px 30px;
    display: flex;
    flex-direction: column;
}

.auth-logo {
    text-align: center;
    margin-bottom: 50px;
}

.auth-logo h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 2px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.code-row {
    display: flex;
    gap: 10px;
}

.code-row .input-field {
    flex: 1;
}

.code-btn {
    padding: 0 16px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.code-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error-tip {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    min-height: 18px;
}

.auth-footer {
    margin-top: auto;
    text-align: center;
    padding-top: 30px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
}

/* ========== 首页 ========== */
.home-container {
    flex: 1;
    padding: 30px 20px;
}

.user-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}

.user-info .name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.user-info .uid {
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: 1px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px 12px;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s;
}

.app-item:active {
    transform: scale(0.92);
}

.app-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 10px;
    box-shadow: 0 8px 20px var(--accent-light);
}

.app-name {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== 拨号页 ========== */
.dial-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.dial-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 300;
    letter-spacing: 6px;
    color: var(--text-primary);
    min-height: 120px;
}

.dial-keypad {
    padding: 0 20px 30px;
}

.keypad-row {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

.keypad-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 26px;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.keypad-btn small {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 1px;
}

.keypad-btn:active {
    background: var(--accent-light);
    border-color: var(--accent);
    transform: scale(0.95);
}

.call-btn-wrap {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.call-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--success);
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-btn:active {
    transform: scale(0.95);
}

/* ========== 列表通用 ========== */
.list-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.list-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.list-item:active {
    background: var(--bg-card);
}

.list-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-size: 15px;
    margin-bottom: 3px;
    color: var(--text-primary);
}

.list-desc {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tabs-bar {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tab-item {
    flex: 1;
    text-align: center;
    padding: 14px 0;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

/* ========== 聊天页 ========== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.sent {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-input-bar {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.chat-input-bar input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== 资料页 ========== */
.profile-container {
    flex: 1;
    padding: 40px 24px;
    text-align: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    color: #fff;
    box-shadow: 0 12px 30px var(--accent-light);
}

.profile-name {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 6px;
}

.profile-id {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 2px;
    margin-bottom: 40px;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 260px;
    margin: 0 auto;
}

/* ========== 设置页 ========== */
.settings-group {
    margin: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.settings-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    cursor: pointer;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item .value {
    color: var(--text-secondary);
    font-size: 14px;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px;
}

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

.theme-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.theme-item.active .theme-dot {
    border-color: var(--accent);
    transform: scale(1.1);
}

.theme-name {
    font-size: 11px;
    color: var(--text-secondary);
}

.logout-btn {
    margin: 30px 16px;
    padding: 15px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
}

.logout-btn:active {
    background: rgba(239, 68, 68, 0.2);
}

/* ========== 工具类 ========== */
.hidden { display: none !important; }
.empty-tip {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 60px 20px;
}
.id-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 10px 0;
}
.id-card {
    padding: 14px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 16px;
    letter-spacing: 2px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.id-card.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--text-primary);
}

/* ========== 小屏适配 ========== */
@media (max-width: 380px) {
    .keypad-btn {
        width: 62px;
        height: 62px;
        font-size: 22px;
    }
    .call-btn {
        width: 68px;
        height: 68px;
        font-size: 28px;
    }
    .keypad-row {
        margin-bottom: 16px;
    }
    .dial-display {
        font-size: 34px;
    }
    .app-icon {
        width: 54px;
        height: 54px;
        font-size: 22px;
    }
}