/* ============================================
   暖心陪伴 - 全局样式
   中老年适配：大字体、高对比、大按钮
   ============================================ */

/* CSS变量 */
:root {
    --primary: #5B86E5;
    --primary-dark: #3A67C4;
    --secondary: #FF9A56;
    --accent: #4ECDC4;
    --success: #48BB78;
    --warning: #F6AD55;
    --danger: #FC8181;
    
    --bg-primary: #F0F4F8;
    --bg-card: #FFFFFF;
    --bg-dark: #1A202C;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    
    --text-primary: #2D3748;
    --text-secondary: #718096;
    --text-light: #FFFFFF;
    --text-on-primary: #FFFFFF;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 50%;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
    
    /* 中老年适配：最小字号28px */
    --font-xs: 24px;
    --font-sm: 26px;
    --font-md: 30px;
    --font-lg: 34px;
    --font-xl: 40px;
    --font-xxl: 48px;
    --font-huge: 64px;
    
    /* 按钮最小高度 */
    --btn-min-height: 56px;
    --btn-large-height: 68px;
    --btn-huge-height: 80px;
    
    /* 安全区域 */
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    
    --app-height: 100vh;
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: var(--font-md);
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

#app {
    width: 100%;
    height: var(--app-height, 100vh);
    position: relative;
    overflow: hidden;
}

/* ===== 屏幕切换 ===== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1;
}
.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===== 启动屏 ===== */
#splash-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    justify-content: center;
    align-items: center;
}
.splash-content {
    text-align: center;
    padding: 40px;
}
.splash-icon {
    font-size: 120px;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}
.splash-title {
    font-size: var(--font-huge);
    color: var(--text-light);
    font-weight: 700;
    margin-bottom: 16px;
}
.splash-subtitle {
    font-size: var(--font-lg);
    color: rgba(255,255,255,0.8);
    margin-bottom: 60px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== 按钮系统 ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--btn-min-height);
    padding: 14px 36px;
    background: var(--primary);
    color: var(--text-on-primary);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--font-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
}
.btn-primary:active {
    transform: scale(0.95);
    background: var(--primary-dark);
}
.btn-large {
    min-height: var(--btn-large-height);
    padding: 18px 48px;
    font-size: var(--font-xl);
}
.btn-huge {
    min-height: var(--btn-huge-height);
    padding: 22px 60px;
    font-size: var(--font-xxl);
    border-radius: var(--radius-lg);
}
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--btn-min-height);
    padding: 14px 36px;
    background: var(--bg-card);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    font-size: var(--font-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:active {
    transform: scale(0.95);
    background: var(--bg-primary);
}
.btn-text {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: var(--font-lg);
    padding: 12px 20px;
    cursor: pointer;
}

/* ===== 引导教程 ===== */
#guide-screen {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    justify-content: center;
    align-items: center;
    padding: 40px;
}
.guide-slides {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.guide-slide {
    display: none;
    text-align: center;
    width: 100%;
}
.guide-slide.active {
    display: block;
    animation: fadeIn 0.3s ease;
}
.guide-emoji {
    font-size: 160px;
    margin-bottom: 40px;
}
.guide-slide h2 {
    font-size: var(--font-xxl);
    color: var(--text-light);
    margin-bottom: 24px;
}
.guide-slide p {
    font-size: var(--font-xl);
    color: rgba(255,255,255,0.9);
    line-height: 1.6;
}
.guide-dots {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 30px 0;
}
.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: all 0.3s;
}
.dot.active {
    background: #fff;
    transform: scale(1.3);
}
#guide-screen .btn-primary {
    margin-bottom: 16px;
}
#guide-screen .btn-text {
    opacity: 0.7;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 主场景 ===== */
#main-screen {
    background: #000;
    position: relative;
}
#scene-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}
#main-canvas {
    width: 100%;
    height: 100%;
    display: block;
}
#ar-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

/* 顶部状态栏 */
#top-bar {
    position: absolute;
    top: var(--safe-top);
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    z-index: 10;
}
.top-left, .top-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.info-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 18px;
    border-radius: var(--radius-lg);
    color: var(--text-light);
    font-size: var(--font-sm);
}
.info-chip .icon {
    font-size: var(--font-lg);
}
.icon-btn {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--font-xl);
    cursor: pointer;
}
.icon-btn:active {
    background: rgba(255,255,255,0.3);
}

/* 对话气泡 */
.speech-bubble {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius-lg);
    padding: 20px 28px;
    max-width: 80%;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    animation: bubbleIn 0.3s ease;
}
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-top: 16px solid rgba(255,255,255,0.95);
}
.speech-bubble p {
    font-size: var(--font-lg);
    color: var(--text-primary);
    line-height: 1.5;
    text-align: center;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.9); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* 提醒弹窗 */
.reminder-popup {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.reminder-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 50px 40px;
    text-align: center;
    max-width: 85%;
    animation: bubbleIn 0.3s ease;
}
.reminder-icon {
    font-size: 100px;
    margin-bottom: 20px;
}
.reminder-content h3 {
    font-size: var(--font-xxl);
    color: var(--danger);
    margin-bottom: 16px;
}
.reminder-detail {
    font-size: var(--font-xl);
    color: var(--text-primary);
    margin-bottom: 36px;
    line-height: 1.5;
}

/* 底部工具栏 */
#bottom-bar {
    position: absolute;
    bottom: calc(var(--safe-bottom) + 12px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 8px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10;
}
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    min-width: 64px;
}
.tool-btn .tool-icon {
    font-size: 36px;
    display: block;
}
.tool-btn .tool-label {
    font-size: var(--font-xs);
    color: var(--text-light);
    display: block;
}
.tool-btn-primary .tool-icon {
    background: var(--primary);
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(91,134,229,0.4);
}

/* ===== 面板系统 ===== */
.panel {
    position: absolute;
    z-index: 50;
    animation: slideUp 0.3s ease;
}
.bottom-panel {
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px 20px calc(var(--safe-bottom) + 20px);
    max-height: 70%;
    overflow-y: auto;
}
.fullscreen-panel {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.panel-header h3 {
    font-size: var(--font-xl);
    font-weight: 600;
}
.btn-close {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--font-lg);
    cursor: pointer;
}
.panel-section {
    margin-top: 24px;
}
.panel-section h4 {
    font-size: var(--font-lg);
    color: var(--text-secondary);
    margin-bottom: 16px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ===== 网格选择器 ===== */
.character-grid,
.scene-grid,
.action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px;
    background: var(--bg-primary);
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}
.grid-item:active {
    transform: scale(0.95);
}
.grid-item.selected {
    border-color: var(--primary);
    background: rgba(91,134,229,0.1);
}
.grid-item .item-icon {
    font-size: 56px;
}
.grid-item .item-label {
    font-size: var(--font-sm);
    color: var(--text-primary);
    text-align: center;
}

/* ===== 语音面板 ===== */
.voice-panel {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.voice-header {
    position: absolute;
    top: var(--safe-top);
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
}
.voice-header h3 {
    color: var(--text-light);
    font-size: var(--font-lg);
}
.voice-header .btn-close {
    background: rgba(255,255,255,0.1);
    color: var(--text-light);
}
.voice-visualizer {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}
.voice-ring {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 4px solid rgba(91,134,229,0.3);
    animation: none;
}
.voice-ring.active {
    animation: voiceRing 1.5s ease-in-out infinite;
}
.voice-avatar {
    font-size: 80px;
    z-index: 1;
}
.voice-status {
    font-size: var(--font-xl);
    color: var(--text-light);
    margin-bottom: 30px;
}
.voice-controls {
    margin-bottom: 30px;
}
.btn-voice-mic {
    width: 88px;
    height: 88px;
    border-radius: var(--radius-full);
    background: var(--primary);
    border: none;
    font-size: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(91,134,229,0.5);
    transition: all 0.2s;
}
.btn-voice-mic:active,
.btn-voice-mic.listening {
    transform: scale(1.1);
    background: var(--danger);
    box-shadow: 0 4px 20px rgba(252,129,129,0.5);
}
.voice-text {
    max-width: 80%;
    text-align: center;
    font-size: var(--font-lg);
    color: rgba(255,255,255,0.8);
    min-height: 50px;
}

@keyframes voiceRing {
    0% { transform: scale(1); opacity: 1; border-color: rgba(91,134,229,0.5); }
    50% { transform: scale(1.3); opacity: 0.5; border-color: rgba(91,134,229,0.2); }
    100% { transform: scale(1); opacity: 1; border-color: rgba(91,134,229,0.5); }
}

/* ===== 拍照预览 ===== */
.photo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-dark);
}
.photo-header h3 {
    color: var(--text-light);
    font-size: var(--font-lg);
}
.photo-header .btn-text {
    font-size: var(--font-md);
}
.photo-canvas-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding: 20px;
}
#photo-canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
}
.photo-actions {
    display: flex;
    gap: 16px;
    padding: 20px;
    padding-bottom: calc(var(--safe-bottom) + 20px);
}
.photo-actions .btn-primary,
.photo-actions .btn-secondary {
    flex: 1;
}

/* ===== 相册 ===== */
.album-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px 20px;
    overflow-y: auto;
    align-content: start;
}
.album-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
}
.album-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.album-item .album-date {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: var(--font-xs);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
.empty-tip {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: var(--font-lg);
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 24px;
}
.form-group label {
    display: block;
    font-size: var(--font-md);
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}
.form-input {
    width: 100%;
    min-height: var(--btn-min-height);
    padding: 14px 18px;
    font-size: var(--font-lg);
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus {
    border-color: var(--primary);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 20px 36px;
    border-radius: var(--radius-md);
    font-size: var(--font-lg);
    z-index: 1000;
    animation: toastIn 0.3s ease;
    text-align: center;
    max-width: 80%;
}
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ===== 权限对话框 ===== */
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.dialog-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px 30px;
    text-align: center;
    max-width: 85%;
}
.dialog-icon {
    font-size: 80px;
    margin-bottom: 20px;
}
.dialog-content h3 {
    font-size: var(--font-xl);
    margin-bottom: 12px;
}
.dialog-content p {
    font-size: var(--font-md);
    color: var(--text-secondary);
    margin-bottom: 30px;
}
.dialog-actions {
    display: flex;
    gap: 16px;
}
.dialog-actions .btn-primary,
.dialog-actions .btn-secondary {
    flex: 1;
}

/* ===== 全息投影模式 ===== */
.hologram-mode #scene-container {
    background: #000;
}
.hologram-mode #bottom-bar {
    background: rgba(0,0,0,0.8);
}
.hologram-mode .info-chip,
.hologram-mode .icon-btn {
    background: rgba(255,255,255,0.08);
}

/* 全息切换按钮 */
.holo-toggle {
    position: absolute;
    top: var(--safe-top);
    right: 20px;
    z-index: 15;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    color: var(--text-light);
    font-size: var(--font-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.holo-toggle.active {
    background: rgba(78,205,196,0.3);
    border: 1px solid var(--accent);
}

/* 全息提示 */
.holo-hint {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: var(--text-light);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: var(--font-md);
    text-align: center;
    z-index: 15;
    max-width: 90%;
    display: none;
}
.holo-hint.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ===== 省电模式 ===== */
.power-save-mode #main-canvas {
    image-rendering: optimizeSpeed;
}
.power-save-mode .voice-ring.active {
    animation-duration: 3s;
}

/* ===== 游戏面板 ===== */
.game-container {
    text-align: center;
    padding: 20px;
}
.game-result {
    font-size: var(--font-huge);
    margin: 20px 0;
}
.game-choices {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
}
.game-choice-btn {
    width: 90px;
    height: 90px;
    font-size: 48px;
    border: 3px solid var(--primary);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.game-choice-btn:active {
    transform: scale(0.9);
    background: rgba(91,134,229,0.2);
}
.game-score {
    font-size: var(--font-lg);
    color: var(--text-secondary);
    margin-top: 16px;
}

/* ===== 健康操指示 ===== */
.exercise-display {
    text-align: center;
    padding: 30px;
}
.exercise-name {
    font-size: var(--font-xxl);
    color: var(--primary);
    margin-bottom: 16px;
}
.exercise-step {
    font-size: var(--font-xl);
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: 24px;
}
.exercise-timer {
    font-size: var(--font-huge);
    color: var(--secondary);
    font-weight: 700;
}
.exercise-controls {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 30px;
}

/* ===== 响应式微调 ===== */
@media (max-height: 700px) {
    .guide-emoji { font-size: 100px; }
    .splash-icon { font-size: 80px; }
    .voice-visualizer { width: 150px; height: 150px; }
    .voice-ring { width: 150px; height: 150px; }
    .voice-avatar { font-size: 60px; }
}
@media (min-width: 500px) {
    .character-grid,
    .scene-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
