/* Basic Reset and Font Setup */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #202124;
    color: #e8eaed;
    line-height: 1.5;
    font-size: 14px;
    display: flex;
    flex-direction: column; /* Changed to column for top nav */
}

/* Top Navigation Bar */
.top-nav {
    background-color: #303134;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3c3c3f;
}

.top-nav .brand {
    font-size: 1.2rem;
    font-weight: 600;
    color: #4CB5F9;
}

.top-nav .search-container {
    flex-grow: 1;
    max-width: 600px;
    margin: 0 20px;
}

.top-nav .search-bar {
    width: 100%;
    padding: 8px 16px;
    background-color: #3c3c3f;
    border: none;
    border-radius: 4px;
    color: #e8eaed;
    font-family: 'Inter', sans-serif;
}

.top-nav .search-bar:focus {
    outline: 1px solid #4CB5F9;
}

.top-nav .profile-button {
    background-color: transparent;
    color: #e8eaed;
    border: 1px solid #4CB5F9;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.top-nav .profile-button:hover {
    background-color: rgba(76, 181, 249, 0.1);
}

/* Dashboard Container */
.dashboard-container {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 20px;
    padding: 20px;
    width: 100%;
    height: calc(100vh - 61px); /* Subtract top nav height */
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #202124;
    padding: 10px 5px 10px 10px;
    overflow-y: auto;
    height: 100%;
    scrollbar-width: thin;
    scrollbar-color: #5f6368 #202124;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: #202124;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: #5f6368;
    border-radius: 4px;
}

.sidebar h2 {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9aa0a6;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 8px;
    position: sticky;
    top: -10px;
    background: #202124;
    z-index: 1;
    padding-top: 10px;
    padding-bottom: 5px;
}

/* Card Base Styling */
.card {
    background-color: #303134;
    border: 1px solid #3c3c3f;
    border-radius: 8px;
    padding: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease;
    min-height: 0; /* Prevent cards from growing beyond available space */
}

/* Apply row layout to cards *not* in highlight or wide sections */
.sidebar .card,
#my-interests-vertical .card,
#my-interests-row .card {
    flex-direction: row;
    align-items: flex-start; /* Align items to the top */
    padding: 12px; /* Adjust padding for row layout */
    max-height: 110px; /* Set maximum height for row-oriented cards */
}

.card:hover {
    border-color: #4CB5F9;
}

/* Card Content Styling */
.card-image-container {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    flex-shrink: 0; /* Prevent image container from shrinking */
}

.card-image-container.large {
    height: 180px; /* Reduce height slightly */
    width: 100%; /* Ensure large image takes full width */
    margin-bottom: 12px; /* Reduce margin for more content space */
}

.card-image-container.small {
    height: 60px; /* Reduce height slightly */
    width: 60px; /* Reduce width slightly */
    margin-left: 10px;
    order: 1; /* Make image appear on the right */
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #3c3c3f;
    display: block;
}

.card-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
    overflow: hidden; /* Prevent content overflow */
    justify-content: space-between; /* Distribute content evenly */
    height: 100%; /* Make content use full height of card */
}

.card-title {
    font-size: 1.0em;
    font-weight: 500;
    margin-bottom: 6px; /* Reduce margin */
    color: #4CB5F9;
    display: block;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
}

.card-description {
    font-size: 0.9em;
    color: #bdc1c6;
    margin-bottom: 8px; /* Reduce margin */
    line-height: 1.4;
    flex-grow: 0; /* Don't let description push metadata out of view */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
}

.card-metadata {
    font-size: 0.8em;
    color: #9aa0a6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* Push to bottom of flex container */
    padding-top: 8px; /* Reduce padding */
    border-top: 1px solid #3c3c3f;
    min-height: 25px; /* Ensure minimum height */
}

/* Row cards specific adjustments */
.sidebar .card .card-content,
#my-interests-vertical .card .card-content,
#my-interests-row .card .card-content {
    max-height: 85px; /* Control height of content in row cards */
    display: flex;
    flex-direction: column;
}

/* Ensure metadata is always visible */
.sidebar .card .card-metadata,
#my-interests-vertical .card .card-metadata,
#my-interests-row .card .card-metadata {
    position: relative; /* Make sure it's in the normal flow */
    bottom: 0;
    width: 100%;
}

.card-source {
    font-weight: 500;
    color: #bdc1c6;
}

.card-source a {
    color: #bdc1c6;
    text-decoration: none;
}

.card-source a:hover {
    color: #4CB5F9;
}

.card-timestamp {
    white-space: nowrap;
}

/* Main Content Area */
.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: minmax(0, 2fr) auto minmax(0, 1.5fr);
    gap: 20px;
    grid-template-areas:
        "highlight interest-vertical"
        "interest-row interest-vertical"
        "interest-wide interest-wide";
    height: 100%;
    overflow: hidden;
}

/* News Sections */
.news-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding: 10px;
    height: 100%;
    scrollbar-width: thin;
    scrollbar-color: #5f6368 #303134;
}

.news-section::-webkit-scrollbar {
    width: 4px;
}

.news-section::-webkit-scrollbar-track {
    background: #303134;
}

.news-section::-webkit-scrollbar-thumb {
    background-color: #5f6368;
    border-radius: 4px;
}

/* Grid areas */
.highlighted-story { grid-area: highlight; }
.my-interests-vertical { grid-area: interest-vertical; }
.my-interests-row-container { grid-area: interest-row; }
.my-interests-wide { grid-area: interest-wide; }

/* Section Titles */
.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9aa0a6;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 5px 0;
    position: sticky;
    top: -10px;
    z-index: 1;
    background: transparent;
}

.news-section.has-title {
    padding-top: 0;
}

/* Highlighted Story */
.highlighted-story .card {
    flex-grow: 1;
}

.highlighted-story .card-title {
    font-size: 1.4em;
    color: #4CB5F9;
}

.highlighted-story .card-description {
    font-size: 1em;
    color: #e8eaed;
}

/* Row of My Interests */
.my-interests-row-container {
    padding: 10px 0 10px 0;
}

.my-interests-row-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: stretch;
}

.my-interests-row-grid .card {
    margin-bottom: 0;
    height: 100%;
}

.my-interests-row-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9aa0a6;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 10px;
    background: transparent;
}

/* Loading State */
.loading-placeholder {
    background: linear-gradient(90deg, #303134 25%, #3c3c3f 50%, #303134 75%);
    background-size: 200% 100%;
    animation: loading-pulse 1.5s infinite;
    border-radius: 4px;
    height: 1em;
    margin-bottom: 0.5em;
}

.loading-placeholder.title {
    width: 80%;
    height: 1.2em;
}

.loading-placeholder.desc-1 {
    width: 90%;
}

.loading-placeholder.desc-2 {
    width: 75%;
}

.loading-placeholder.source {
    width: 40%;
    margin-top: auto;
}

@keyframes loading-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .dashboard-container {
        grid-template-columns: 240px 1fr 240px;
        padding: 16px;
        gap: 16px;
    }
    
    .main-content {
        gap: 16px;
    }
    
    .my-interests-row-grid {
        gap: 12px;
    }
    
    .card {
        padding: 14px;
    }
}

@media (max-width: 992px) {
    .top-nav {
        padding: 10px 16px;
    }
    
    .top-nav .search-container {
        max-width: 400px;
        margin: 0 16px;
    }
    
    .dashboard-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
        overflow-y: auto;
        padding: 12px;
        gap: 16px;
    }
    
    .sidebar {
        height: auto;
        max-height: 40vh;
        order: 2;
    }
    
    .left-sidebar { order: 2; }
    .right-sidebar { order: 3; }

    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        grid-template-areas:
            "highlight"
            "interest-vertical"
            "interest-row"
            "interest-wide";
        height: auto;
        order: 1;
        overflow: visible;
    }
    
    .news-section {
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .my-interests-row-container {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .my-interests-row-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        align-items: stretch;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    .top-nav {
        flex-wrap: wrap;
        padding: 8px 12px;
    }
    
    .top-nav .search-container {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin: 8px 0 0 0;
    }
    
    .dashboard-container {
        height: calc(100vh - 95px); /* Adjust for taller nav on mobile */
        padding: 10px;
        gap: 12px;
    }
    
    .sidebar {
        max-height: 35vh;
    }
    
    h2, .section-title, .my-interests-row-title {
        font-size: 0.75rem;
    }
    
    .card-title { font-size: 0.95em; }
    .highlighted-story .card-title { font-size: 1.2em; }
    .card-description { font-size: 0.85em; }
    .highlighted-story .card-description { font-size: 0.95em; }
    
    .my-interests-row-grid {
        grid-template-columns: 1fr;
    }
    
    .card-image-container.small {
        height: 70px;
        width: 70px;
    }
} 