/* ============================================
   Office Survival - 職場生存工具
   全局樣式
   ============================================ */

:root {
    --primary: #6c5ce7;
    --primary-dark: #5b4cdb;
    --secondary: #00cec9;
    --accent: #fd79a8;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #00b894;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #252540;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --border: #2a2a45;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 隱藏類 */
.hidden { display: none !important; }

/* ============================================
   啟動畫面
   ============================================ */
.splash-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.6s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    padding: 2rem;
}

.splash-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

.splash-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.splash-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.splash-loader {
    width: 200px;
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    margin: 0 auto 1rem;
    overflow: hidden;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
    animation: loadBar 2s ease forwards;
}

.splash-hint {
    font-size: 0.75rem !important;
    opacity: 0.6;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes loadBar {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ============================================
   主容器
   ============================================ */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* ============================================
   頂部標題欄
   ============================================ */
.app-header {
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    flex-shrink: 0;
    z-index: 100;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-card-hover);
}

.icon-btn.active {
    background: var(--primary);
}

/* ============================================
   主內容區
   ============================================ */
.app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.app-main::-webkit-scrollbar {
    width: 0;
}

/* ============================================
   底部導航
   ============================================ */
.app-nav {
    height: 64px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-shrink: 0;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    height: 100%;
    border: none;
    background: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.nav-item .nav-icon {
    font-size: 1.4rem;
    transition: var(--transition);
}

.nav-item .nav-label {
    font-size: 0.65rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 6px;
    width: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

/* ============================================
   通用組件
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--primary);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.input-area {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    color: var(--text);
    font-size: 1rem;
    resize: none;
    font-family: inherit;
    transition: var(--transition);
}

.input-area:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================
   下班結界覆蓋層
   ============================================ */
.boundary-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.boundary-content {
    text-align: center;
    max-width: 320px;
}

.boundary-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.boundary-content h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--danger);
}

.boundary-time {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin: 1rem 0;
    font-variant-numeric: tabular-nums;
}

.boundary-cost {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin: 1.5rem 0;
    border: 1px solid var(--border);
}

.boundary-cost p {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

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

/* ============================================
   假通知
   ============================================ */
.fake-notification {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 400px;
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 500;
    animation: slideDown 0.4s ease;
    cursor: pointer;
}

.fake-notification.hiding {
    animation: slideUp 0.4s ease forwards;
}

.fake-notify-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.fake-notify-content {
    flex: 1;
    min-width: 0;
}

.fake-notify-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.fake-notify-body {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fake-notify-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(-100%); opacity: 0; }
}

/* ============================================
   頁面特定樣式
   ============================================ */

/* --- 防護罩頁面 --- */
.shield-page .translate-box {
    margin-bottom: 1rem;
}

.shield-page .result-box {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1rem;
    border-left: 4px solid var(--success);
    animation: fadeIn 0.3s ease;
}

.shield-page .emotion-meter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}

.shield-page .emotion-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.shield-page .emotion-flames {
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.shield-page .emotion-hint {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.5rem;
    font-style: italic;
}

.shield-page .quick-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.shield-page .quick-tag {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.shield-page .quick-tag:hover {
    border-color: var(--primary);
    color: var(--text);
}

/* --- Bingo 頁面 --- */
.bingo-page .bingo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin: 1rem 0;
}

.bingo-page .bingo-cell {
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.bingo-page .bingo-cell:hover {
    border-color: var(--primary);
}

.bingo-page .bingo-cell.marked {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: white;
}

.bingo-page .bingo-cell.marked::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.7rem;
    opacity: 0.7;
}

.bingo-page .bingo-cell.bingo-line {
    animation: bingoFlash 1s ease infinite alternate;
}

@keyframes bingoFlash {
    from { box-shadow: 0 0 5px var(--warning); }
    to { box-shadow: 0 0 20px var(--warning), 0 0 40px var(--warning); }
}

.bingo-page .bingo-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.bingo-page .bingo-counter {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--warning);
}

.bingo-page .bingo-prize {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    margin-top: 1rem;
}

.bingo-page .bingo-prize.locked {
    opacity: 0.5;
}

.bingo-page .bingo-prize.unlocked {
    border: 2px solid var(--warning);
    animation: prizeUnlock 0.6s ease;
}

@keyframes prizeUnlock {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- 偽裝聊天頁面 --- */
.chat-page .chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.chat-page .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-page .msg {
    max-width: 80%;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
    animation: msgPop 0.3s ease;
}

.chat-page .msg.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-page .msg.received {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-page .msg-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 0.3rem;
    text-align: right;
}

.chat-page .chat-input-area {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.chat-page .chat-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 0.6rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.chat-page .chat-input:focus {
    border-color: var(--primary);
}

.chat-page .chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.chat-page .chat-send:hover {
    background: var(--primary-dark);
}

.chat-page .chat-modes {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    overflow-x: auto;
    padding-bottom: 0.3rem;
}

.chat-page .chat-mode-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.chat-page .chat-mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

@keyframes msgPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- 變臉 UI 頁面 --- */
.disguise-page .disguise-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.disguise-page .disguise-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.disguise-page .disguise-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
}

.disguise-page .disguise-card.active {
    border-color: var(--success);
    background: rgba(0, 184, 148, 0.1);
}

.disguise-page .disguise-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.disguise-page .disguise-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.disguise-page .disguise-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.disguise-page .preview-area {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    min-height: 200px;
}

/* Excel 偽裝 */
.excel-preview {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 0.8rem;
}

.excel-toolbar {
    background: #217346;
    color: white;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
}

.excel-formula-bar {
    background: #f3f3f3;
    color: #333;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid #d4d4d4;
    font-size: 0.75rem;
}

.excel-grid {
    display: grid;
    grid-template-columns: 30px repeat(3, 1fr);
    background: white;
    color: #333;
}

.excel-cell {
    border: 1px solid #e0e0e0;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.excel-cell.header {
    background: #f3f3f3;
    text-align: center;
    font-weight: 600;
}

.excel-cell.row-header {
    background: #f3f3f3;
    text-align: center;
}

/* Outlook 偽裝 */
.outlook-preview {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 0.8rem;
    background: #f5f5f5;
    color: #333;
}

.outlook-header {
    background: #0078d4;
    color: white;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
}

.outlook-folder {
    background: #f5f5f5;
    padding: 0.3rem 0.8rem;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.75rem;
    color: #666;
}

.outlook-item {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    cursor: pointer;
}

.outlook-item:hover {
    background: #f0f0f0;
}

.outlook-sender {
    font-weight: 600;
    font-size: 0.8rem;
    color: #333;
}

.outlook-subject {
    font-size: 0.75rem;
    color: #666;
    margin-top: 2px;
}

.outlook-snippet {
    font-size: 0.7rem;
    color: #999;
    margin-top: 2px;
}

/* --- 假通知頁面 --- */
.notify-page .notify-templates {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin: 1rem 0;
}

.notify-page .notify-template {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.notify-page .notify-template:hover {
    border-color: var(--primary);
}

.notify-page .notify-template-icon {
    font-size: 1.8rem;
}

.notify-page .notify-template-info {
    flex: 1;
}

.notify-page .notify-template-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.notify-page .notify-template-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.notify-page .custom-notify-form {
    margin-top: 1rem;
}

.notify-page .form-group {
    margin-bottom: 0.8rem;
}

.notify-page .form-label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
}

/* --- 下班結界設定頁 --- */
.boundary-settings .time-range {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    justify-content: center;
}

.boundary-settings .time-input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    text-align: center;
    width: 100px;
}

.boundary-settings .toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
}

/* 開關 */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
    background: var(--bg);
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch.active {
    background: var(--success);
    border-color: var(--success);
}

.toggle-switch.active::after {
    left: 24px;
    background: white;
}

/* ============================================
   動畫
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-enter {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   響應式
   ============================================ */
@media (max-width: 360px) {
    .nav-label {
        display: none;
    }
    
    .bingo-page .bingo-grid {
        gap: 0.4rem;
    }
    
    .bingo-page .bingo-cell {
        font-size: 0.7rem;
        padding: 0.3rem;
    }
}
