/* ===== CSS Variables ===== */
:root {
    --sidebar-width: 320px;
    --topnav-height: 56px;
}

/* ===== Layout ===== */
.topnav {
    height: var(--topnav-height);
    background: rgba(13, 17, 23, 0.95);
    border-bottom: 1px solid rgba(48, 54, 61, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.main-layout {
    height: calc(100dvh - var(--topnav-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: rgba(13, 17, 23, 0.8);
}

.page-content {
    background: #0d1117;
}

/* ===== Logo ===== */
.logo-icon {
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
}

/* ===== Navigation Links ===== */
.nav-link {
    font-size: 0.85rem;
    color: #8B949E;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.15s ease;
    font-weight: 500;
}
.nav-link:hover {
    color: #E6EDF3;
    background: rgba(255,255,255,0.06);
}
.nav-link.active {
    color: #E6EDF3;
    background: rgba(59, 130, 246, 0.15);
}

/* ===== Panels & Cards ===== */
.panel {
    background: rgba(22, 27, 34, 0.85);
    border: 1px solid rgba(48, 54, 61, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.indicator-card {
    background: rgba(13, 17, 23, 0.6);
    border: 1px solid rgba(48, 54, 61, 0.6);
}

/* ===== Sidebar Search ===== */
.sidebar-search {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid rgba(48, 54, 61, 0.8);
    transition: border-color 0.2s ease;
}
.sidebar-search:focus-within {
    border-color: #3B82F6;
}

/* ===== Category Tabs ===== */
.cat-tab {
    color: #8B949E;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
    background: transparent;
    cursor: pointer;
}
.cat-tab:hover { color: #E6EDF3; background: rgba(255,255,255,0.02); }
.cat-tab.active {
    color: #3B82F6;
    border-bottom-color: #3B82F6;
    background: rgba(59, 130, 246, 0.05);
}

/* ===== Stock List Items ===== */
.stock-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-radius: 0.625rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    margin-bottom: 2px;
}
.stock-item:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
}
.stock-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.35);
}
.stock-item-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.stock-item-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #E6EDF3;
    line-height: 1.2;
}
.stock-item-ticker {
    font-size: 0.65rem;
    color: #8B949E;
    font-family: 'Courier New', monospace;
    margin-top: 1px;
}
.stock-item-price {
    font-size: 0.8rem;
    font-weight: 600;
    text-align: right;
    color: #E6EDF3;
}
.stock-item-change {
    font-size: 0.65rem;
    text-align: right;
    margin-top: 1px;
    font-weight: 500;
}
.stock-chg-up { color: #10B981; }
.stock-chg-dn { color: #EF4444; }

.fav-btn {
    color: #484F58;
    transition: color 0.2s;
    font-size: 0.8rem;
    padding: 2px 4px;
}
.fav-btn:hover { color: #F59E0B; }
.fav-btn.favorited { color: #F59E0B; }

/* ===== Loader ===== */
.loader {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3B82F6;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Custom Scrollbar ===== */
.custom-scroll::-webkit-scrollbar { width: 5px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb {
    background: rgba(139, 148, 158, 0.25);
    border-radius: 3px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 148, 158, 0.45);
}

/* ===== Chat Widget ===== */
.chat-bubble-ai {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(48, 54, 61, 0.8);
    color: #E6EDF3;
    padding: 0.6rem 0.8rem;
    border-radius: 0 0.8rem 0.8rem 0.8rem;
    max-width: 230px;
    line-height: 1.5;
}
.chat-bubble-user {
    background: rgba(59, 130, 246, 0.25);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #E6EDF3;
    padding: 0.6rem 0.8rem;
    border-radius: 0.8rem 0 0.8rem 0.8rem;
    max-width: 230px;
    line-height: 1.5;
}

/* ===== Chat Typing Indicator ===== */
.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 0.6rem; height: 32px; }
.typing-indicator span {
    width: 5px; height: 5px;
    background: #8B949E;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #30363D;
    transition: .3s;
    border-radius: 20px;
}
.toggle-slider:before {
    position: absolute; content: "";
    height: 16px; width: 16px;
    left: 2px; bottom: 2px;
    background-color: #8B949E;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .toggle-slider { background-color: #3B82F6; }
input:checked + .toggle-slider:before {
    background-color: #FFF;
    transform: translateX(20px);
}

/* ===== Settings Inputs ===== */
.settings-input {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid rgba(48, 54, 61, 0.8);
    color: #E6EDF3;
    transition: border-color 0.2s;
}
.settings-input:focus {
    outline: none;
    border-color: #3B82F6;
}

/* ===== Category Section Header ===== */
.cat-header {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8B949E;
    padding: 0.75rem 0.75rem 0.25rem;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.4s ease forwards; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root { --sidebar-width: 240px; }
    .sidebar { width: var(--sidebar-width); }
    .main-content { padding: 1rem; }
    #chatWidget { right: calc(var(--sidebar-width) + 8px) !important; }
}
@media (max-width: 640px) {
    .sidebar { display: none; /* Mobile view needs a toggle, hiding for simplicity in this demo */ }
    #chatWidget { right: 16px !important; }
}
