/* =========================================
   台股投資雷達 — 基礎排版與重置
   ========================================= */

/* === CSS Reset === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === 連結 === */
a {
    color: var(--brand-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--brand-primary);
}

/* === 按鈕基礎 === */
button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    background: none;
    color: inherit;
    font-size: inherit;
}

/* === 輸入框基礎 === */
input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

/* === 清單 === */
ul, ol {
    list-style: none;
}

/* === 圖片 === */
img {
    max-width: 100%;
    display: block;
}

/* === 選取 === */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

/* === 捲軸美化 === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* === 通用工具類 === */
.mono {
    font-family: var(--font-mono);
}

.text-up {
    color: var(--color-up) !important;
}
.text-down {
    color: var(--color-down) !important;
}
.text-flat {
    color: var(--color-flat) !important;
}
.text-secondary {
    color: var(--text-secondary);
}
.text-center {
    text-align: center;
}

.bg-up {
    background: var(--color-up-bg);
}
.bg-down {
    background: var(--color-down-bg);
}

/* === 載入動畫 === */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: var(--space-lg);
    color: var(--text-secondary);
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === 數字跳動動畫 === */
@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: countUp 0.4s var(--transition-base) forwards;
}

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

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* === 脈動動畫 (即時報價) === */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* === 閃爍標記（價格更新） === */
@keyframes priceFlash {
    0% { background-color: transparent; }
    30% { background-color: rgba(99, 102, 241, 0.2); }
    100% { background-color: transparent; }
}

.price-flash {
    animation: priceFlash 0.6s ease-out;
}

/* === 骨架屏 === */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        var(--bg-elevated) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: var(--radius-sm);
}

.skeleton-text.short {
    width: 60%;
}

/* === Toast 通知 === */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: var(--text-sm);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
}

.toast.success { border-left: 3px solid var(--color-up); }
.toast.info { border-left: 3px solid var(--brand-primary); }
.toast.warning { border-left: 3px solid #F59E0B; }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
