:root {
    --bg-app: #080c14;
    --bg-sidebar: #0f1524;
    --bg-card: #131b2e;
    --border-color: #1e293b;
    --border-hover: #334155;
    
    --text-title: #f8fafc;
    --text-body: #cbd5e1;
    --text-muted: #64748b;
    
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.15);
    
    --gain: #f43f5e; /* Korean standard: red is gain */
    --gain-bg: rgba(244, 63, 94, 0.1);
    --loss: #4b89ff; /* Korean standard: blue is loss */
    --loss-bg: rgba(75, 137, 255, 0.1);
    
    --font-sans: 'Plus Jakarta Sans', 'Noto Sans KR', sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-app);
    color: var(--text-body);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 240px 320px 1fr;
    height: 100vh;
    width: 100vw;
}

/* 1. LEFT SIDEBAR STYLE */
.sidebar-left {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.brand-icon {
    font-size: 1.5rem;
}

.brand-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-title);
    letter-spacing: 0.5px;
}

.menu-section {
    flex: 1;
}

.menu-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 1rem;
    font-weight: 700;
}

.index-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.index-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.index-info {
    display: flex;
    flex-direction: column;
}

.index-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.index-value {
    font-size: 0.95rem;
    color: var(--text-title);
    font-weight: 700;
    margin-top: 0.1rem;
}

.index-change {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.index-change.gain {
    color: var(--gain);
    background-color: var(--gain-bg);
}

.index-change.loss {
    color: var(--loss);
    background-color: var(--loss-bg);
}

/* Weather Widget styling */
.weather-widget {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-top: auto;
}

.weather-header select {
    background: transparent;
    border: none;
    color: var(--text-title);
    font-size: 0.85rem;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    width: 100%;
}

.weather-header select option {
    background-color: var(--bg-sidebar);
    color: var(--text-title);
}

.weather-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.75rem 0;
}

.weather-temp {
    font-size: 1.75rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-title);
}

.weather-desc {
    font-size: 0.8rem;
    color: var(--text-body);
}

.weather-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
}

/* 2. MIDDLE SIDEBAR STYLE (Watchlist) */
.sidebar-middle {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

.watchlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-title {
    font-size: 1rem;
    color: var(--text-title);
    font-weight: 700;
}

.btn-primary-sm {
    background-color: var(--accent-glow);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

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

.watchlist-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.wl-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

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

.wl-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}

.wl-index {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-muted);
    margin-right: 0.75rem;
    width: 12px;
}

.wl-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
    margin-right: 0.75rem;
}

.wl-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.wl-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-title);
}

.wl-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.wl-sparkline {
    width: 60px;
    height: 25px;
    margin: 0 0.5rem;
}

.wl-price-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.wl-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-title);
}

.wl-change {
    font-size: 0.75rem;
    font-weight: bold;
    margin-top: 0.1rem;
}

.wl-change.gain { color: var(--gain); }
.wl-change.loss { color: var(--loss); }

.wl-remove-btn {
    position: absolute;
    top: 4px;
    right: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.wl-card:hover .wl-remove-btn {
    opacity: 1;
}

.wl-remove-btn:hover {
    color: var(--loss);
}

.portfolio-summary-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.summary-value {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-title);
}

.summary-value.gain { color: var(--gain); }
.summary-value.loss { color: var(--loss); }


/* 3. MAIN DASHBOARD CONTENT STYLE */
.main-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}

.top-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.status-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.market-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background-color: rgba(244, 63, 94, 0.05);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--gain);
    border-radius: 50%;
}

.status-text {
    font-size: 0.75rem;
    color: var(--gain);
    font-weight: 700;
}

/* Active Stock details */
.active-stock-section {
    margin-bottom: 1.5rem;
}

.active-stock-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

.stock-meta-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stock-code-badge {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
}

.active-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-title);
}

.tag-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.tag-badge.text-kospi {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent);
}

.tag-badge.text-sec {
    background-color: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
}

.stock-price-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.active-price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-title);
    font-family: var(--font-heading);
}

.active-price-change {
    font-size: 1rem;
    font-weight: 700;
    margin-top: 0.15rem;
}

.active-price-change.gain { color: var(--gain); }
.active-price-change.loss { color: var(--loss); }

.stock-submetrics {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.01);
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1rem;
}

.metric-val {
    color: var(--text-title);
    font-weight: 700;
    margin-left: 0.25rem;
}

.metric-val.gain { color: var(--gain); }
.metric-val.loss { color: var(--loss); }

/* Main Chart box */
.main-chart-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
}

.chart-timeframe-header {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
}

.timeframe-tabs {
    display: flex;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.2rem;
    border-radius: 8px;
}

.tf-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.3rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
}

.tf-tab.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-title);
}

.chart-canvas-wrapper {
    height: 350px;
    width: 100%;
}

/* My holdings styling */
.holding-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-title);
    margin-bottom: 1rem;
}

.holding-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.holding-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.holding-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.holding-val {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-title);
}

.holding-val.gain { color: var(--gain); }
.holding-val.loss { color: var(--loss); }

/* Feeds grids: News & Forum */
.feed-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.feed-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
}

.forum-list, .news-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.forum-item, .news-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.forum-item:last-child, .news-item:last-child {
    border-bottom: none;
}

.forum-title, .news-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-title);
    line-height: 1.4;
    cursor: pointer;
}

.forum-title:hover, .news-title:hover {
    color: var(--accent);
}

.forum-meta, .news-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    gap: 0.5rem;
}

.forum-num {
    font-weight: bold;
    color: var(--accent);
    margin-right: 0.5rem;
}

/* Modal overlay stylings */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 450px;
    max-width: 90%;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-title);
}

#modal-search-input {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-title);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    outline: none;
    margin-bottom: 1rem;
}

#modal-search-input:focus {
    border-color: var(--accent);
}

.modal-results {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

.modal-result-item:hover {
    background-color: var(--accent-glow);
    border-color: var(--accent);
}

.result-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-title);
}

.result-symbol {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Real-time price flashing animations */
@keyframes flash-up {
    0% { background-color: rgba(244, 63, 94, 0.4); color: #ff4b4b; }
    100% { background-color: transparent; }
}

@keyframes flash-down {
    0% { background-color: rgba(75, 137, 255, 0.4); color: #4b89ff; }
    100% { background-color: transparent; }
}

.flash-up {
    animation: flash-up 0.4s ease-out;
}

.flash-down {
    animation: flash-down 0.4s ease-out;
}

/* Responsiveness overrides */
@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: 200px 1fr;
    }
    .sidebar-middle {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar-left {
        display: none;
    }
    .holding-grid {
        grid-template-columns: 1fr 1fr;
    }
    .feed-grid {
        grid-template-columns: 1fr;
    }
}
