:root {
    --bg-color: #191724;
    --surface-color: #1f1d2e;
    --text-color: #e0def4;
    --muted-color: #908caa;
    --primary-color: #c4a7e7;
    --secondary-color: #eb6f92;
    --accent-color: #9ccfd8;
    --border-color: #44415a;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.app-header .subtitle {
    color: var(--muted-color);
    font-size: 1.1rem;
}

/* Main Layout */
/* .main-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    height: 100vh;
} */

.main-content {
    display: flex;
    gap: 2rem;

    /* REMOVED: align-items: flex-start (This prevents them from matching heights) */

    /* CHANGED: 100vh - 200px accounts for the Header space so the bottom doesn't cut off */
    height: calc(100vh - 200px);
    min-height: 500px;
}

.left-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.right-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Ensures the scrollbar stays inside the list area */
}

/* Form Controls */
.controls-form {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-group {
    display: flex;
    gap: 0.5rem;
}

input[type="text"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--primary-color);
}

.search-group input {
    flex: 1;
}

.btn-search {
    padding: 0 1.5rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-search:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.category-wrapper label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--muted-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-scrape {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary-color);
    color: #191724;
    /* Dark text on light button */
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-scrape:hover {
    opacity: 0.9;
}

/* Results & Stats */
.result {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-out;
}

.message {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-box {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--muted-color);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.overall-sentiment.sentiment-positive {
    color: var(--accent-color);
}

.overall-sentiment.sentiment-negative {
    color: var(--secondary-color);
}

.overall-sentiment.sentiment-neutral {
    color: var(--muted-color);
}

/* Headlines (Right Section) */
.top5-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.top5-wrapper h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.headlines-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    /* Enables scrolling */
    flex: 1;
    /* Fills the remaining height */
    padding-right: 8px;
    /* Adds space so scrollbar doesn't cover text */
}

.headline-item {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    transform-origin: center;
    margin: 11px;
}

.headline-item:hover {
    transform: scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.headline-details {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease-out;
}

.headline-item:hover .headline-details {
    display: block;
}

.headline-image-container {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
}

.headline-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 250px;
}

.headline-text {
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.read-more {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.read-more:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.headline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted-color);
}

.headline-rank {
    font-weight: 700;
    color: var(--primary-color);
}

.headline-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.headline-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.sentiment-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sentiment-badge.sentiment-positive {
    background-color: rgba(13, 240, 115, 0.521);
    color: var(--accent-color);
}

.sentiment-badge.sentiment-negative {
    background-color: rgba(250, 0, 71, 0.87);
    color: var(--secondary-color);
}

.sentiment-badge.sentiment-neutral {
    background-color: rgba(144, 140, 170, 0.15);
    color: var(--muted-color);
}

.sentiment-score {
    color: var(--muted-color);
    font-family: monospace;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        height: auto;
    }

    .headlines-list {
        height: 60vh;
        min-height: 450px;
    }

    .app-header h1 {
        font-size: 2rem;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.foot {
    border-radius: 10px;
    /* padding: 10px 200px 10px 200px; */
    margin-top: 60px;
    text-align: center;
    /* background-color: var(--surface-color); */
    color: #908caa;
}

.foot p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted-color);
}

.foot a {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 10px;
}

.foot a:hover {
    text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(25, 23, 36, 0.9);
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.loading-bar-container {
    width: 300px;
    height: 6px;
    background-color: var(--surface-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.loading-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    animation: loading 2s infinite ease-in-out;
    border-radius: 3px;
}

.loading-overlay p {
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

@keyframes loading {
    0% {
        width: 0%;
        margin-left: 0;
    }

    50% {
        width: 100%;
        margin-left: 0;
    }

    100% {
        width: 0%;
        margin-left: 100%;
    }
}