:root {
    --primary-color: #2563eb;
    --secondary-color: #3b82f6;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    background-color: var(--background-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #1e40af;
    color: #ffffff;
    padding: 8px 16px;
    z-index: 1100;
    text-decoration: none;
    border-radius: 0 0 6px 0;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    color: #ffffff;
    text-decoration: none;
}

#main-content:focus {
    outline: none;
}

.kbanner {
    background: linear-gradient(120deg, #4284fb, #3c5fec);
    overflow: visible;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.kbanner .navbar {
    background: transparent !important;
    padding: 0.85rem 1.5rem;
    overflow: visible;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
    text-decoration: none;
}

.navbar-brand:hover {
    text-decoration: none;
}

.kbanner .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    transition: color 0.2s ease;
}

.kbanner .navbar-nav .nav-link:hover,
.kbanner .navbar-nav .nav-link:focus {
    color: #ffffff;
}

.dropdown-menu {
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 8px 0;
}

.dropdown-item {
    padding: 10px 20px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #f0f4ff;
    color: #3c5fec;
}

@media (max-width: 991px) {
    .navbar-collapse {
        background: linear-gradient(135deg, #4a7ce8 0%, #3c5fec 100%);
        border-radius: 0 0 12px 12px;
        margin-top: 10px;
        padding: 10px 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .kbanner .navbar-nav {
        padding: 0 10px;
    }

    .kbanner .navbar-nav .nav-item {
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    .kbanner .navbar-nav .nav-item:last-child {
        border-bottom: none;
    }

    .navbar-nav .dropdown-menu {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0 0 10px 20px;
        margin: 0;
    }

    .navbar-nav .dropdown-item {
        color: rgba(255, 255, 255, 0.9);
        padding: 10px 16px;
        border-radius: 6px;
        font-size: 14px;
    }

    .navbar-nav .dropdown-item:hover,
    .navbar-nav .dropdown-item:focus {
        background-color: rgba(255, 255, 255, 0.12);
        color: #ffffff;
    }
}

.search-section {
    background: var(--card-background);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.page-title {
    color: var(--primary-color);
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.page-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0;
}

.search-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

#search-input {
    border-radius: var(--border-radius);
    padding: 0.875rem 1rem;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    font-size: 0.875rem;
    line-height: 1.4;
    transition: var(--transition);
    flex: 1;
    min-width: 200px;
    min-height: 48px;
}

#timeline-dropdown {
    border-radius: var(--border-radius);
    padding: 0.875rem 1rem;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    font-size: 0.875rem;
    line-height: 1.4;
    transition: var(--transition);
    flex: 0 0 auto;
    width: auto;
    min-width: 160px;
    min-height: 48px;
    cursor: pointer;
}

#search-input:focus,
#timeline-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.news-item {
    background: var(--card-background);
    border: none;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: var(--transition);
    position: relative;
    border-left: 4px solid var(--primary-color);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1rem;
    row-gap: 0.5rem;
    align-items: start;
}

.news-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.news-item h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0;
    grid-column: 1;
    grid-row: 1;
}

.news-item h3 a {
    color: inherit;
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.3s ease, color 0.2s ease;
}

.news-item:hover h3 a,
.news-item:focus-within h3 a {
    color: var(--primary-color);
    background-size: 100% 1px;
}

.news-item h3 a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: var(--border-radius);
}

.news-item h3 a:focus-visible {
    outline: none;
}

.news-item:has(h3 a:focus-visible) {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.news-source {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 0.6rem;
    position: relative;
    z-index: 2;
}

.news-source::before {
    content: '·';
    margin-right: 0.35rem;
    opacity: 0.6;
}

.news-source i {
    opacity: 0.7;
}

.news-summary,
.news-date {
    position: relative;
    z-index: 2;
}

.news-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.results-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.results-strip strong {
    color: var(--text-primary);
    font-weight: 600;
}

.results-strip .results-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.results-strip .filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.results-strip .btn-refresh {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: var(--text-secondary);
    padding: 0.35rem 0.85rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 36px;
}

.results-strip .btn-refresh:hover,
.results-strip .btn-refresh:focus-visible {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.empty-state,
.error-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.empty-state i,
.error-state i {
    font-size: 2.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: block;
}

.error-state i {
    color: #dc2626;
}

.empty-state h3,
.error-state h3 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding-right: 0;
}

.empty-state p,
.error-state p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.empty-state .btn,
.error-state .btn {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
}

.empty-state .btn:hover,
.error-state .btn:hover,
.empty-state .btn:focus-visible,
.error-state .btn:focus-visible {
    background: var(--secondary-color);
}

.news-date {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    background: #f1f5f9;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.news-date .relative-time {
    color: var(--primary-color);
    font-weight: 600;
}

.news-summary {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.7;
    grid-column: 1 / -1;
    grid-row: 2;
}

.news-cta {
    grid-column: 1 / -1;
    grid-row: 3;
}

.news-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.news-link:hover {
    color: var(--secondary-color);
    text-decoration: none;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem;
}

.pagination-controls button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
    min-width: 120px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.pagination-controls button:disabled {
    background: #94a3b8;
    color: #f8fafc;
    cursor: not-allowed;
}

.pagination-controls button:not(:disabled):hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

#page-info {
    font-weight: 500;
    color: #475569;
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    border-radius: var(--border-radius);
}

.loading-spinner {
    display: none;
    justify-content: center;
    padding: 2rem;
}

.loading-spinner.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .search-section {
        padding: 1.5rem;
    }

    .news-item {
        padding: 1.25rem;
        grid-template-columns: 1fr;
    }

    .news-date {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    .news-item h3 {
        grid-column: 1;
        grid-row: 2;
        font-size: 1.1rem;
    }

    .news-summary {
        grid-row: 3;
    }

    .news-cta {
        grid-row: 4;
    }
}

@media (max-width: 480px) {
    .pagination-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #page-info {
        order: -1;
        flex-basis: 100%;
        text-align: center;
    }

    .pagination-controls button {
        flex: 1;
        min-width: 0;
        padding: 0.65rem 0.85rem;
    }

    .pag-text {
        display: none;
    }
}

[data-theme="dark"] {
    --background-color: #0f172a;
    --card-background: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
}

[data-theme="dark"] .kbanner,
[data-theme="dark"] .kbanner.bg-primary {
    background: #0e0f19 !important;
    border-bottom: 1px solid #2a2d40;
}

[data-theme="dark"] .dropdown-menu {
    background-color: #1e2340;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .dropdown-item {
    color: #e1e1e1;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: #2a305c;
    color: #ffffff;
}

[data-theme="dark"] body {
    background-color: var(--background-color);
    color: var(--text-primary);
}

[data-theme="dark"] .search-section {
    background: var(--card-background);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] #search-input,
[data-theme="dark"] #timeline-dropdown {
    background-color: #0f172a;
    border-color: #334155;
    color: var(--text-primary);
}

[data-theme="dark"] #search-input::placeholder {
    color: #64748b;
}

[data-theme="dark"] #search-input:focus,
[data-theme="dark"] #timeline-dropdown:focus {
    border-color: #5dade2;
    box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.2);
}

[data-theme="dark"] .news-item {
    background: var(--card-background);
    border-left-color: #5dade2;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .news-item h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .news-summary {
    color: #cbd5e1;
}

[data-theme="dark"] .news-date {
    background: #0f172a;
    color: var(--text-secondary);
}

[data-theme="dark"] .news-date .relative-time {
    color: #5dade2;
}

[data-theme="dark"] .news-link {
    color: #5dade2;
}

[data-theme="dark"] .news-link:hover {
    color: #93c5fd;
}

[data-theme="dark"] #page-info {
    background: #1e293b;
    color: var(--text-secondary);
}

[data-theme="dark"] .pagination-controls button {
    background: #1d4ed8;
}

[data-theme="dark"] .pagination-controls button:disabled {
    background: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .pagination-controls button:not(:disabled):hover {
    background: #2563eb;
}

[data-theme="dark"] .spinner {
    border-color: #334155;
    border-top-color: #5dade2;
}

[data-theme="dark"] .page-title {
    color: #5dade2;
}

[data-theme="dark"] .results-strip {
    background: var(--card-background);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .results-strip .filter-pill {
    background: rgba(93, 173, 226, 0.15);
    color: #93c5fd;
}

[data-theme="dark"] .results-strip .btn-refresh {
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .results-strip .btn-refresh:hover,
[data-theme="dark"] .results-strip .btn-refresh:focus-visible {
    background: #0f172a;
    color: #5dade2;
    border-color: #5dade2;
}

[data-theme="dark"] .news-source {
    color: #94a3b8;
}

[data-theme="dark"] .news-cta {
    color: #5dade2;
}

[data-theme="dark"] .news-item:hover h3 a,
[data-theme="dark"] .news-item:focus-within h3 a {
    color: #5dade2;
}

[data-theme="dark"] .news-item:has(h3 a:focus-visible) {
    outline-color: #5dade2;
}

[data-theme="dark"] .empty-state,
[data-theme="dark"] .error-state {
    background: var(--card-background);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .empty-state h3,
[data-theme="dark"] .error-state h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .empty-state p,
[data-theme="dark"] .error-state p {
    color: var(--text-secondary);
}

[data-theme="dark"] .empty-state .btn,
[data-theme="dark"] .error-state .btn {
    background: #1d4ed8;
}

[data-theme="dark"] .empty-state .btn:hover,
[data-theme="dark"] .error-state .btn:hover {
    background: #2563eb;
}

.footer {
    background-color: #ffffff;
    padding: 40px 0 20px;
    margin-top: 40px;
    border-top: 1px solid #ebedef;
}

.footer p {
    color: #666;
    font-size: 14px;
}

.footer p a {
    color: #3c5fec;
    text-decoration: none;
}

.footer p a:hover {
    text-decoration: underline;
}

.footer-columns {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 20px;
}

.footer-group {
    flex: 1;
    min-width: 150px;
}

.footer-group h6 {
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    font-size: 14px;
}

.footer-group a.footer-link {
    display: block;
    color: #666;
    text-decoration: none;
    margin-bottom: 8px;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-group a.footer-link:hover {
    color: #3c5fec;
}

.footer-group a.footer-link i {
    margin-right: 6px;
    width: 16px;
}

[data-theme="dark"] .footer {
    background-color: var(--dark-bg-color, #1a1f3c);
    border-top-color: #2a305c;
}

[data-theme="dark"] .footer p {
    color: #8f96b3;
}

[data-theme="dark"] .footer p a {
    color: #6daae0;
}

[data-theme="dark"] .footer-group h6 {
    color: #e1e1e1;
}

[data-theme="dark"] .footer-group a.footer-link {
    color: #8f96b3;
}

[data-theme="dark"] .footer-group a.footer-link:hover {
    color: #fff;
}

[data-theme="dark"] .footer .custom-control-label {
    color: #8f96b3;
}

@media (max-width: 768px) {
    .footer-columns {
        flex-direction: column;
        gap: 0;
    }

    .footer-group {
        border-bottom: 1px solid #e0e4e8;
        text-align: left;
    }

    .footer-group:last-child {
        border-bottom: none;
    }

    .footer-group h6 {
        cursor: pointer;
        padding: 16px 20px;
        margin: 0 !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 15px;
    }

    .footer-group h6::after {
        content: '+';
        font-size: 18px;
        font-weight: 400;
        color: #666;
        transition: transform 0.3s ease;
    }

    .footer-group.active h6::after {
        content: '−';
    }

    .footer-group .footer-links-wrapper {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        padding: 0 20px;
    }

    .footer-group.active .footer-links-wrapper {
        max-height: 300px;
        padding: 0 20px 15px 20px;
    }

    [data-theme="dark"] .footer-group {
        border-bottom-color: #2a305c;
    }

    [data-theme="dark"] .footer-group h6::after {
        color: #8f96b3;
    }
}
