/* =============================================
   국내주식 자동매매 시스템 v2 - 공유 CSS
   다크 테마, 모바일 반응형
   ============================================= */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-card: #1e2538;
    --bg-hover: #252d42;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --border: #2d3548;
    --accent: #4f8cff;
    --accent-hover: #6ba0ff;
    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.1);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.1);
    --yellow: #fbbf24;
    --yellow-bg: rgba(251, 191, 36, 0.1);
    --orange: #fb923c;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── 네비게이션 ─────────────────────────── */
.nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    margin-right: 24px;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-status {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── 티커바 ─────────────────────────────── */
.ticker-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    gap: 24px;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 13px;
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.ticker-value {
    font-weight: 600;
}

/* ── 컨테이너 ───────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* ── 그리드 ─────────────────────────────── */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── 카드 ───────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.card-value {
    font-size: 24px;
    font-weight: 700;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── 뱃지 ───────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-go { background: var(--green-bg); color: var(--green); }
.badge-half { background: var(--yellow-bg); color: var(--yellow); }
.badge-minimal { background: var(--yellow-bg); color: var(--orange); }
.badge-stop { background: var(--red-bg); color: var(--red); }
.badge-strong-buy { background: var(--green-bg); color: var(--green); }
.badge-buy { background: rgba(79, 140, 255, 0.15); color: var(--accent); }
.badge-watch { background: var(--yellow-bg); color: var(--yellow); }
.badge-pass { background: rgba(95, 99, 104, 0.2); color: var(--text-muted); }

/* ── 테이블 ─────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

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

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody td {
    padding: 10px 12px;
    white-space: nowrap;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── 색상 유틸 ──────────────────────────── */
.positive { color: var(--red); }   /* 한국은 빨간색이 상승 */
.negative { color: var(--accent); }   /* 파란색이 하락 */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-muted); }

/* ── 버튼 ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
    background: var(--red);
    color: #fff;
}
.btn-danger:hover { opacity: 0.85; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ── 인풋 / 셀렉트 ──────────────────────── */
select, input[type="date"], input[type="number"], input[type="text"] {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 13px;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── 필터바 ─────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* ── 탭 ─────────────────────────────────── */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tab {
    padding: 8px 16px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    transition: all 0.2s;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── 로딩 ───────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── 섹션 제목 ──────────────────────────── */
.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── 스크롤바 ───────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── 반응형 ─────────────────────────────── */
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .nav {
        padding: 0 12px;
    }

    .nav-brand {
        font-size: 14px;
        margin-right: 12px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }

    .container {
        padding: 12px;
    }

    .card {
        padding: 12px;
    }

    .ticker-bar {
        padding: 6px 12px;
        gap: 16px;
    }

    .filter-bar {
        gap: 6px;
    }

    .card-value {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .nav-links {
        gap: 2px;
    }

    .nav-link {
        padding: 6px 8px;
        font-size: 12px;
    }

    .grid {
        gap: 8px;
    }
}

/* ── 차트 컨테이너 ──────────────────────── */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

@media (max-width: 768px) {
    .chart-container {
        height: 220px;
    }
}

/* ── 게이지 ─────────────────────────────── */
.gauge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gauge-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ── 토스트 ─────────────────────────────── */
.toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── 유틸 ───────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
