body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    background-color: #f8f9fa; /* Lighter background */
    color: #343a40; /* Darker text */
    line-height: 1.6;
}

header {
    background-color: #ffffff;
    padding: 1rem 2rem;
    border-bottom: 1px solid #dee2e6;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

header h1 {
    color: #0d6efd; /* Bootstrap blue */
    margin: 0;
    font-weight: 600;
    font-size: 1.8em;
}
header p {
    margin-top: 0.25rem;
    color: #6c757d; /* Gray text */
    font-size: 0.95em;
}

main {
    max-width: 1320px; /* Wider max-width */
    margin: 1.5em auto; /* Reduced top margin */
    padding: 0 1em;
}

/* --- Filter Controls Styling --- */
#filter-controls {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 0.8em; /* Space between filter elements */
    margin-bottom: 1.5em;
    padding: 1em;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    align-items: center; /* Align items vertically */
}

#filter-controls input[type="text"],
#filter-controls select {
    padding: 0.6em 0.8em; /* Slightly more padding */
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9em;
    box-sizing: border-box; /* Include padding in width/height */
}

#filter-controls input[type="text"] {
    flex-basis: 250px; /* Base width for search */
    flex-grow: 1;
}

#filter-controls select {
    flex-basis: 150px; /* Base width for selects */
    flex-grow: 1;
    cursor: pointer;
    background-color: #fff; /* Ensure white background */
}

#category-select {
     min-width: 180px;
     /* Override default multiselect appearance if needed, but size=1 helps */
     height: auto; /* Let browser determine height */
     min-height: 38px; /* Minimum height */
     overflow-y: auto; /* Add scroll if many options selected */
     /* For better multiselect UX, consider JS libraries later */
}

#filter-controls button#refresh-button {
    padding: 0.6em 0.8em;
    font-size: 1em; /* Use emoji size */
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    line-height: 1.2; /* Adjust line height for emoji */
}
#filter-controls button#refresh-button:hover {
    background-color: #dee2e6;
}

hr.filter-divider {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 1.5em 0; /* Adjusted margin */
}


/* --- News Grid Styling --- */
#news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5em;
}

.news-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column; /* Stack items vertically */
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.news-card:hover {
     box-shadow: 0 5px 15px rgba(0,0,0,0.12);
     transform: translateY(-3px);
}

.news-card img {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}
.news-card .caption { /* Target caption within card */
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 0.5em; /* Space below title */
    margin-bottom: auto; /* Push caption (and button below it) down */
    padding: 0 1em; /* Add padding */
}


/* Apply padding to a content div inside the card */
.card-content {
    padding: 0 1em 1em 1em; /* Padding for text/button */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Make content area fill available space */
}


.news-card h6 {
    font-size: 1.05em;
    font-weight: 600;
    margin-top: 0.8em; /* Space above title */
    margin-bottom: 0; /* Reset bottom margin */
    line-height: 1.35;
    /* Removed min-height, rely on flexbox */
}

.news-card button {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 0.7em 1em;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 1em; /* Add space above button */
    transition: background-color 0.2s ease;
    width: 100%;
    font-weight: 500;
    flex-shrink: 0; /* Prevent button from shrinking */
}

.news-card button:hover {
    background-color: #0b5ed7;
}

/* --- Article Detail Styling --- */
.view { display: none; }
.active-view { display: block; }

#article-detail {
    background-color: #fff;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 1200px;
    margin: 0 auto;
}

.article-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2em;
    margin-top: 2em;
}

.article-main {
    padding-right: 2em;
    border-right: 1px solid #dee2e6;
}

.article-sidebar {
    position: static; /* Remove sticky positioning */
    align-self: start;
    padding-right: 0.5em;
    /* Remove height and overflow properties */
}

.sidebar-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5em;
    margin-bottom: 1em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Remove all scrollbar styling since we don't need it anymore */
/* Delete or comment out these blocks:
.article-sidebar::-webkit-scrollbar {...}
.article-sidebar::-webkit-scrollbar-track {...}
.article-sidebar::-webkit-scrollbar-thumb {...}
.article-sidebar::-webkit-scrollbar-thumb:hover {...}
*/

.sidebar-section h2 {
    font-size: 1.2em;
    margin-top: 0;
    color: #0d6efd;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5em;
    margin-bottom: 1em;
}

#detail-title {
    font-size: 2.2em;
    line-height: 1.3;
    color: #212529;
    margin-bottom: 0.5em;
}

#detail-image {
    width: 100%;
    border-radius: 8px;
    margin: 1.5em 0;
}

#detail-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: #2c3e50;
}

#detail-timeline {
    position: relative;
    padding-left: 2em;
    margin-left: 1em;
}

/* Timeline vertical line */
#detail-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #dee2e6;
}

#detail-timeline div {
    position: relative;
    padding: 1em 1.2em;
    margin-bottom: 1.5em;
    background-color: #fff;
    border-radius: 6px;
    border-left: 3px solid #0d6efd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Timeline dots */
#detail-timeline div::before {
    content: '';
    position: absolute;
    left: -2.35em;
    top: 1.5em;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #0d6efd;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #0d6efd;
}

/* Timeline connector lines */
#detail-timeline div::after {
    content: '';
    position: absolute;
    left: -2em;
    top: 1.8em;
    width: 1em;
    height: 2px;
    background-color: #0d6efd;
}

/* Year label styling */
#detail-timeline div strong {
    display: block;
    color: #0d6efd;
    font-size: 1.1em;
    margin-bottom: 0.5em;
}

/* Event description styling */
#detail-timeline div p {
    margin: 0;
    color: #495057;
    line-height: 1.6;
}

#detail-glossary {
    padding-left: 0.5em;
}

#detail-timeline h6, #detail-glossary h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: #0d6efd;
}

#detail-timeline div, #detail-glossary div {
    margin-bottom: 1.2em;
}

#detail-timeline strong, #detail-glossary strong {
    font-weight: 600;
}

/* Style the link button container */
#detail-link-container { margin: 1.5em 0; }
/* Style the link button itself */
#detail-link-container a {
    display: inline-block;
    padding: 0.6em 1.2em;
    background-color: #198754; /* Green */
    color: white;
    text-decoration: none;
    border-radius: 5px;
    border: none;
    transition: background-color 0.2s ease;
}
#detail-link-container a:hover {
    background-color: #146c43;
}


hr { border: none; border-top: 1px solid #dee2e6; margin: 2em 0; }
hr.content-divider { margin: 1em 0; } /* More subtle divider */


/* --- Loading/Error Styling --- */
#loading-indicator, #error-message, #no-results-message {
     margin: 2em auto; /* Center horizontally */
     padding: 1em;
     max-width: 600px; /* Limit width */
     font-size: 1.05em;
     color: #6c757d;
     text-align: center;
     border-radius: 4px;
}
#error-message {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}
#no-results-message {
    background-color: #e9ecef;
    border: 1px solid #ced4da;
}

/* --- Footer --- */
footer { text-align: center; margin-top: 3em; padding: 1.5em; font-size: 0.85em; color: #6c757d; border-top: 1px solid #dee2e6; }

#back-button {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 0.6em 1.2em;
    font-size: 0.95em;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    margin-bottom: 1em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

#back-button:hover {
    background-color: #e9ecef;
    transform: translateX(-3px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

#back-button:active {
    transform: translateX(-1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Notification styling */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 1em 1.5em;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    border-left: 4px solid #28a745;
}

.notification.error {
    border-left: 4px solid #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Update refresh button styling */
#refresh-button {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 0.8em 1.2em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;  /* Prevent button size changes */
}

#refresh-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.8;
}

#refresh-button:hover:not(:disabled) {
    background-color: #0b5ed7;
    transform: translateY(-1px);
}

/* Read More Button Styling */
#read-more-container {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px solid #dee2e6;
    text-align: center;
}

.read-more-button {
    display: inline-block;
    padding: 0.8em 1.5em;
    background-color: #0d6efd;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.read-more-button:hover {
    background-color: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.read-more-button:active {
    transform: translateY(0);
}

/* Read More Section Styling */
.read-more-section {
    margin-top: 2.5em;
    padding-top: 1.5em;
    border-top: 1px solid #dee2e6;
    text-align: center;
}

.read-more-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 1em 2em;
    background-color: #0d6efd;
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.2);
}

.read-more-button:hover {
    background-color: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3);
    color: #ffffff;
    text-decoration: none;
}

.read-more-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.2);
}

#refresh-button {
    display: none;
}

/* ===========================================
   MOBILE RESPONSIVE STYLES
   =========================================== */

/* Large desktop (1200px and above) - maintain original desktop design */
@media screen and (min-width: 1200px) {
    /* Preserve all original desktop styles - no changes needed */
}

/* Medium desktop (1024px - 1199px) - minimal adjustments */
@media screen and (max-width: 1199px) and (min-width: 1025px) {
    /* Keep desktop layout intact, only minor spacing adjustments if needed */
    main {
        padding: 0 1.2em;
    }
}

/* Tablet and small desktop (768px - 1024px) */
@media screen and (max-width: 1024px) and (min-width: 769px) {
    main {
        padding: 0 1.5em;
    }
    
    .article-layout {
        grid-template-columns: 1fr 300px;
        gap: 1.5em;
    }
    
    .article-main {
        padding-right: 1.5em;
    }
    
    #detail-title {
        font-size: 2em;
    }
}

/* Tablet Portrait (768px and below) */
@media screen and (max-width: 768px) {
    header {
        padding: 1rem 1rem;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    header p {
        font-size: 0.9em;
    }
    
    main {
        margin: 1em auto;
        padding: 0 1em;
    }
    
    /* Stack filter controls vertically on tablet */
    #filter-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1em;
    }
    
    #filter-controls input[type="text"],
    #filter-controls select {
        width: 100%;
        flex-basis: auto;
    }
    
    #category-select {
        min-width: auto;
    }
    
    /* Adjust grid for smaller screens */
    #news-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.2em;
    }
    
    /* Stack article layout vertically */
    .article-layout {
        grid-template-columns: 1fr;
        gap: 1.5em;
    }
    
    .article-main {
        padding-right: 0;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 1.5em;
    }
    
    .article-sidebar {
        padding-right: 0;
    }
    
    #article-detail {
        padding: 1.5em;
    }
    
    #detail-title {
        font-size: 1.8em;
        line-height: 1.2;
    }
    
    #detail-content {
        font-size: 1.05em;
        line-height: 1.7;
    }
    
    /* Adjust timeline for smaller screens */
    #detail-timeline {
        padding-left: 1.5em;
        margin-left: 0.5em;
    }
    
    #detail-timeline div::before {
        left: -2em;
    }
    
    #detail-timeline div::after {
        left: -1.7em;
    }
    
    /* Adjust notification for tablet */
    .notification {
        bottom: 15px;
        right: 15px;
        left: 15px;
        padding: 0.8em 1.2em;
    }
}

/* Mobile Landscape (480px - 767px) */
@media screen and (max-width: 767px) and (orientation: landscape) {
    header {
        padding: 0.8rem 1rem;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    #news-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .news-card img {
        height: 150px;
    }
}

/* Mobile Portrait (480px and below) */
@media screen and (max-width: 480px) {
    header {
        padding: 1rem 0.8rem;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    header p {
        font-size: 0.85em;
    }
    
    main {
        padding: 0 0.8em;
        margin: 0.8em auto;
    }
    
    /* Mobile filter controls */
    #filter-controls {
        padding: 0.8em;
        margin-bottom: 1.2em;
        gap: 0.8em;
    }
    
    #filter-controls input[type="text"],
    #filter-controls select {
        padding: 0.7em;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    #refresh-button {
        min-width: auto;
        width: 100%;
        padding: 0.7em;
    }
    
    /* Single column grid for mobile */
    #news-grid {
        grid-template-columns: 1fr;
        gap: 1em;
    }
    
    .news-card {
        margin: 0 auto;
        max-width: 100%;
    }
    
    .news-card img {
        height: 180px;
    }
    
    .news-card h6 {
        font-size: 1em;
        margin-top: 0.6em;
    }
    
    .news-card button {
        padding: 0.8em;
        font-size: 0.95em;
    }
    
    /* Article detail mobile adjustments */
    #article-detail {
        padding: 1em;
        margin: 0;
        border-radius: 0;
    }
    
    #detail-title {
        font-size: 1.6em;
        line-height: 1.3;
        margin-bottom: 0.8em;
    }
    
    #detail-content {
        font-size: 1em;
        line-height: 1.6;
    }
    
    #detail-image {
        margin: 1em 0;
        border-radius: 4px;
    }
    
    /* Simplify timeline for mobile */
    #detail-timeline {
        padding-left: 1em;
        margin-left: 0;
    }
    
    #detail-timeline::before {
        left: 0.5em;
    }
    
    #detail-timeline div {
        padding: 0.8em 1em;
        margin-bottom: 1em;
        margin-left: 0.5em;
    }
    
    #detail-timeline div::before {
        left: -1.1em;
        width: 8px;
        height: 8px;
        top: 1.2em;
    }
    
    #detail-timeline div::after {
        left: -0.8em;
        width: 0.6em;
        top: 1.4em;
    }
    
    .sidebar-section {
        padding: 1em;
        margin-bottom: 0.8em;
    }
    
    .sidebar-section h2 {
        font-size: 1.1em;
    }
    
    /* Mobile buttons */
    #back-button {
        padding: 0.7em 1em;
        font-size: 0.9em;
        gap: 0.3em;
    }
    
    .read-more-button {
        padding: 0.8em 1.5em;
        font-size: 0.95em;
    }
    
    #detail-link-container a {
        padding: 0.7em 1em;
        font-size: 0.9em;
        display: block;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Mobile notifications */
    .notification {
        bottom: 10px;
        right: 10px;
        left: 10px;
        padding: 0.8em 1em;
        font-size: 0.9em;
    }
    
    /* Footer mobile */
    footer {
        margin-top: 2em;
        padding: 1em;
        font-size: 0.8em;
    }
    
    /* Hide hover effects on mobile */
    .news-card:hover {
        transform: none;
        box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    }
    
    #back-button:hover {
        transform: none;
    }
    
    .read-more-button:hover {
        transform: none;
    }
}

/* Extra small mobile (320px and below) */
@media screen and (max-width: 320px) {
    header h1 {
        font-size: 1.2em;
    }
    
    header p {
        font-size: 0.8em;
    }
    
    main {
        padding: 0 0.5em;
    }
    
    #filter-controls {
        padding: 0.6em;
    }
    
    .news-card img {
        height: 160px;
    }
    
    #detail-title {
        font-size: 1.4em;
    }
    
    #article-detail {
        padding: 0.8em;
    }
    
    .sidebar-section {
        padding: 0.8em;
    }
}

/* Landscape orientation adjustments for mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 0.5rem 1rem;
    }
    
    header h1 {
        font-size: 1.3em;
    }
    
    main {
        margin: 0.5em auto;
    }
    
    #filter-controls {
        padding: 0.6em;
        margin-bottom: 1em;
    }
    
    .news-card img {
        height: 120px;
    }
    
    #article-detail {
        padding: 1em;
    }
    
    .notification {
        bottom: 5px;
        right: 5px;
        left: auto;
        max-width: 300px;
    }
}

/* Print styles */
@media print {
    header, footer, #filter-controls, .news-card button, #back-button, .notification {
        display: none !important;
    }
    
    body {
        background-color: white;
        color: black;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .news-card, #article-detail {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
    
    #news-grid {
        grid-template-columns: 1fr;
        gap: 1em;
    }
    
    .article-layout {
        grid-template-columns: 1fr;
    }
    
    .article-main {
        border-right: none;
        padding-right: 0;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .news-card {
        border: 2px solid #000;
    }
    
    .news-card button {
        border: 2px solid #000;
    }
    
    #filter-controls input[type="text"],
    #filter-controls select {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .news-card:hover {
        transform: none;
    }
    
    #back-button:hover {
        transform: none;
    }
    
    .read-more-button:hover {
        transform: none;
    }
    
    .notification {
        animation: none;
    }
}

/* Keep all your existing CSS */
/* New styles for timeline cards inside article-main */
.main-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5em;
    margin-top: 2em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.main-section h2 {
    font-size: 1.2em;
    color: #0d6efd;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5em;
    margin-bottom: 1em;
}

/* Timeline inside main now */
#detail-timeline {
    position: relative;
    padding-left: 2em;
    margin-left: 1em;
}

#detail-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #dee2e6;
}

#detail-timeline div {
    position: relative;
    padding: 1em 1.2em;
    margin-bottom: 1.5em;
    background-color: #fff;
    border-radius: 6px;
    border-left: 3px solid #0d6efd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#detail-timeline div::before {
    content: '';
    position: absolute;
    left: -2.35em;
    top: 1.5em;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #0d6efd;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #0d6efd;
}

#detail-timeline div::after {
    content: '';
    position: absolute;
    left: -2em;
    top: 1.8em;
    width: 1em;
    height: 2px;
    background-color: #0d6efd;
}

#detail-timeline div strong {
    display: block;
    color: #0d6efd;
    font-size: 1.1em;
    margin-bottom: 0.5em;
}

#detail-timeline div p {
    margin: 0;
    color: #495057;
    line-height: 1.6;
}
