/* css/global.css */

/* --- CSS 变量定义 --- */
:root {
    --frame-bg: #f7f9fc;
    --screen-bg: #fff;
    --page-bg: #f0f2f5;
    --header-bg: rgba(255, 255, 255, 0.7);
    --primary-text: #333;
    --secondary-text: #888;
    --highlight-color: #5b9dff;
    --soft-border: #e0e4e8;
    --nav-icon: #888;
    --user-bubble-bg: #87CEEB;
    --user-bubble-text: #fff;
    --ai-bubble-bg: #fff;
    --ai-bubble-text: #333;
}

/* --- 主题定义 --- */
body[data-theme="pink"] {
    --frame-bg: #fff0f5;
    --screen-bg: #fff;
    --page-bg: #fde8f0;
    --header-bg: rgba(255, 240, 245, 0.7);
    --primary-text: #5c2b29;
    --secondary-text: #ab6976;
    --highlight-color: #f472b6;
    --soft-border: #fbcfe8;
    --nav-icon: #c4717c;
    --user-bubble-bg: #f472b6;
    --user-bubble-text: #fff;
    --ai-bubble-bg: #fff;
    --ai-bubble-text: #5c2b29;
}

body[data-theme="green"] {
    --frame-bg: #dcfce7;
    --screen-bg: #fff;
    --page-bg: #f0fdf4;
    --header-bg: rgba(240, 255, 244, 0.7);
    --primary-text: #14532d;
    --secondary-text: #16a34a;
    --highlight-color: #4ade80;
    --soft-border: #d1fae5;
    --nav-icon: #16a34a;
    --user-bubble-bg: #4ade80;
    --user-bubble-text: #14532d;
    --ai-bubble-bg: #fff;
    --ai-bubble-text: #14532d;
}

body[data-theme="purple"] {
    --frame-bg: #f5f3ff;
    --screen-bg: #fff;
    --page-bg: #ede9fe;
    --header-bg: rgba(245, 243, 255, 0.7);
    --primary-text: #3730a3;
    --secondary-text: #6d6af0;
    --highlight-color: #818cf8;
    --soft-border: #ddd6fe;
    --nav-icon: #6d6af0;
    --user-bubble-bg: #818cf8;
    --user-bubble-text: #fff;
    --ai-bubble-bg: #fff;
    --ai-bubble-text: #3730a3;
}

body[data-theme="gray"] {
    --frame-bg: #111827;
    --screen-bg: #1f2937;
    --page-bg: #374151;
    --header-bg: rgba(31, 41, 55, 0.7);
    --primary-text: #f9fafb;
    --secondary-text: #9ca3af;
    --highlight-color: #7dd3fc;
    --soft-border: #4b5563;
    --nav-icon: #9ca3af;
    --user-bubble-bg: #38bdf8;
    --user-bubble-text: #000;
    --ai-bubble-bg: #4b5563;
    --ai-bubble-text: #f9fafb;
}

body[data-theme="sepia"] {
    --frame-bg: #fdf6e3;
    --screen-bg: #fffaf0;
    --page-bg: #fdf6e3;
    --header-bg: rgba(253, 246, 227, 0.7);
    --primary-text: #5d4037;
    --secondary-text: #8d6e63;
    --highlight-color: #d2b48c;
    --soft-border: #eee8d5;
    --nav-icon: #8d6e63;
    --user-bubble-bg: #d2b48c;
    --user-bubble-text: #fff;
    --ai-bubble-bg: #fff;
    --ai-bubble-text: #5d4037;
}

/* --- 基础设置 --- */
body {
    margin: 0; padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
    background-color: #f0f2f5;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
    color: var(--primary-text);
}

/* --- 手机外框 --- */
.mobile-frame {
    width: 390px; height: 590px;
    background-color: var(--frame-bg);
    border-radius: 40px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 0 0 5px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

/* --- 手机屏幕 --- */
.mobile-screen {
    width: 100%; height: 100%;
    background-color: var(--screen-bg);
    border-radius: 28px;
    overflow: hidden;
    display: flex; flex-direction: column;
    position: relative;
    transition: background-color 0.3s ease;
}

/* --- 顶部状态栏 --- */
.status-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px;
    height: 44px;
    background-color: var(--header-bg);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    z-index: 10;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.status-bar .time { flex: 1; text-align: left; font-size: 13px; }
.status-bar .indicators { flex: 1; text-align: right; display: flex; gap: 12px; justify-content: flex-end; align-items: center; }

/* --- 刘海与同步按钮 --- */
.notch {
    position: absolute; top: 0; left: 50%;
    transform: translateX(-50%);
    width: 120px; height: 30px;
    background: var(--frame-bg);
    border-radius: 0 0 15px 15px;
    display: flex; justify-content: center; align-items: center;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sync-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 4px;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, color 0.2s, background-color 0.2s;
}
.sync-button:hover { background-color: rgba(0,0,0,0.1); }
.sync-button:active { transform: scale(0.9); color: var(--highlight-color); }


/* --- 主内容容器 --- */
#app-container { flex-grow: 1; overflow-y: auto; position: relative; }

/* --- 底部导航栏 --- */
.bottom-nav {
    display: flex; height: 50px;
    background-color: var(--ai-bubble-bg);
    border-top: 1px solid var(--soft-border);
    flex-shrink: 0;
    z-index: 10;
    transition: background-color 0.3s ease, border-top-color 0.3s ease;
}
.nav-button {
    flex: 1; background: none; border: none;
    font-size: 22px; color: var(--nav-icon);
    cursor: pointer; transition: color 0.2s;
    display: flex; justify-content: center; align-items: center;
}
.nav-button:hover { color: var(--primary-text); }
.nav-button.active { color: var(--highlight-color); }

/* --- 全局滚动条美化 --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.3); }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.4); }

/* === MODAL STYLES === */
.modal-overlay {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 100;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }

.modal-content {
    background: var(--screen-bg);
    color: var(--primary-text);
    padding: 20px; border-radius: 16px;
    width: 90%; max-width: 320px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}
.modal-overlay.visible .modal-content { transform: scale(1); }
.modal-header { font-size: 18px; font-weight: 600; margin-bottom: 20px; text-align: center; }

/* -- 弹窗选项的通用布局 (已美化) -- */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 8px; /* 增加选项之间的间距 */
}

.options-container .option {
    display: flex;
    align-items: center;
    justify-content: center; /* 文字居中 */
    padding: 12px;
    border: none; /* 移除分割线 */
    border-radius: 12px; /* 添加圆角 */
    cursor: pointer;
    background-color: rgba(0,0,0,0.03); /* 默认一个非常淡的背景 */
    transition: background-color 0.2s ease, color 0.2s ease;
}

.options-container .option:hover {
    background-color: rgba(0,0,0,0.07); /* 悬停时背景加深 */
}

.options-container .option.selected { 
    background-color: var(--highlight-color);
    color: var(--ai-bubble-bg); /* 选中时文字颜色反转，更清晰 */
    font-weight: 600;
}
/* === 主功能菜单样式 === */
#function-menu-modal .modal-overlay {
    /* 这会让菜单的黑色遮罩适应手机屏幕，而不是整个网页 */
    position: absolute; 
}

#function-menu-modal {
    align-items: flex-end; /* 菜单从底部弹出 */
}

.function-menu-content {
    background-color: var(--page-bg);
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.3s ease, background-color 0.3s ease;
}

#function-menu-modal.visible .function-menu-content {
    transform: translateY(0);
}

.function-grid {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    justify-content: center; 
    gap: 25px 20px;
    margin-bottom: 20px;
}

.function-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--primary-text);
    font-size: 12px;
    cursor: pointer;
}

.function-button i {
    font-size: 28px;
    width: 60px;
    height: 60px;
    background-color: var(--screen-bg);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}

.cancel-button {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background-color: var(--screen-bg);
    color: var(--primary-text);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

/* === 特殊消息输入弹窗样式 === */
.special-message-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--soft-border);
    border-radius: 8px;
    background-color: var(--page-bg);
    color: var(--primary-text);
    font-size: 15px;
    box-sizing: border-box;
    resize: vertical;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.modal-input:focus {
    outline: none;
    border-color: var(--highlight-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-button {
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}
.modal-button.cancel {
    background-color: var(--soft-border);
    color: var(--secondary-text);
}
.modal-button.send {
    background-color: var(--highlight-color);
    color: #fff;
}