/* =============================================
   CSS 變數 & Reset
   ============================================= */
:root {
    --bg-dark: #0d0f1a;
    --bg-card: rgba(22, 26, 44, 0.72);
    --border-color: rgba(255, 255, 255, 0.09);
    --text-main: #edf0f7;
    --text-muted: #7a82a0;
    --color-buy: #00e676;
    --color-sell: #ff3d5e;
    --color-neutral: #4fc3f7;
    --color-accent: #a78bfa;
    --font: 'Outfit', sans-serif;
    --glow-buy: rgba(0, 230, 118, 0.18);
    --glow-sell: rgba(255, 61, 94, 0.18);
    --radius-card: 18px;
    --radius-btn: 10px;
    --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    padding: 20px 16px 40px;
    background-image:
        radial-gradient(ellipse at 10% 60%, rgba(50, 30, 120, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 90% 20%, rgba(100, 30, 60, 0.25) 0%, transparent 50%);
    background-attachment: fixed;
}

/* =============================================
   Layout Container
   ============================================= */
.app-container {
    max-width: 1300px;
    margin: 0 auto;
}

/* =============================================
   Glassmorphism Card
   ============================================= */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

/* =============================================
   Header
   ============================================= */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon { font-size: 36px; line-height: 1; }

.logo-text h1 {
    font-size: clamp(20px, 4vw, 28px);
    font-weight: 700;
    letter-spacing: 0.3px;
    background: linear-gradient(100deg, #fff 30%, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.label-text {
    font-size: 14px;
    color: var(--text-muted);
}

.glass-select, .glass-input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-btn);
    font-family: var(--font);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition), background var(--transition);
    -webkit-appearance: none;
}

.glass-select:focus, .glass-input:focus {
    border-color: var(--color-neutral);
    background: rgba(255, 255, 255, 0.1);
}

.glass-select option {
    background: #161a2c;
    color: var(--text-main);
}

/* =============================================
   Tabs
   ============================================= */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 11px 20px;
    border-radius: var(--radius-btn);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.tab-btn.active {
    background: rgba(167, 139, 250, 0.18);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.tab-icon { font-size: 16px; }

.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: fadeUp 0.35s ease;
}

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

/* =============================================
   Summary Cards
   ============================================= */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    padding: 22px 24px;
    transition: transform var(--transition);
}
.card:hover { transform: translateY(-4px); }

.card h3 {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.card-content {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.card-content .symbol {
    font-size: 17px;
    font-weight: 600;
    word-break: break-all;
}

.card-content .value {
    font-size: 26px;
    font-weight: 700;
    white-space: nowrap;
}

/* Colours */
.buy   { color: var(--color-buy);  text-shadow: 0 0 12px var(--glow-buy); }
.sell  { color: var(--color-sell); text-shadow: 0 0 12px var(--glow-sell); }
.neutral { color: var(--text-main); }
.remove  { color: var(--text-muted); text-decoration: line-through; }

/* =============================================
   Table
   ============================================= */
.table-container { padding: 24px; overflow: hidden; }

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 14px;
    flex-wrap: wrap;
}

.table-header h2 { font-size: 19px; font-weight: 600; }

.table-actions { flex: 1; max-width: 300px; }

.glass-input { width: 100%; }

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; text-align: left; min-width: 360px; }

th, td { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.05); }

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
    white-space: nowrap;
}

th:hover { color: var(--text-main); }

.sort-icon { font-size: 11px; opacity: 0.5; margin-left: 4px; }
th.active-sort .sort-icon { opacity: 1; color: var(--color-neutral); }

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.03); }

.num-col { text-align: right; font-variant-numeric: tabular-nums; }

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
    display: none;
}

/* Badge */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}

.badge.buy-badge    { background: rgba(0,230,118,.1);  color: var(--color-buy);  border: 1px solid rgba(0,230,118,.2); }
.badge.sell-badge   { background: rgba(255,61,94,.1);  color: var(--color-sell); border: 1px solid rgba(255,61,94,.2); }
.badge.neutral-badge { background: rgba(255,255,255,.07); color: var(--text-main); }

/* =============================================
   Chart Section
   ============================================= */
.chart-section { padding: 24px 24px 20px; }

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.chart-header h2 { font-size: 19px; font-weight: 600; }

.chart-top-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.chart-date-display {
    font-size: clamp(18px, 3vw, 26px);
    font-weight: 700;
    color: var(--color-neutral);
    font-variant-numeric: tabular-nums;
    min-width: 110px;
    text-align: center;
}

.glass-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 9px 18px;
    border-radius: var(--radius-btn);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.glass-btn:hover { background: rgba(255,255,255,0.16); }

.play-btn.playing {
    background: rgba(167,139,250,0.2);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

#chart-container {
    width: 100%;
    height: clamp(320px, 55vh, 600px);
}

/* =============================================
   Timeline (Scrubber) Panel
   ============================================= */
.timeline-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.timeline-nav-btn {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.timeline-nav-btn:hover { background: rgba(255,255,255,0.16); }
.timeline-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.timeline-track-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Slider styling */
.timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(to right, var(--color-accent) 0%, var(--color-accent) var(--progress, 0%), rgba(255,255,255,0.12) var(--progress, 0%), rgba(255,255,255,0.12) 100%);
    transition: height var(--transition);
}

.timeline-slider:hover { height: 8px; }

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 8px rgba(167,139,250,0.6);
    cursor: pointer;
    transition: transform var(--transition);
}

.timeline-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }

.timeline-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    border: none;
    box-shadow: 0 0 8px rgba(167,139,250,0.6);
    cursor: pointer;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
}

.tl-label {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* =============================================
   Responsive — Mobile (≤ 600px)
   ============================================= */
@media (max-width: 600px) {
    body { padding: 12px 10px 32px; }

    .header { margin-bottom: 18px; }
    .logo-icon { font-size: 28px; }

    .controls { width: 100%; }
    .glass-select { width: 100%; }

    .summary-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card { padding: 16px 18px; }

    .card-content .value { font-size: 22px; }

    .tab-btn { padding: 9px 14px; font-size: 14px; }
    .tab-icon { display: none; }   /* 手機隱藏 icon 省空間 */

    .table-header { flex-direction: column; align-items: flex-start; }
    .table-actions { max-width: 100%; width: 100%; }

    .hide-mobile { display: none; }

    .chart-header { flex-direction: column; align-items: flex-start; }

    .chart-top-controls { width: 100%; justify-content: space-between; }

    .timeline-nav-btn { width: 32px; height: 32px; font-size: 18px; }

    #chart-container { height: clamp(280px, 60vw, 380px); }
}

/* Responsive — Tablet (601px ~ 900px) */
@media (min-width: 601px) and (max-width: 900px) {
    .summary-cards { grid-template-columns: repeat(2, 1fr); }

    .hide-mobile { display: none; }
}
