/* ============================================================
 * Ayuland Global CSS (assets/css/global.css)
 *
 * 包含：所有页面共用的设计令牌 + 通用组件样式
 * 原则：
 *   1. 只放真正"共用"的东西（每个页面都会用到的）
 *   2. 不覆盖页面的样式（页面特有 CSS 优先）
 *   3. 变量名/值对齐 iOS HIG + Apple Design
 *
 * 适用：所有 PHP 页面通过 <link rel="stylesheet" href="assets/css/global.css"> 加载
 * ============================================================ */

/* ============================================================
 * 设计令牌 (Design Tokens)
 * ============================================================ */
:root {
    /* 颜色 — 统一对齐原网站主色（强行统一） */
    --bg:           #f2f2f7;   /* 页面背景 (iOS 浅灰) */
    --white:        #ffffff;   /* 卡片背景 = --card-bg */
    --card-bg:      #ffffff;   /* 兼容旧命名 */
    --border:       #E5E5EA;   /* 标准分割线 */

    --text-main:    #000000;   /* 主文字（纯黑，对齐 iOS HIG） */
    --text-sub:     #8E8E93;   /* 次文字（Apple 系统灰） */
    --text-mute:    #8e8e93;   /* 兼容 */

    --accent:       #007AFF;   /* iOS 蓝 (主操作色，统一) */
    --accent-soft:  #f0f6ff;   /* 蓝色背景 (浅) */
    --danger:       #FF3B30;   /* 错误红 */
    --success:      #34c759;   /* 成功绿 */
    --warning:      #ff9500;   /* 警告橙 */

    /* 圆角 — iOS 标准 */
    --r-sm:         8px;       /* 小输入框、tag */
    --r-md:         12px;      /* 中卡片、列表 */
    --r-lg:         16px;      /* 大卡片 */
    --r-xl:         24px;      /* 特大（如登录卡） */
    --r-pill:       999px;     /* 胶囊按钮 */

    /* 阴影 — 浅到深 */
    --sh-sm:        0 2px 8px rgba(0, 0, 0, 0.04);
    --sh-md:        0 4px 16px rgba(0, 0, 0, 0.08);
    --sh-lg:        0 12px 32px rgba(0, 0, 0, 0.10);

    /* 字体 */
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display",
            "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    /* 通用尺寸 */
    --max-w:        1000px;   /* 页面内容最大宽度 */
    --max-w-narrow: 600px;    /* 登录/注册等窄页 */
}

/* ============================================================
 * 基础重置
 * ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
    font-size: 16px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
 * 排版（h1/h2/h3 字号）
 * ============================================================ */
h1 { font-size: 32px; font-weight: 700; margin: 0 0 16px; letter-spacing: -0.02em; }
h2 { font-size: 22px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 12px; }
small, .text-mute { color: var(--text-sub); font-size: 13px; }
.muted { color: var(--text-sub); }
.center { text-align: center; }
.right { text-align: right; }

/* ============================================================
 * 容器
 * ============================================================ */
.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 24px 20px;
}
.container-narrow {
    max-width: var(--max-w-narrow);
    margin: 0 auto;
    padding: 24px 20px;
}

/* ============================================================
 * 顶部导航（sticky + 毛玻璃）
 * ============================================================ */
header.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    font-family: var(--font);
}
.nav-container {
    position: relative;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-left-btn {
    border: none; background: transparent;
    font-size: 20px; cursor: pointer;
    color: var(--text-main);
    padding: 0;
    line-height: 1;
}
.nav-title {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600; font-size: 16px;
    color: var(--text-main);
}
.nav-right { display: flex; gap: 2px; align-items: center; }
.icon-btn {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border: none; background: transparent;
    font-size: 18px; cursor: pointer;
    color: var(--text-main);
    opacity: 0.85;
    text-decoration: none;
}
.icon-btn:hover { opacity: 1; text-decoration: none; }

/* 二级导航 */
.sub-nav {
    display: flex; justify-content: center; gap: 40px;
    padding: 12px 0;
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.sub-nav a {
    color: var(--text-main);
    opacity: 0.9;
    text-decoration: none;
    position: relative;
}
.sub-nav a:hover { color: var(--accent); opacity: 1; }
.sub-nav a.active { color: var(--accent); font-weight: 500; }

/* 红点徽标（未读） */
.nav-badge-dot {
    position: absolute; top: 2px; right: 2px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.85);
}

/* ============================================================
 * 卡片
 * ============================================================ */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    padding: 28px;
}
.card-bordered { box-shadow: none; }
.card-flush { padding: 0; }

/* ============================================================
 * 按钮
 * ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 96px;
    padding: 12px 20px;
    font-size: 14px; font-weight: 500;
    border-radius: var(--r-pill);
    border: none; cursor: pointer;
    transition: 0.18s ease;
    text-align: center;
    text-decoration: none;
    line-height: 1.4;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }

/* 主按钮（实心蓝）— 原网站叫 btn-apple */
.btn-primary,
.btn-apple {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover,
.btn-apple:hover { filter: brightness(1.05); }

/* 次按钮（白底蓝字）— 原网站叫 btn-white */
.btn-white {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--border);
}
.btn-white:hover { background: #f8f9fa; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: rgba(0, 113, 227, 0.08); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-width: 0; }
.btn-row { display: flex; justify-content: center; gap: 12px; margin-bottom: 18px; }
.btn-long { width: 204px; margin: 0 auto; display: block; }

/* ============================================================
 * 表单
 * ============================================================ */
.field { margin-bottom: 12px; }
.field label {
    display: block; margin: 0 0 6px 2px;
    font-size: 13px; color: var(--text-sub);
}
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    font-size: 16px; outline: none;
    background: #fff;
    color: var(--text-main);
    font-family: inherit;
    transition: 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}
.field .hint { margin-top: 6px; font-size: 12px; color: var(--text-sub); }
.field .error { margin-top: 6px; font-size: 12px; color: var(--danger); }

/* ============================================================
 * 提示框
 * ============================================================ */
.alert {
    margin: 0 0 14px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    font-size: 14px;
    border: 1px solid var(--border);
}
.alert.error {
    border-color: rgba(255, 59, 48, 0.25);
    color: var(--danger);
    background: rgba(255, 59, 48, 0.06);
}
.alert.success {
    border-color: rgba(52, 199, 89, 0.25);
    color: var(--success);
    background: rgba(52, 199, 89, 0.06);
}
.alert.warning {
    border-color: rgba(255, 149, 0, 0.25);
    color: var(--warning);
    background: rgba(255, 149, 0, 0.06);
}

/* ============================================================
 * 通用错误条（页面顶部红色横条）
 * ============================================================ */
.error-bar {
    position: fixed; top: 0; left: 0; right: 0;
    background: rgba(255, 59, 48, 0.8);
    color: white;
    padding: 10px 0;
    text-align: center;
    font-size: 14px;
    backdrop-filter: blur(10px);
    z-index: 9999;
}

/* ============================================================
 * 链接文字
 * ============================================================ */
.text-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.text-link:hover { text-decoration: underline; }
.text-muted { color: var(--text-sub); font-size: 14px; }

/* ============================================================
 * 底部 footer
 * ============================================================ */
.site-footer {
    text-align: center;
    padding: 40px 0;
    font-size: 12px;
    color: var(--text-sub);
    border-top: 1px solid var(--border);
    margin-top: 60px;
}

/* ============================================================
 * 隐藏 / 显示
 * ============================================================ */
.hidden { display: none !important; }

/* ============================================================
 * 左侧抽屉（header.php 引用）
 * ============================================================ */
.drawer-mask {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0; visibility: hidden;
    transition: 0.3s;
}
.drawer-mask.show { opacity: 1; visibility: visible; }
.drawer {
    position: fixed; top: 0; left: -280px;
    width: 280px; height: 100vh;
    background: #f2f2f7;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(280px); }
.drawer-header {
    padding: 20px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.drawer-title { font-size: 18px; font-weight: 700; color: var(--text-main); }
.drawer-close {
    background: none; border: none;
    font-size: 20px; color: #8e8e93;
    cursor: pointer; padding: 0;
}
.drawer-content { padding: 16px; overflow-y: auto; flex: 1; }
.drawer-item {
    display: flex; align-items: center;
    padding: 14px 16px; margin-bottom: 8px;
    background: #fff;
    border-radius: var(--r-md);
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500; font-size: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}
.drawer-item:hover { text-decoration: none; }
.drawer-item:active { background: #e5e5ea; transform: scale(0.98); }
.drawer-icon {
    font-size: 18px; margin-right: 12px;
    width: 24px; text-align: center;
}

/* ============================================================
 * 右上角气泡菜单（header.php 引用）
 * ============================================================ */
.settings-wrapper { position: relative; display: flex; align-items: center; }
.settings-menu {
    position: absolute; top: 42px; right: 0; width: 120px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: flex; flex-direction: column;
    padding: 6px 0;
    z-index: 200;
    opacity: 0; visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transform-origin: top right;
    transition: 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.settings-menu.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.settings-menu::before {
    content: ''; position: absolute;
    top: -5px; right: 10px;
    width: 10px; height: 10px;
    background: rgba(255, 255, 255, 0.95);
    transform: rotate(45deg);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
}
.settings-item {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
    position: relative; z-index: 1;
    text-align: center;
}
.settings-item:hover, .settings-item:active {
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
}
.settings-item.danger { color: var(--danger); }
