:root {
    /* Dark Mode (Default) */
    --bg-dark: #0f172a;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --accent-yellow: #f59e0b;
    
    --card-hover: rgba(255, 255, 255, 0.08);
}

/* Light Mode Override */
[data-theme="light"] {
    --bg-dark: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    
    --card-hover: rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Glassmorphism Utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
    transition: background 0.3s, border 0.3s;
}

/* Sidebar */
.sidebar {
    width: 250px;
    margin: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 40px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-links li {
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.nav-links li:hover, .nav-links li.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 16px 16px 0;
    overflow: hidden;
}

.top-bar {
    height: 60px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.status-dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-open { background-color: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-closed { background-color: var(--accent-red); }

.content-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

/* Search Bar Styles */
.search-container {
    position: relative;
    width: 300px;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 6px 12px;
    transition: all 0.3s;
}

.search-box:focus-within {
    border-color: var(--accent-blue);
    background: rgba(0, 0, 0, 0.4);
}

.search-icon {
    color: var(--text-secondary);
    margin-right: 8px;
    font-size: 0.9rem;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
    font-size: 0.9rem;
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    overflow: hidden;
    z-index: 1000;
}

.search-dropdown.hidden {
    display: none;
}

.search-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.2s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.search-symbol {
    font-weight: bold;
    color: var(--accent-blue);
}

.search-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.search-price {
    font-size: 0.9rem;
    font-weight: bold;
}


/* Dashboard Layout */
.dashboard-header-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1000px) {
    .dashboard-header-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.mini-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100px;
}

.mini-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.mini-card .value {
    font-size: 1.4rem;
    font-weight: bold;
}

.mini-card .change {
    font-size: 0.85rem;
}

.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-secondary { color: var(--text-secondary); }

/* Section Styles */
.section-title {
    font-size: 1.2rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sector-panel {
    padding: 16px;
    height: 100%;
}

.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stock-card {
    padding: 20px;
    transition: transform 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.stock-card:hover {
    transform: translateY(-4px);
    background: var(--card-hover);
}

.stock-badge {
    background: rgba(125, 125, 125, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.live-pulse {
    background: var(--accent-red);
    color: white;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    animation: pulse 2s infinite;
}

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

.info-chips {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.chip {
    background: rgba(125, 125, 125, 0.15);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.news-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.news-card {
    padding: 16px;
    border-left: 4px solid transparent;
}

.news-card.positive { border-left-color: var(--accent-green); }
.news-card.negative { border-left-color: var(--accent-red); }
.news-card.neutral { border-left-color: var(--text-secondary); }

.sentiment-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}
.sentiment-badge.positive { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.sentiment-badge.negative { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
.sentiment-badge.neutral { background: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }

/* Simulator & Charts */
.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
    margin-bottom: 24px;
    padding: 16px;
}

.quant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}

.metric-item {
    background: rgba(125, 125, 125, 0.1);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.metric-label { font-size: 0.8rem; color: var(--text-secondary); }
.metric-val { font-size: 1.1rem; font-weight: bold; }

/* Chatbot */
.chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

.chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: var(--accent-blue);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.5);
    transition: transform 0.2s;
}

.chat-fab:hover {
    transform: scale(1.1);
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    transform-origin: bottom right;
}

.chat-window.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.chat-header {
    padding: 16px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.chat-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--glass-bg);
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.bot {
    align-self: flex-start;
    background: rgba(125, 125, 125, 0.1);
    border-bottom-left-radius: 2px;
    color: var(--text-primary);
}

.message.user {
    align-self: flex-end;
    background: var(--accent-blue);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-input {
    padding: 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--glass-border);
    background: var(--glass-bg);
}

.chat-input input {
    flex: 1;
    background: rgba(125, 125, 125, 0.1);
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 20px;
    color: var(--text-primary);
    outline: none;
}

.chat-input button {
    background: var(--accent-blue);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
}

/* Beginner Mode */
.beginner-card {
    padding: 24px;
    margin-bottom: 20px;
}

.explanation-bubble {
    background: rgba(59, 130, 246, 0.15);
    border-left: 4px solid var(--accent-blue);
    padding: 16px;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
    color: var(--text-primary);
}

.progress-bar-container {
    height: 20px;
    background: rgba(125, 125, 125, 0.2);
    border-radius: 10px;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
}

.progress-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-primary);
    box-shadow: 0 0 5px var(--text-primary);
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 30px;
    border: 1px solid var(--glass-border);
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

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

/* Stock Detail View */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.detail-price {
    font-size: 3rem;
    font-weight: bold;
}

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 800px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.back-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.back-button:hover { color: var(--text-primary); }

.tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(125, 125, 125, 0.15);
    font-size: 0.8rem;
    margin-right: 5px;
    color: var(--text-secondary);
}

/* Settings Page */
.settings-container {
    max-width: 600px;
    margin: 0 auto;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--glass-border);
}

.setting-row:last-child { border-bottom: none; }

.toggle-switch {
    display: flex;
    gap: 10px;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 20px;
}

.toggle-btn {
    padding: 6px 16px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--accent-blue);
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}