/* =========================================
   Components.css - 通用组件样式
   沉浸式手机聊天App风格
   ========================================= */

/* =========================================
   页面通用样式
   ========================================= */

.messages-page,
.contacts-page,
.discover-page,
.profile-page {
    min-height: 100%;
    background: var(--bg-color);
    padding-bottom: calc(var(--nav-height) + var(--space-10));
}

/* 页面头部 */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6) var(--space-5);
    padding-top: calc(var(--space-6) + env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* 简化头部 - 搜索框+按钮 */
.page-header-simple {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4);
    padding-top: calc(var(--space-4) + env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* 内联搜索栏 */
.search-bar-inline {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--white);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(167, 139, 250, 0.1);
    transition: all var(--transition-fast);
}

.search-bar-inline:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.search-bar-inline i {
    font-size: 18px;
    color: var(--primary-color);
    opacity: 0.6;
}

.search-bar-inline .search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-base);
    color: var(--text-main);
}

.search-bar-inline .search-input::placeholder {
    color: var(--text-placeholder);
}

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.header-btn {
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    color: var(--text-main);
    position: relative;
}

.header-btn:active {
    transform: scale(0.95);
    background: var(--bg-color);
}

.header-btn i {
    font-size: 20px;
}

/* =========================================
   下拉菜单
   ========================================= */

.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 160px;
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-2);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-main);
    font-size: var(--font-size-sm);
}

.dropdown-item:active {
    background: var(--bg-color);
}

.dropdown-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-ultra-light);
    border-radius: var(--radius-sm);
    color: var(--primary-color);
}

.dropdown-icon i {
    font-size: 16px;
}

/* 下拉动画 */
.dropdown-enter-active,
.dropdown-leave-active {
    transition: all var(--transition-fast);
}

.dropdown-enter-from,
.dropdown-leave-to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 40;
}

/* =========================================
   空状态
   ========================================= */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-6);
    text-align: center;
}

.empty-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-ultra-light);
    border-radius: 50%;
    margin-bottom: var(--space-5);
}

.empty-icon i {
    font-size: 36px;
    color: var(--primary-color);
}

.empty-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 var(--space-2);
}

.empty-desc {
    font-size: var(--font-size-sm);
    color: var(--text-sub);
    margin: 0;
}

/* =========================================
   发起聊天弹窗
   ========================================= */

.start-chat-modal {
    max-width: 520px;
}

.start-chat-search {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(167, 139, 250, 0.15);
    box-shadow: var(--shadow-xs);
    margin-bottom: var(--space-4);
}

.start-chat-search i {
    font-size: 18px;
    color: var(--primary-color);
    opacity: 0.7;
}

.start-chat-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-base);
    color: var(--text-main);
}

.start-chat-search input::placeholder {
    color: var(--text-placeholder);
}

.start-chat-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 50vh;
    overflow-y: auto;
}

.start-chat-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(167, 139, 250, 0.1);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
}

.start-chat-item:active {
    transform: scale(0.98);
    background: var(--primary-ultra-light);
}

.start-chat-item img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}

.start-chat-info {
    flex: 1;
    min-width: 0;
}

.start-chat-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: var(--font-size-base);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.start-chat-desc {
    font-size: var(--font-size-xs);
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.start-chat-empty {
    text-align: center;
    color: var(--text-sub);
    padding: var(--space-4) 0;
    font-size: var(--font-size-sm);
}

/* =========================================
   聊天列表
   ========================================= */

.chat-list {
    padding: 0 var(--space-4);
}

.chat-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--white);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-2);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.chat-item:active {
    transform: scale(0.98);
    background: var(--bg-color);
}

/* 头像 */
.chat-avatar {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--online-color);
    border: 2px solid var(--white);
    border-radius: 50%;
}

/* 消息内容 */
.chat-content {
    flex: 1;
    min-width: 0;
}

.chat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-1);
}

.chat-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-main);
}

.chat-time {
    font-size: var(--font-size-xs);
    color: var(--text-time);
}

.chat-preview {
    font-size: var(--font-size-sm);
    color: var(--text-sub);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.preview-prefix {
    color: var(--primary-color);
}

/* =========================================
   右键菜单 / 上下文菜单
   ========================================= */

.context-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1000;
}

.context-menu {
    position: fixed;
    min-width: 140px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    box-shadow: var(--shadow-lg);
    animation: contextIn 0.2s ease-out;
}

@keyframes contextIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    color: var(--text-main);
}

.context-item:active {
    background: var(--bg-color);
}

.context-item i {
    font-size: 18px;
}

.context-item.danger {
    color: var(--danger);
}

/* =========================================
   联系人网格
   ========================================= */

.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-4);
    padding: 0 var(--space-4);
}

.contact-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4);
    background: var(--white);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.contact-card:active {
    transform: scale(0.95);
}

.contact-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-main);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* =========================================
   搜索栏
   ========================================= */

.search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 var(--space-4) var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--white);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.search-bar i {
    font-size: 18px;
    color: var(--icon-default);
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-base);
    color: var(--text-main);
}

.search-bar input::placeholder {
    color: var(--text-placeholder);
}

/* =========================================
   分组标题
   ========================================= */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
}

.section-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-action {
    font-size: var(--font-size-sm);
    color: var(--primary-color);
    cursor: pointer;
}

/* =========================================
   设置列表
   ========================================= */

.settings-list {
    padding: 0 var(--space-4);
}

.settings-group {
    background: var(--white);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-4);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.settings-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row:active {
    background: var(--bg-color);
}

.settings-row-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.settings-row-icon i {
    font-size: 18px;
}

.settings-row-content {
    flex: 1;
    min-width: 0;
}

.settings-row-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text-main);
}

.settings-row-desc {
    font-size: var(--font-size-xs);
    color: var(--text-sub);
    margin-top: 2px;
}

.settings-row-arrow {
    color: var(--icon-default);
    font-size: 18px;
}

/* =========================================
   开关控件
   ========================================= */

.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
    background: var(--bg-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.toggle-switch.active {
    background: var(--primary-color);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.toggle-switch.active::after {
    left: calc(100% - 26px);
}

/* =========================================
   头像组
   ========================================= */

.avatar-group {
    display: flex;
    align-items: center;
}

.avatar-group .avatar-item {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    margin-left: -8px;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-xs);
}

.avatar-group .avatar-item:first-child {
    margin-left: 0;
}

.avatar-group .avatar-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-group .avatar-more {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin-left: -8px;
    border: 2px solid var(--white);
}

/* =========================================
   标签 / 徽章
   ========================================= */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--danger);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge.primary {
    background: var(--primary-color);
}

.badge.success {
    background: var(--online-color);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    background: var(--primary-ultra-light);
    color: var(--primary-color);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

/* =========================================
   加载状态
   ========================================= */

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* =========================================
   按钮
   ========================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-main);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-ghost {
    background: transparent;
    color: var(--primary-color);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    min-height: 36px;
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--font-size-lg);
    min-height: 52px;
}

/* =========================================
   输入框
   ========================================= */

.input-field {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    color: var(--text-main);
    transition: all var(--transition-fast);
    outline: none;
}

.input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-ultra-light);
}

.input-field::placeholder {
    color: var(--text-placeholder);
}

.textarea-field {
    min-height: 100px;
    resize: vertical;
}

/* =========================================
   卡片
   ========================================= */

.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-main);
}

.card-body {
    color: var(--text-sub);
    font-size: var(--font-size-sm);
    line-height: 1.6;
}

/* =========================================
   动画
   ========================================= */

.fade-enter-active,
.fade-leave-active {
    transition: opacity var(--transition-base);
}

.fade-enter-from,
.fade-leave-to {
    opacity: 0;
}

.scale-enter-active,
.scale-leave-active {
    transition: all var(--transition-base);
}

.scale-enter-from,
.scale-leave-to {
    opacity: 0;
    transform: scale(0.9);
}

/* =========================================
   发现页样式 - 紫白配色
   ========================================= */

.discover-page {
    min-height: 100%;
    background: var(--bg-color);
    padding: var(--space-5) var(--space-4);
    padding-top: calc(var(--space-5) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-height) + var(--space-10));
}

.discover-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.discover-card {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    background: var(--white);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(167, 139, 250, 0.06);
}

.discover-card:active {
    transform: scale(0.98);
    background: var(--primary-ultra-light);
}

.discover-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    margin-right: var(--space-4);
    flex-shrink: 0;
    box-shadow: var(--shadow-purple);
}

.discover-icon i {
    font-size: 24px;
    color: white;
}

.discover-content {
    flex: 1;
}

.discover-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.discover-desc {
    font-size: var(--font-size-sm);
    color: var(--text-sub);
}

.discover-arrow {
    color: var(--primary-color);
    font-size: 20px;
    opacity: 0.5;
}

.discover-footer {
    text-align: center;
    padding: var(--space-8) 0;
    color: var(--text-sub);
}

.discover-footer-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-ultra-light);
    border-radius: 50%;
    margin: 0 auto var(--space-3);
}

.discover-footer-icon i {
    font-size: 28px;
    color: var(--primary-color);
    opacity: 0.5;
}

.discover-footer p {
    font-size: var(--font-size-sm);
    margin: 0;
}
