/* ========================================
   成人成事財經簡報 - 主樣式表
   ======================================== */

/* ---- Reset & Base ---- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Light Mode Colors */
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #2c2c2e;
    
    --text-primary: #1c1c1e;
    --text-secondary: #6b6b6b;
    --text-tertiary: #aeaeb2;
    --text-inverse: #f2f2f7;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.07);
    
    --accent-blue: #007aff;
    --accent-green: #34c759;
    --accent-red: #ff3b30;
    --accent-orange: #ff9500;
    --accent-yellow: #ffcc00;
    
    --skeleton-bg: #e5e5ea;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    
    /* Layout */
    --header-height: 52px;
    --tab-bar-height: 72px;
    --max-width: 390px;
}

/* Dark Mode Colors */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1c1c1e;
        --bg-secondary: #2c2c2e;
        --bg-tertiary: #3a3a3c;
        
        --text-primary: #f2f2f7;
        --text-secondary: #aeaeb2;
        --text-tertiary: #636366;
        
        --border-color: rgba(255, 255, 255, 0.07);
        --border-subtle: rgba(255, 255, 255, 0.07);
        
        --skeleton-bg: #3a3a3c;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Noto Sans TC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- App Container ---- */
.app {
    max-width: var(--max-width);
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}

/* ---- Page Layout ---- */
.page {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: var(--header-height) var(--spacing-lg) var(--tab-bar-height);
    display: none;
    scrollbar-width: thin;
    scrollbar-color: var(--text-tertiary) transparent;
}

.page.active {
    display: block;
}

.page::-webkit-scrollbar {
    width: 4px;
}

.page::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 2px;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    min-height: 44px;
}

.page-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.page-sub {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ---- Status Bar ---- */
.status-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    min-height: 18px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.ok { background: var(--accent-green); }
.status-dot.warn { background: var(--accent-orange); }
.status-dot.err { background: var(--accent-red); }
.status-dot.load { 
    background: var(--text-tertiary);
    animation: pulse 1s ease-in-out infinite;
}

.status-text {
    font-size: 10px;
    color: var(--text-tertiary);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Section Label ---- */
.section-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 7px;
}

/* ---- Skeleton Loading ---- */
.skeleton {
    background: var(--skeleton-bg);
    border-radius: var(--radius-sm);
    animation: pulse 1.2s ease-in-out infinite;
}

/* ---- Common Components ---- */
.card {
    background: var(--bg-secondary);
    border: 0.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
}

.source-pill {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 20px;
    border: 0.5px solid rgba(0, 0, 0, 0.15);
    color: var(--text-tertiary);
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    .source-pill {
        border-color: rgba(255, 255, 255, 0.15);
        color: #636366;
    }
}

.refresh-btn {
    font-size: 11px;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    border: 0.5px solid rgba(0, 0, 0, 0.2);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.refresh-btn:active {
    background: var(--skeleton-bg);
}

@media (prefers-color-scheme: dark) {
    .refresh-btn {
        background: var(--bg-secondary);
        border-color: rgba(255, 255, 255, 0.15);
        color: var(--text-inverse);
    }
    
    .refresh-btn:active {
        background: var(--bg-tertiary);
    }
}

/* ---- Price Colors ---- */
.pos { color: var(--accent-green); }
.neg { color: var(--accent-red); }

.chg {
    font-size: 12px;
    font-weight: 500;
}

/* ---- Meta Info ---- */
.meta-item {
    font-size: 11px;
    color: var(--text-secondary);
}

.meta-val {
    color: var(--text-primary);
    font-weight: 500;
}

/* ---- Tab Bar ---- */
.tab-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background: rgba(242, 242, 247, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: flex-start;
    padding-top: 10px;
    z-index: 100;
}

@media (prefers-color-scheme: dark) {
    .tab-bar {
        background: rgba(28, 28, 30, 0.92);
        border-top-color: rgba(255, 255, 255, 0.1);
    }
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    padding: 0 4px;
}

.tab-icon {
    font-size: 22px;
    line-height: 1;
}

.tab-label {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.tab-item.active .tab-label {
    color: var(--accent-blue);
}

.tab-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-blue);
    margin-top: 1px;
    opacity: 0;
}

.tab-item.active .tab-dot {
    opacity: 1;
}

/* ---- Grid Layouts ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.coins-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.indices-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 18px;
}

.metals-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 18px;
}

.rates-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 18px;
}

.movers-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 18px;
}

.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    align-items: center;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

/* ---- Utility Classes ---- */
.text-center { text-align: center; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
