/* ==================== 基础变量 & 重置 ==================== */
:root {
    --bg: #f5f7fa;
    --bg-white: #ffffff;
    --bg-hover: #f0f2f5;
    --border: #e8ecf1;
    --border-focus: #6c5ce7;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-hint: #9ca3af;
    --accent: #6c5ce7;
    --accent-light: #ede9ff;
    --accent-2: #00b894;
    --accent-2-light: #e6faf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== 通用卡片 ==================== */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    margin-bottom: 16px;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ==================== 按钮 ==================== */
.btn-primary {
    display: block;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover:not(:disabled) {
    background: #5a4bd4;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
    display: inline-block;
}

.btn-accent {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-accent:hover {
    background: #5a4bd4;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* 退出登录按钮 — 独立、清晰 */
.logout-card {
    border: 1px solid var(--border);
}

.btn-logout-full {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-logout-full:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.logout-icon {
    font-size: 1.2rem;
}

/* ==================== 输入框 ==================== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: all var(--transition);
    outline: none;
}

.input-group input::placeholder {
    color: var(--text-hint);
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
    background: white;
}

.select-wrapper {
    margin-bottom: 16px;
}

.select-wrapper select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    appearance: none;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    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;
}

.select-wrapper select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

.hint {
    font-size: 0.8rem;
    color: var(--text-hint);
    text-align: center;
    margin-top: 12px;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.version {
    color: var(--text-hint);
    font-size: 0.8rem;
    margin-top: 8px;
    margin-bottom: 0;
}

.demo-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--warning);
    background: #fef9ee;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid #fde68a;
}

.demo-note {
    color: var(--text-hint);
    font-size: 0.8rem;
}

/* ==================== 页面切换 ==================== */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: flex;
}

/* ==================== 登录页 ==================== */
#page-login {
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #ede9ff 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    animation: fadeInUp 0.6s ease-out;
}

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

.logo-icon {
    font-size: 4rem;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo-area h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 6px;
}

.login-card {
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

/* 登录/注册 Tab 样式 */
.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.auth-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: calc(var(--radius-sm) - 4px);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.auth-tab-btn.active {
    background: var(--bg-white);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.auth-tab-btn:hover:not(.active) {
    color: var(--text-primary);
}


@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 主界面布局 ==================== */
#page-main {
    flex-direction: column;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-light);
}

#header-nickname {
    font-weight: 600;
    font-size: 0.95rem;
}

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

.city-badge {
    font-size: 0.85rem;
    color: var(--accent-2);
    background: var(--accent-2-light);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(0, 184, 148, 0.2);
    font-weight: 500;
}

/* ==================== 底部导航 ==================== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-hint);
    cursor: pointer;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    position: relative;
    font-family: var(--font);
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active .tab-icon {
    transform: scale(1.1);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg);
}

.tab-icon {
    font-size: 1.3rem;
    transition: transform var(--transition);
}

.tab-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge {
    position: absolute;
    top: 2px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    padding: 0 4px;
    font-weight: 700;
}

/* ==================== Tab 内容 ==================== */
.tab-content {
    display: none;
    padding: 76px 16px 88px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    margin-top: 8px;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

/* ==================== 3D 地球页 ==================== */
#tab-globe {
    padding: 60px 0 72px;
    max-width: none;
}

.globe-wrapper {
    position: relative;
    width: 100%;
    height: calc(100vh - 132px);
    background: linear-gradient(180deg, #0d1b2a 0%, #1b2838 50%, #0d1b2a 100%);
    overflow: hidden;
}

#globe-container {
    width: 100%;
    height: 100%;
}

.globe-overlay {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.globe-stats {
    display: flex;
    align-items: baseline;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 20px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
}

.globe-stats span:first-child {
    font-size: 1.5rem;
    font-weight: 700;
    color: #00b894;
}

.globe-stats-label {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ==================== 匹配列表 ==================== */
.match-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
    animation: slideIn 0.3s ease-out both;
}

.match-item:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
    transform: translateX(3px);
}

.match-avatar {
    font-size: 1.8rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-light);
    flex-shrink: 0;
}

.match-info {
    flex: 1;
    min-width: 0;
}

.match-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.match-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.match-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--accent-2-light);
    color: var(--accent-2);
    border: 1px solid rgba(0, 184, 148, 0.2);
    white-space: nowrap;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== 分组 ==================== */
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group-item {
    padding: 18px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
    animation: fadeInUp 0.3s ease-out both;
}

.group-item:hover {
    box-shadow: var(--shadow-sm);
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.group-name {
    font-weight: 600;
    font-size: 1rem;
}

.group-code {
    font-size: 0.75rem;
    color: var(--accent);
    background: var(--accent-light);
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
}

.group-code:hover {
    background: var(--accent);
    color: white;
}

.group-members {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.group-actions {
    display: flex;
    gap: 8px;
}

.join-card {
    margin-bottom: 12px;
}

/* ==================== 通知 ==================== */
.notification-item {
    padding: 16px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    transition: all var(--transition);
    animation: fadeInUp 0.3s ease-out both;
}

.notification-item.unread {
    border-left: 3px solid var(--accent);
    background: #faf9ff;
}

.notification-item:hover {
    box-shadow: var(--shadow-sm);
}

.notif-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.notif-icon {
    font-size: 1.3rem;
}

.notif-title {
    font-weight: 600;
    font-size: 0.95rem;
    flex: 1;
}

.notif-time {
    font-size: 0.75rem;
    color: var(--text-hint);
}

.notif-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-left: 30px;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-hint);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ==================== 设置 ==================== */
#tab-settings h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.danger-zone {
    border-color: #fecaca;
    background: var(--danger-light);
}

.sim-user-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.8rem;
    margin: 4px;
    animation: fadeIn 0.3s ease-out;
}

.sim-user-tag .remove-sim {
    cursor: pointer;
    opacity: 0.4;
    transition: opacity var(--transition);
}

.sim-user-tag .remove-sim:hover {
    opacity: 1;
}

/* ==================== Toast 通知 ==================== */
#toast-container {
    position: fixed;
    top: 76px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 380px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: white;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s ease-out;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.toast.toast-out {
    animation: toastOut 0.3s ease-in forwards;
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

.toast.match {
    border-left: 3px solid var(--accent-2);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }
}

/* ==================== 响应式 ==================== */
@media (max-width: 480px) {
    .logo-area h1 {
        font-size: 1.6rem;
    }

    .card {
        padding: 18px;
    }

    .tab-content {
        padding: 68px 12px 80px;
    }

    .top-bar {
        padding: 0 12px;
    }

    .city-badge {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    #toast-container {
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: unset;
    }

    #tab-globe {
        padding: 60px 0 72px;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

::selection {
    background: rgba(108, 92, 231, 0.15);
    color: var(--text-primary);
}