/* =========================================================================
   HARU QUANT v15 — Pro Quant Dark Theme
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-primary: #0B0E11;
    --bg-secondary: #1E2329;
    --bg-tertiary: #2B3139;
    --bg-hover: #363D47;
    --border: #2B3139;
    --border-light: #363D47;

    --text-primary: #EAECEF;
    --text-secondary: #848E9C;
    --text-muted: #5E6673;

    --green: #0ECB81;
    --green-dim: rgba(14, 203, 129, 0.15);
    --red: #F6465D;
    --red-dim: rgba(246, 70, 93, 0.15);
    --blue: #1E80FF;
    --purple: #A855F7;
    --cyan: #22D3EE;
    --gold: #F0B90B;
    --orange: #FF6838;

    --cloud-bull: rgba(14, 203, 129, 0.08);
    --cloud-bear: rgba(246, 70, 93, 0.08);

    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* =========================================================================
   HEADER
   ========================================================================= */

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    user-select: none;
}

.logo .version {
    font-size: 10px;
    color: var(--gold);
    background: rgba(240, 185, 11, 0.12);
    padding: 2px 7px;
    border-radius: 3px;
    font-weight: 500;
}

.chart-mode-btn {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 3px 10px;
    border-radius: 3px;
    border: 1px solid var(--border);
    margin-left: 6px;
    transition: all 0.15s;
}
.chart-mode-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.chart-mode-btn.active { color: var(--gold); border-color: var(--gold); background: rgba(240,185,11,0.1); }

.guide-btn {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.15s;
}
.guide-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.logo .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse 2s infinite;
}

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

/* Coin Tabs */
.coin-tabs {
    display: flex;
    gap: 4px;
}

.coin-tab {
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.coin-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.coin-tab.active {
    color: var(--gold);
    background: rgba(240, 185, 11, 0.08);
    border-color: rgba(240, 185, 11, 0.25);
}

/* Header right */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.regime-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.regime-badge.bull {
    color: var(--green);
    background: var(--green-dim);
}
.regime-badge.bear {
    color: var(--red);
    background: var(--red-dim);
}
.regime-badge.ranging {
    color: var(--gold);
    background: rgba(240, 185, 11, 0.12);
}

/* =========================================================================
   MAIN LAYOUT
   ========================================================================= */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chart Area */
#chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: scroll;
    min-width: 0;
    padding-right: 14px;  /* 스크롤바 공간 확보 */
}

#chart-area::-webkit-scrollbar { width: 14px; }
#chart-area::-webkit-scrollbar-track { background: #0B0E11; }
#chart-area::-webkit-scrollbar-thumb { background: #363D47; border-radius: 7px; border: 3px solid #0B0E11; }
#chart-area::-webkit-scrollbar-thumb:hover { background: #4a5568; }

/* ---- Chart Panels ---- */
.chart-panel {
    position: relative;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.chart-panel:last-child {
    border-bottom: none;
}

.chart-label {
    position: absolute;
    top: 8px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    pointer-events: none;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.chart-label .tf-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chart-label .indicator-tags {
    display: flex;
    gap: 4px;
}

.chart-label .indicator-tag {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 2px;
    background: rgba(30, 128, 255, 0.1);
    color: var(--blue);
}

/* Panel heights */
#panel-1h { height: 450px; min-height: 450px; }
#panel-15m { height: 350px; min-height: 350px; }
#panel-macd { height: 150px; min-height: 150px; }
#panel-rsi { height: 150px; min-height: 150px; }
#panel-5m { height: 350px; min-height: 350px; }

.chart-container {
    width: 100%;
    height: 100%;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.chart-container canvas {
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: crisp-edges !important;
}

/* =========================================================================
   SIDEBAR
   ========================================================================= */

#sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-section {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

/* Accounts — filter buttons */
.account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: var(--radius);
    margin-bottom: 3px;
    transition: all 0.15s;
}

.account-filter {
    cursor: pointer;
    opacity: 0.5;
    border: 1px solid transparent;
}

.account-filter:hover {
    background: var(--bg-tertiary);
    opacity: 0.8;
}

.account-filter.active {
    opacity: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
}

.filter-hint {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 400;
}

.account-name {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 1px rgba(255,255,255,0.3);
}

.account-name.recipe-all { color: #FFFFFF; }
.account-name.recipe-a { color: #5AAFFF; }
.account-name.recipe-a2 { color: #D4A0FF; }
.account-name.recipe-a3 { color: #40F0FF; }
.account-name.recipe-bc { color: #FFE44D; }
.account-name.recipe-d { color: #10B981; }

.account-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: #F0F0F0;
}

.account-pnl {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    margin-left: 6px;
}

.account-pnl.positive { color: var(--green); }
.account-pnl.negative { color: var(--red); }

/* Signals */
.signal-card {
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: var(--radius);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}

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

.signal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.signal-recipe {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
}

.signal-recipe.A { color: var(--blue); background: rgba(30, 128, 255, 0.12); }
.signal-recipe.A2 { color: var(--purple); background: rgba(168, 85, 247, 0.12); }
.signal-recipe.A3 { color: var(--cyan); background: rgba(34, 211, 238, 0.12); }
.signal-recipe.B { color: var(--gold); background: rgba(240, 185, 11, 0.12); }
.signal-recipe.C { color: var(--orange); background: rgba(255, 104, 56, 0.12); }

.signal-coin {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.signal-dir {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 3px;
}

.signal-dir.LONG { color: var(--green); background: var(--green-dim); }
.signal-dir.SHORT { color: var(--red); background: var(--red-dim); }

.signal-reason {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

.signal-strength {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.strength-bar-bg {
    flex: 1;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.strength-val {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: right;
}

/* Stats */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

/* Legend */
.legend-section {
    padding: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 10px;
    color: var(--text-secondary);
}

.legend-color {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ---- No Signal ---- */
.no-signals {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 1200px) {
    #sidebar {
        width: 220px;
        min-width: 220px;
    }
}

@media (max-width: 900px) {
    #app {
        height: auto !important;
        min-height: 100vh;
    }
    #header {
        flex-wrap: wrap;
        height: auto;
        padding: 8px;
        gap: 8px;
    }
    .coin-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        flex-wrap: nowrap !important;
        width: 100%;
        padding-bottom: 4px;
    }
    .coin-tab {
        flex-shrink: 0;
    }
    .header-right {
        width: 100%;
        justify-content: flex-end;
    }
    .logo .version { display: none; }
    #main {
        flex-direction: column !important;
        overflow: visible !important;
    }
    #sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-height: none;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }
    .sidebar-section {
        padding: 4px;
    }
    .sidebar-title {
        font-size: 11px !important;
    }
    .account-row {
        padding: 4px 8px;
        font-size: 12px;
    }
    #chart-area {
        overflow-y: visible !important;
        padding-right: 0 !important;
    }
    .chart-panel {
        height: 250px !important;
        min-height: 250px !important;
    }
    .coin-tabs {
        flex-wrap: wrap;
    }
    .coin-tab {
        font-size: 12px !important;
        padding: 4px 8px !important;
    }
}

@media (max-width: 480px) {
    .chart-panel {
        height: 200px !important;
        min-height: 200px !important;
    }
    .sidebar-header h2 {
        font-size: 14px;
    }
    .signal-card {
        padding: 6px !important;
        font-size: 11px !important;
    }
    .account-value {
        font-size: 11px !important;
    }
    .account-pnl {
        font-size: 10px !important;
    }
}
