:root {
    --bg: #0b0f19;
    --glass-bg: rgba(20, 25, 40, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --green: #10b981;
    --red: #ef4444;
    --font: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text-main);
    background-image: radial-gradient(ellipse at top left, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
                      radial-gradient(ellipse at bottom right, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    background-size: cover;
    background-attachment: fixed;
    height: 100vh;
    overflow: hidden;
}

.layout { display: flex; height: 100vh; }

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.brand h1 {
    font-size: 28px;
    margin: 0;
    font-weight: 700;
}
.brand .highlight { color: var(--primary); }
.brand p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.search-box { margin-top: 24px; }
.search-box input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font);
    outline: none;
    transition: all 0.3s;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }

.companies-list {
    margin-top: 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

.companies-list::-webkit-scrollbar { width: 6px; }
.companies-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }

.company-item {
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.company-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border);
}
.company-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
}
.company-item .symbol { font-weight: 600; font-size: 16px; }
.company-item .name { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.stock-info h2 { margin: 0; font-size: 32px; font-weight: 700; }
.price-badge { font-size: 24px; font-weight: 600; color: var(--green); margin-top: 8px; }

.controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.glass-select {
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
}
.glass-select option { background: var(--bg); color: var(--text-main); }

.period-filters { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.05); padding: 4px; border-radius: 8px; }
.filter-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    color: var(--text-muted);
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}
.filter-btn:hover { color: var(--text-main); }
.filter-btn.active { background: var(--primary); color: white; box-shadow: 0 0 10px var(--primary-glow); }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.metric-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.metric-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.metric-card h3 { margin: 8px 0 0 0; font-size: 24px; font-weight: 600; }

.chart-container {
    flex: 1;
    padding: 24px;
    position: relative;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;}
.chart-header h3 { margin: 0; font-weight: 600; }

.predict-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    border: none;
    padding: 10px 20px;
    color: white;
    font-family: var(--font);
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}
.predict-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6); }

canvas#stockChart {
    width: 100% !important;
    height: 100% !important;
    flex: 1;
}

.compare-stats { padding: 24px; margin-top: auto; }
.compare-stats h4 { margin: 0 0 8px 0; }
.compare-stats p { margin: 0; }
.hintText { color: var(--text-muted); display: block; margin-top: 4px; }

/* Utilities */
.loading-spinner {
    width: 24px; height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.sidebar-spinner { margin: 40px auto; }
.loading-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 15, 25, 0.6);
    backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center;
    border-radius: 12px;
    z-index: 10;
}

.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--glass-bg); backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 16px 24px; border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateY(100px); opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.toast.show { transform: translateY(0); opacity: 1; }
