:root {
    /* Premium Color Palette */
    --bg-dark: #030712;         /* ดำลึกมาก */
    --bg-blue: #0f172a;         /* น้ำเงินเข้ม */
    --accent-gold: #D4AF37;     /* ทองหรูหรา */
    --accent-gold-light: #FCE883;
    --accent-gold-dark: #997A15;
    
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --price-up: #10B981;        /* เขียวสดใส (รับซื้อ) */
    --price-down: #EF4444;      /* แดงสดใส (ขายออก) */
}

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

body {
    font-family: 'Prompt', sans-serif;
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at 50% 50%, var(--bg-blue) 0%, var(--bg-dark) 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

/* แสงพื้นหลังเนียนๆ ไม่รบกวนสายตา */
.ambient-glow {
    position: absolute;
    top: -30%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 2vw;
    z-index: 1;
    position: relative;
}

/* ================= HEADER ================= */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5vh;
    border-bottom: 2px solid rgba(212, 175, 55, 0.3);
    margin-bottom: 2vh;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1.5vw;
}

.brand-logo {
    height: clamp(160px, 20vh, 280px);
    width: auto;
    object-fit: contain;
    /* เอาพื้นหลังและขอบออกหมดตามที่ลูกค้าต้องการ เป็น PNG โปร่งใส */
    background: transparent;
    border: none;
    box-shadow: none;
}

.brand-text h1 {
    font-size: clamp(1.8rem, 2.5vw, 3rem);
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
    letter-spacing: 0.5px;
}

.brand-text h2 {
    font-size: clamp(1rem, 1.2vw, 1.5rem);
    font-weight: 600;
    color: var(--accent-gold);
    letter-spacing: 2px;
}

.header-status {
    text-align: right;
}

.title-text {
    font-size: clamp(1.2rem, 1.5vw, 1.8rem);
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5vh;
}

.time-badge {
    font-size: clamp(1rem, 1.1vw, 1.4rem);
    color: var(--accent-gold-light);
    background: rgba(212, 175, 55, 0.1);
    padding: 0.5vh 1vw;
    border-radius: 30px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    display: inline-block;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 1vw;
    justify-content: flex-end;
}

.trend-badge {
    font-size: clamp(1rem, 1.1vw, 1.4rem);
    padding: 0.5vh 1vw;
    border-radius: 30px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4vw;
    transition: all 0.3s ease;
}

.trend-badge.up {
    background: rgba(16, 185, 129, 0.2);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.trend-badge.down {
    background: rgba(239, 68, 68, 0.2);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.trend-badge.neutral {
    background: rgba(148, 163, 184, 0.1);
    color: #94A3B8;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ================= MAIN CONTENT (SPLIT LAYOUT) ================= */
.main-content {
    display: flex;
    flex: 1;
    gap: 2vw;
    min-height: 0; /* Important for flex children scrolling/sizing */
}

/* ฝั่งซ้าย 40% */
.left-panel {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    gap: 2vh;
}

/* ฝั่งขวา 60% */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ================= PREMIUM CARDS ================= */
.premium-card {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 1.5rem;
    padding: 2vh 2vw;
    display: flex;
    flex-direction: column;
    flex: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.chart-card {
    padding: 1.5vh 1.5vw;
}

.card-title {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1vh;
    margin-bottom: 1.5vh;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title h3 {
    font-size: clamp(1.5rem, 2vw, 2.5rem);
    font-weight: 600;
    color: var(--text-main);
}

.card-title span {
    color: var(--accent-gold);
    font-size: clamp(1.2rem, 1.5vw, 2rem);
    font-weight: 400;
}

/* ================= PRICES ================= */
.price-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.price-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.price-divider {
    width: 1px;
    height: 70%;
    background: linear-gradient(to bottom, transparent, rgba(212, 175, 55, 0.5), transparent);
    margin: 0 1vw;
}

.label {
    font-size: clamp(1rem, 1.3vw, 1.6rem);
    color: var(--text-muted);
    margin-bottom: 1vh;
    font-weight: 400;
}

.value {
    /* Use clamp to ensure font scales and NEVER overflows */
    font-size: clamp(2rem, 4vw, 5.5rem);
    font-weight: 800;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.3s ease, color 0.3s ease;
}

.buy .value { color: var(--price-up); }
.sell .value { color: var(--price-down); }

/* Animation on update */
@keyframes flash-update {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.08); filter: brightness(1.5) drop-shadow(0 0 15px var(--accent-gold)); }
    100% { transform: scale(1); filter: brightness(1); }
}

.flash {
    animation: flash-update 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ================= HISTORY PANEL ================= */
.history-panel {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 1vh 2vw;
    margin-bottom: 2vh;
    display: flex;
    align-items: center;
    gap: 1.5vw;
}

.history-title {
    color: var(--text-muted);
    font-weight: 600;
    font-size: clamp(1rem, 1.2vw, 1.5rem);
    white-space: nowrap;
}

.history-list {
    display: flex;
    gap: 0.8vw;
    overflow-x: auto;
    scrollbar-width: none;
}

.history-list::-webkit-scrollbar {
    display: none;
}

.history-item {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.5vh 1vw;
    border-radius: 8px;
    font-size: clamp(0.9rem, 1vw, 1.2rem);
    white-space: nowrap;
    border: 1px solid transparent;
}

.history-item.up {
    color: #10B981;
    border-color: rgba(16, 185, 129, 0.3);
}

.history-item.down {
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.history-item.neutral {
    color: #94A3B8;
    border-color: rgba(148, 163, 184, 0.3);
}

/* ================= FOOTER ================= */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2vh;
    padding: 1.5vh 2vw;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 1rem;
}

.marquee-wrapper {
    flex: 1;
    overflow: hidden;
    margin-right: 2vw;
    border-right: 1px solid rgba(255,255,255,0.1);
    padding-right: 2vw;
}

.marquee-content {
    font-size: clamp(1rem, 1.2vw, 1.5rem);
    color: var(--accent-gold-light);
    white-space: nowrap;
    display: inline-block;
    animation: marquee 30s linear infinite;
}

@keyframes marquee {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.8vw;
    font-size: clamp(0.9rem, 1vw, 1.2rem);
    color: var(--text-muted);
    white-space: nowrap;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ef4444;
}

.online .pulse-dot {
    background-color: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ================= RESPONSIVE DESIGN (ป้องกันการทับซ้อน) ================= */
@media (max-width: 1200px) {
    header {
        flex-direction: column;
        align-items: center;
        gap: 2vh;
        text-align: center;
    }
    
    .status-row {
        justify-content: center;
        margin-top: 1vh;
    }
    
    .main-content {
        flex-direction: column;
        overflow-y: visible;
    }
    
    .left-panel, .right-panel {
        width: 100%;
        min-height: 50vh;
    }
}
