/* --- 全局与主题样式 --- */
:root {
    --bg-color: #e5eded;       /* 灰蓝：背景基础 */
    --primary-color: #cee4f1;  /* 黑：主色调 */
    --secondary-color: #b6b6b6;/* 灰：次要色 */
    --accent-color: #e5eded;   /* 蓝：强调色 */
    --text-color: #2a3032;     /* 黑：文本 */
    --white-color: #2a3032;
    --border-radius: 18px;
    --phone-corner-radius: 0px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --top-pinned-bg: #e2e2e4;  /* 浅灰：置顶背景 */
    --online-status-color: #4CAF50;
    --kkt-icon-color: #000000; /* KKT图标黑 */
    --chat-avatar-radius: 50%; /* 默认圆形 */
    --app-font-scale: 1;       /* 全局字体缩放比例 */

    /* --- 新增美化变量 --- */
    --nav-icon-color: #999999;
    --nav-active-icon-color: #2a3032;
    --chat-bottom-bar-bg: #ffffff;
    --func-icon-color: #000000;
    --folder-pill-bg: #ffffff;
    --folder-pill-text: #333333;
    --folder-pill-active-bg: #1e1e1e;
    --folder-pill-active-text: #ffffff;
    --global-title-color: #000000;
}

html {
    height: 100%;
    overflow: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    background: #ffffff;
    width: 100%;
    min-height: 100vh;
    display: flex;
    overflow: hidden;
    overscroll-behavior: none;
}

/* --- 通用组件 --- */

/* 模态框通用样式 */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.visible {
    display: flex;
}

.modal-window {
    background: #ffffff;
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    width: 85%;
    max-width: 340px;
    animation: slideUp 0.4s ease-out;
}

.modal-window h3 {
    margin-top: 0;
    text-align: center;
    color: var(--primary-color);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 表单组件 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--secondary-color);
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e2e4; /* 改为浅灰 */
    border-radius: 10px;
    background-color: #fff;
    transition: border-color 0.3s;
    font-family: var(--font-family);
    font-size: calc(14px * var(--app-font-scale));
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group.radio-group {
    display: flex;
    gap: 20px;
    align-items: center;
}

.form-group.radio-group label {
    margin-bottom: 0;
}

/* 按钮组件 */
.btn {
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    border: none;
    font-size: calc(16px * var(--app-font-scale));
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white-color);
}

.btn-primary:hover {
    background-color: #454d50; /* 悬停变浅黑 */
    box-shadow: 0 4px 15px rgba(206, 228, 241, 0.6); /* 改为蓝色光晕 */
}

label.btn-primary {
    color: var(--white-color) !important;
}

.btn-small {
    padding: 8px 16px;
    font-size: calc(14px * var(--app-font-scale));
    width: auto;
}

.btn-secondary {
    background-color: var(--accent-color);
    color: var(--white-color);
    margin-bottom: 15px;
}

.btn-secondary:hover {
    background-color: #64b5f6;
    box-shadow: 0 4px 15px rgba(144, 202, 249, 0.5);
}

.btn-neutral {
    background-color: #bdbdbd;
    color: var(--white-color);
}

.btn-neutral:hover {
    background-color: #9e9e9e;
}

.btn-danger {
    background-color: #ef5350;
    color: white;
}

.btn .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: var(--white-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn.loading .spinner {
    display: block;
}

.btn.loading .btn-text {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast 提示 */
.toast {
    position: absolute;
    top: -120px; /* Start off-screen */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 380px;
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #333;
    padding: 12px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: top 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.05);
}

.toast.show {
    top: 20px;
    opacity: 1;
    visibility: visible;
}

.toast.simple {
    top: auto;
    bottom: 90px;
    background-color: rgba(255, 255, 255, 0.7);
    color: white;
    max-width: 250px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: opacity 0.4s ease-out;
}

.toast.simple.show {
    top: auto;
}

.toast.simple .toast-avatar {
    display: none;
}
.toast.simple .toast-content {
    text-align: center;
    width: 100%;
}

.toast-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #eee;
}

.toast-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 2px;
}

.toast-name {
    font-weight: 600;
    font-size: 15px;
    color: #000;
}

.toast-message {
    font-size: 14px;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 折叠面板 (Collapsible) - 通用 */
.collapsible-section {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
}

.collapsible-header {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.collapsible-header h4 {
    margin: 0;
    font-size: 16px;
    color: var(--primary-color);
    flex-grow: 1;
}

.collapsible-arrow {
    font-size: 14px;
    color: #999;
    transition: transform 0.3s ease-in-out;
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
    padding: 0 20px;
}

.collapsible-section.open .collapsible-content {
    max-height: 5000px;
    padding: 0 20px 20px !important;
}

.collapsible-section.open .collapsible-arrow {
    transform: rotate(180deg);
}

/* 错误模态框修正 */
#error-modal-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

#error-modal-overlay .modal-window {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

/* 更新日志模态框 */
#update-log-modal .modal-window {
    max-width: 380px;
    text-align: left;
}

#update-log-modal-content {
    max-height: 60vh;
    overflow-y: auto;
    padding: 15px 15px;
    margin: 15px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    background-color: #fcfcfc;
    border-radius: 8px;
}

#update-log-modal-content h4 {
    font-size: 16px;
    color: var(--primary-color);
    margin-top: 10px;
    margin-bottom: 8px;
}

#update-log-modal-content ul {
    list-style-type: none;
    padding-left: 5px;
    margin: 0;
}

#update-log-modal-content li {
    margin-bottom: 8px;
    line-height: 1.6;
    font-size: 14px;
    color: #555;
    position: relative;
    padding-left: 20px;
}

#update-log-modal-content li::before {
    content: '✨';
    position: absolute;
    left: 0;
    top: 2px;
    color: var(--accent-color);
}
