:root {
    --primary-purple: #667eea;
    --secondary-purple: #764ba2;
    --accent-green: #10b981;
    --bg-gradient: linear-gradient(135deg, var(--primary-purple) 0%, var(--secondary-purple) 100%);
    --card-bg: #ffffff;
    --card-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 40px 20px;
    color: #374151;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
    padding-top: 20px;
}

.header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Search Card */
.search-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 32px;
    transition: all 0.3s ease;
}

.search-card:hover {
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.search-form {
    display: flex;
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e5e7eb;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    font-family: inherit;
}

.search-input:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f9fafb;
    transform: translateX(2px);
}

.autocomplete-item .ticker-symbol {
    font-weight: 700;
    color: var(--primary-purple);
    font-size: 0.95rem;
}

.autocomplete-item .company-name {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 4px;
}

.search-btn {
    padding: 16px 32px;
    background: var(--accent-green);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
}

.search-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
    background: #0da271;
}

.search-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Ticker Display */
.ticker-display {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    padding: 15px 0;
    color: white;
    font-size: 1.1rem;
}

.ticker-symbol-main {
    font-size: 1.8rem;
    font-weight: 700;
    margin-right: 15px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.ticker-name-main {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Data Grid */
.data-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: 1fr;
}

.data-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    overflow: hidden;
}

.data-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 24px;
    background: #fcfcfc;
    border-bottom: 1px solid #f3f4f6;
    user-select: none;
    transition: all 0.3s ease;
}

.card-header:hover {
    background: #f5f5f5;
}

.card-header h2 {
    font-size: 1.3rem;
    color: var(--primary-purple);
    margin: 0;
    display: flex;
    align-items: center;
    font-weight: 700;
}

.card-header h2 span {
    margin-right: 12px;
    font-size: 1.6rem;
    line-height: 1;
}

.dropdown-icon {
    font-size: 1.4rem;
    color: var(--primary-purple);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-icon.collapsed {
    transform: rotate(0deg);
}

.dropdown-icon:not(.collapsed) {
    transform: rotate(180deg);
}

.card-content {
    padding: 0 24px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-content:not(.collapsed) {
    max-height: 2000px;
    opacity: 1;
    padding: 24px;
}

/* Table Styles */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 20px;
}

.data-table table {
    min-width: 600px;
    border-collapse: collapse;
    width: 100%;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.data-table th {
    font-weight: 700;
    background: #f9fafb;
    color: var(--primary-purple);
    font-size: 0.95rem;
}

.data-table tr:nth-child(even) {
    background-color: #fcfcfc;
}

.data-table tr:hover {
    background-color: #f8fafc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* RSI Grid */
.rsi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 16px;
    padding-top: 15px;
}

.rsi-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background-color: #f9fafb;
    transition: all 0.2s ease;
}

.rsi-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.rsi-item strong {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 6px;
    font-weight: 600;
}

.rsi-item .rsi-value {
    padding: 6px 10px;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
}

/* Data Colors */
.data-table td.positive-hist {
    color: var(--accent-green);
    font-weight: 700;
}

.data-table td.negative-hist {
    color: #ef4444;
    font-weight: 700;
}

/* Analysis Content */
.analysis-content {
    color: #374151;
    line-height: 1.7;
    font-size: 1rem;
}

.analysis-content h3 {
    color: var(--secondary-purple);
    font-size: 1.3rem;
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 700;
}

.analysis-content h3:first-child {
    margin-top: 0;
}

.analysis-content h4 {
    color: var(--primary-purple);
    font-size: 1.1rem;
    margin-top: 18px;
    margin-bottom: 10px;
    font-weight: 600;
}

.analysis-content strong {
    font-weight: 700;
    color: #1f2937;
}

.analysis-content p {
    margin-bottom: 18px;
}

.analysis-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

.analysis-content em {
    color: #6b7280;
    font-size: 0.9rem;
    font-style: italic;
}

.unavailable-notice {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 20px;
    border-radius: 8px;
    color: #92400e;
}

.unavailable-notice strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

/* Loading & Error States */
.loading {
    text-align: center;
    padding: 50px;
    color: white;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner {
    display: inline-block;
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error {
    background: #fee2e2;
    color: #dc2626;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    border-left: 4px solid #dc2626;
    display: none;
    font-weight: 500;
}

/* Sidebar Styles - FIXED */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 320px;
    background: var(--card-bg);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
}

.sidebar.sidebar-collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-gradient);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.sidebar-search {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.sidebar-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

.sidebar-search-input:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.sidebar-stocks {
    padding: 0;
}

.sidebar-stock-item {
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.sidebar-stock-item:hover {
    background: #f8fafc;
    transform: translateX(2px);
}

.sidebar-stock-item.active {
    background: #eef2ff;
    border-left: 4px solid var(--primary-purple);
    padding-left: 20px;
}

.sidebar-stock-symbol {
    font-weight: 700;
    color: var(--primary-purple);
    font-size: 1rem;
    margin-bottom: 4px;
}

.sidebar-stock-name {
    color: #6b7280;
    font-size: 0.85rem;
    line-height: 1.4;
}

.sidebar-stock-group {
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-group-header {
    padding: 16px 24px;
    background: #f8fafc;
    color: var(--primary-purple);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Main Content Adjustments - FIXED */
.main-content {
    margin-left: 320px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* Toggle Buttons */
.mobile-sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 999;
    background: var(--bg-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    display: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 1.3rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.mobile-sidebar-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.desktop-sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--bg-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 1.3rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: none;
}

.desktop-sidebar-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Chart Styles */
.chart-container {
    position: relative;
    height: 400px;
    margin: 20px 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    background: white;
}

.chart-title {
    text-align: center;
    color: var(--primary-purple);
    font-weight: 700;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin: 20px 0;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    padding: 24px;
    transition: all 0.3s ease;
}

.chart-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.chart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 15px;
}

.chart-tab {
    padding: 8px 16px;
    border: none;
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 600;
}

.chart-tab.active {
    background: var(--primary-purple);
    color: white;
}

.chart-tab:hover:not(.active) {
    background: #e5e7eb;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }

    .main-content {
        margin-left: 280px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 2.2rem;
    }

    .search-form {
        flex-direction: column;
    }

    .search-btn {
        width: 100%;
    }

    .ticker-display {
        flex-direction: column;
        text-align: center;
    }

    .ticker-symbol-main {
        margin-right: 0;
        margin-bottom: 12px;
    }

    /* Mobile Sidebar */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
    }

    .sidebar:not(.sidebar-collapsed) {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-sidebar-toggle {
        display: block;
    }

    .desktop-sidebar-toggle {
        display: none !important;
    }

    .sidebar-toggle {
        display: none;
    }

    .card-header {
        padding: 20px;
    }

    .card-content:not(.collapsed) {
        padding: 20px;
    }

    /* Responsive charts */
    .chart-container {
        height: 300px;
        padding: 15px;
    }

    .chart-card {
        padding: 16px;
    }
}

@media (min-width: 769px) {
    .sidebar-collapsed ~ .desktop-sidebar-toggle {
        display: block;
    }

    .mobile-sidebar-toggle {
        display: none !important;
    }

    .sidebar:not(.sidebar-collapsed) ~ .desktop-sidebar-toggle {
        left: 340px;
        display: block;
    }
}

@media (max-width: 480px) {
    body {
        padding: 15px 10px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .search-card {
        padding: 20px;
    }

    .card-header {
        padding: 16px 20px;
    }

    .card-content:not(.collapsed) {
        padding: 16px 20px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .rsi-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 12px;
    }

    .chart-container {
        height: 250px;
        padding: 10px;
    }
}

/* === STICK FOOTER TO BOTTOM & MAKE IT BLACK === */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

.container {
    flex: 1; /* takes remaining space so footer stays down */
}

footer {
    margin-top: auto; /* pushes footer to bottom */
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    font-size: 0.8rem;
    color: black; /* ⚡ black text */
    text-align: center;
    background: #fff; /* optional for clean look */
}
