/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e40af;
    --secondary-color: #0f172a;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.logo p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.search-container {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
}

.search-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.search-btn:hover {
    background-color: var(--primary-color);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* API Selection Section */
.api-selection {
    margin-bottom: 3rem;
}

.api-selection h2 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.api-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.api-tile {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.api-tile:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-color);
}

.api-tile.selected {
    background: linear-gradient(135deg, #e0e7ff 0%, #f0f9ff 100%);
    border-color: var(--primary-color);
}

.api-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.api-tile h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.api-tile p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.features {
    list-style: none;
    margin: 1rem 0;
    text-align: left;
    font-size: 0.9rem;
}

.features li {
    color: var(--text-secondary);
    padding: 0.3rem 0;
}

.select-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: auto;
    transition: background-color 0.3s;
}

.select-btn:hover {
    background-color: var(--secondary-color);
}

/* Data Section */
.data-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-controls h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
}

.back-btn {
    padding: 0.6rem 1.2rem;
    background-color: var(--border-color);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.back-btn:hover {
    background-color: var(--accent-color);
    color: white;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    position: relative;
    transition: color 0.3s;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--light-bg) 0%, #f1f5f9 100%);
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid var(--accent-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* Chart Container */
.chart-container {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    min-height: 400px;
}

.chart-container h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Indicator Selector */
.indicator-selector {
    margin-bottom: 2rem;
}

.indicator-selector h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.indicator-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.indicator-btn {
    padding: 0.6rem 1.2rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.indicator-btn:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

.indicator-btn.active {
    background-color: var(--primary-color);
}

/* Analysis Results */
.analysis-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.analysis-card {
    background: linear-gradient(135deg, var(--light-bg) 0%, #f1f5f9 100%);
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid var(--success-color);
}

.analysis-card h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.analysis-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

/* Fundamentals Grid */
.fundamentals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.fundamental-card {
    background: linear-gradient(135deg, var(--light-bg) 0%, #f1f5f9 100%);
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid var(--accent-color);
}

.fundamental-card h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.fundamental-card p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.fundamental-card span {
    color: var(--primary-color);
    font-weight: 600;
}

/* News List */
.news-list {
    display: grid;
    gap: 1.5rem;
}

.news-item {
    background: linear-gradient(135deg, var(--light-bg) 0%, #f1f5f9 100%);
    border-radius: 8px;
    padding: 1.5rem;
    border-left: 4px solid var(--warning-color);
}

.news-item h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.news-item p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.news-item a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.news-item a:hover {
    text-decoration: underline;
}

.news-date {
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Spinner */
.spinner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.spinner-border {
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Error Message */
.error-message {
    background-color: #fee;
    border: 2px solid var(--danger-color);
    border-radius: 8px;
    padding: 1.5rem;
    color: var(--danger-color);
    margin-bottom: 2rem;
    font-weight: 600;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem;
    margin-top: 3rem;
    text-align: center;
}

.footer p {
    margin: 0.5rem 0;
}

.footer a {
    color: #93c5fd;
    text-decoration: none;
    font-weight: 600;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .navbar-container {
        flex-direction: column;
        gap: 1rem;
    }

    .search-container {
        max-width: 100%;
    }

    .api-tiles {
        grid-template-columns: 1fr;
    }

    .header-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabs {
        overflow-x: auto;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }

    .chart-container {
        min-height: 300px;
    }
}
