:root {
    --bg-dark: #080b14;
    --bg-sidebar: #0f121d;
    --bg-card: #151926;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.2);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #262c40;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --sidebar-width: 260px;
    --header-height: 80px;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    color: var(--text-muted);
    text-decoration: none !important;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    background: radial-gradient(circle at 0% 0%, #1e293b 0%, var(--bg-dark) 50%);
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.top-bar {
    height: var(--header-height);
    padding: 0 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(8, 11, 20, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 900;
}

.page-container {
    padding: 2.5rem 3rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* Components */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.h-100 { height: 100% !important; }

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-buy { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.badge-sell { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.badge-hold { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    --bs-table-bg: transparent;
    color: var(--text-main);
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    background: transparent;
}

.table td {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    background: transparent;
}

/* Fix for table rows in dark mode bootstrap */
.table > :not(caption) > * > * {
    background-color: transparent !important;
    color: inherit;
    box-shadow: none !important;
}

/* Buttons */
.btn-primary-custom {
    background: var(--primary);
    color: white !important;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-primary-custom:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

/* Technical Indicators Readability */
.card .fw-extrabold.fs-6, 
.card .small.fw-bold {
    color: var(--text-main) !important;
}

/* Button Text Visibility */
.btn-outline-custom {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main) !important;
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none !important;
}

.btn-sm.btn-outline-custom {
    padding: 0.4rem 1rem;
    color: var(--text-main) !important;
}

.btn-outline-custom:hover {
    background: var(--border-color);
    color: white !important;
}

/* Search Dropdown Styles */
.search-container {
    position: relative;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 3000;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    display: none;
}

#searchDropdown a.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: var(--text-main) !important;
    text-decoration: none !important;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    background: transparent;
}

#searchDropdown a.search-result-item:last-child {
    border-bottom: none;
}

#searchDropdown a.search-result-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: white !important;
}

.search-result-item div {
    color: inherit;
}

.search-result-symbol {
    background: var(--primary);
    color: white !important;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.7rem;
    min-width: 75px;
    text-align: center;
    box-shadow: 0 4px 10px var(--primary-glow);
}

/* Force specific fix for View Analytics in Signals table */
.table .btn-outline-custom {
    color: var(--text-main) !important;
}

/* Charts */
.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Force dark mode for form elements */
.form-select, .form-control, .form-range {
    background-color: #0f121d !important;
    border-color: var(--border-color) !important;
    color: var(--text-main) !important;
}

.form-label, .form-check-label {
    color: var(--text-main) !important;
}

.form-select option {
    background-color: #0f121d;
    color: var(--text-main);
}

.form-check-input {
    background-color: #0f121d;
    border-color: var(--border-color);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Button overrides for unreadability/awkward shapes */
.btn-outline-custom {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination .page-link {
    background-color: transparent !important;
    border-color: var(--border-color) !important;
    color: var(--text-muted) !important;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}

/* Chart Container Overlap fix */
.stock-detail-chart-wrapper {
    position: relative;
    height: 500px;
    width: 100%;
    margin-bottom: 2rem;
}

/* Utilities */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Responsive */
@media (max-width: 1200px) {
    .app-container { grid-template-columns: 80px 1fr; }
    .sidebar-header span, .nav-item span, .user-info { display: none; }
    .nav-item { justify-content: center; padding: 1rem; }
    .sidebar-header { justify-content: center; }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .top-bar {
        padding: 0 1.5rem;
    }
    
    .page-container {
        padding: 1.5rem;
        padding-bottom: 100px; /* Space for bottom nav */
    }
    
    .search-container {
        width: 100% !important;
        max-width: none !important;
    }
    
    .kpi-card {
        padding: 1.5rem;
    }
    
    .kpi-value {
        font-size: 1.75rem;
    }
    
    h1.fw-extrabold {
        font-size: 1.75rem !important;
    }
    
    .stock-detail-chart-wrapper {
        height: 350px;
    }
}

/* Bottom Navigation */
.bottom-nav {
    display: none !important;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: rgba(15, 18, 29, 0.85);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        z-index: 2000;
        justify-content: space-around;
        align-items: center;
        padding: 0 1rem;
    }
    
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: var(--text-muted);
        text-decoration: none !important;
        transition: all 0.2s;
        flex: 1;
    }
    
    .bottom-nav-item i {
        font-size: 1.4rem;
        transition: transform 0.2s;
    }
    
    .bottom-nav-item span {
        font-size: 0.65rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    .bottom-nav-item.active {
        color: var(--primary);
    }
    
    .bottom-nav-item.active i {
        transform: translateY(-2px);
        color: var(--primary);
        text-shadow: 0 0 15px var(--primary-glow);
    }
    
    .bottom-nav-item:active i {
        transform: scale(0.9);
    }
}
