/*Reset default browser styles*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Main page setup */
html,
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: #DAE0E6;
    color: #1c1c1c;
    min-height: 100vh;
    line-height: 1.6;
}

/* Top bar fixed at the top */
header {
    background-color: #ffffff;
    padding: 0 20px;
    border-bottom: 1px solid #ccc;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Left side of header */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Hamburger menu button */
.menu-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: #1c1c1c;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.menu-btn:hover {
    background-color: #f6f7f8;
}

/* Logo text */
.logo {
    font-size: 28px;
    font-weight: 700;
    color: #0079D3;
    letter-spacing: -0.5px;
    cursor: pointer;
}

/* Small tag next to logo */
.tagline {
    font-size: 12px;
    color: #7c7c7c;
    font-weight: 500;
    padding: 4px 8px;
    background-color: #f6f7f8;
    border-radius: 4px;
}

/* Right side of header */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 0;
}

#search-input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-right: none;
    font-size: 14px;
    width: 250px;
    outline: none;
    border-radius: 4px 0 0 4px;
}

#search-input:focus {
    border-color: #0079D3;
}

#search-btn {
    padding: 8px 16px;
    background-color: #0079D3;
    color: white;
    border: 1px solid #0079D3;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    border-radius: 0 4px 4px 0;
    transition: background-color 0.2s;
}

#search-btn:hover {
    background-color: #006cbf;
}

/* Profile button */
.profile-btn {
    background: none;
    border: 1px solid #ccc;
    padding: 6px 10px;
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.profile-btn:hover {
    background-color: #f6f7f8;
    border-color: #0079D3;
}

/* Push content down below header */
.page-wrapper {
    padding-top: 56px;
    min-height: calc(100vh - 56px);
}

/* Category buttons bar */
.category-nav {
    background-color: #ffffff;
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #edeff1;
    position: sticky;
    top: 56px;
    z-index: 999;
    overflow-x: auto;
    white-space: nowrap;
}

.category-nav::-webkit-scrollbar {
    height: 0;
}

/* Individual category buttons */
.category-btn {
    padding: 6px 16px;
    background-color: transparent;
    color: #1c1c1c;
    border: 1px solid #ccc;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    flex-shrink: 0;
}

.category-btn:hover {
    background-color: #f6f7f8;
    border-color: #0079D3;
}

.category-btn.active {
    background-color: #0079D3;
    color: white;
    border-color: #0079D3;
}

/* Sort dropdown bar */
.sort-bar {
    background-color: #ffffff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #edeff1;
}

.sort-bar label {
    font-size: 14px;
    font-weight: 500;
    color: #7c7c7c;
}

#sort-options {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    background-color: white;
    outline: none;
}

#sort-options:focus {
    border-color: #0079D3;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #edeff1;
    border-top-color: #0079D3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 16px;
    color: #7c7c7c;
}

/* Error message */
.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 16px;
    margin: 20px;
    border-radius: 4px;
    text-align: center;
}

/* Hide stuff with this class */
.hidden {
    display: none !important;
}

/* News articles grid */
.articles-grid {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* Individual news card */
.article-card {
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.article-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: #0079D3;
}

.article-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 12px;
}

.article-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1c1c1c;
    margin-bottom: 8px;
    line-height: 1.3;
}

.article-card p {
    font-size: 14px;
    color: #7c7c7c;
    line-height: 1.5;
    margin-bottom: 12px;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #878a8c;
}

.article-source {
    font-weight: 600;
    color: #0079D3;
}

/* Footer at bottom */
footer {
    background-color: #1c1c1c;
    color: #ffffff;
    text-align: center;
    padding: 24px 20px;
    margin-top: 40px;
    border-top: 1px solid #343536;
}

footer p {
    font-size: 14px;
    margin-bottom: 8px;
}

.credits {
    font-size: 12px;
    color: #878a8c;
}

/* Side menu hidden by default */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background-color: #ffffff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease;
    z-index: 2000;
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

.sidebar-content {
    padding: 20px;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #7c7c7c;
    line-height: 1;
}

.close-btn:hover {
    color: #1c1c1c;
}

.sidebar h2 {
    margin-top: 40px;
    margin-bottom: 20px;
    color: #0079D3;
    font-size: 24px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    padding: 12px 16px;
    text-decoration: none;
    color: #1c1c1c;
    font-size: 16px;
    border-radius: 4px;
    transition: background-color 0.2s;
    display: block;
}

.sidebar-link:hover {
    background-color: #f6f7f8;
    color: #0079D3;
}

/* Dark mode toggle switch */
.sidebar-setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 4px;
}

.setting-label {
    font-size: 16px;
    color: #1c1c1c;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: #0079D3;
}

input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

/* Dark overlay behind sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1999;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* DARK MODE - when body has dark-mode class */
body.dark-mode {
    background-color: #1a1a1b;
    color: #d7dadc;
}

body.dark-mode header {
    background-color: #1a1a1b;
    border-bottom-color: #343536;
}

body.dark-mode .logo {
    color: #4fbcff;
}

body.dark-mode .tagline {
    background-color: #272729;
    color: #818384;
}

body.dark-mode .menu-btn,
body.dark-mode .profile-btn {
    color: #d7dadc;
}

body.dark-mode .menu-btn:hover,
body.dark-mode .profile-btn:hover {
    background-color: #272729;
}

body.dark-mode #search-input {
    background-color: #272729;
    border-color: #343536;
    color: #d7dadc;
}

body.dark-mode #search-input::placeholder {
    color: #818384;
}

body.dark-mode .category-nav,
body.dark-mode .sort-bar {
    background-color: #1a1a1b;
    border-bottom-color: #343536;
}

body.dark-mode .category-btn {
    color: #d7dadc;
    border-color: #343536;
}

body.dark-mode .category-btn:hover {
    background-color: #272729;
}

body.dark-mode .category-btn.active {
    background-color: #0079D3;
    color: white;
}

body.dark-mode .sort-bar label {
    color: #818384;
}

body.dark-mode #sort-options {
    background-color: #272729;
    border-color: #343536;
    color: #d7dadc;
}

body.dark-mode .article-card {
    background-color: #1a1a1b;
    border-color: #343536;
}

body.dark-mode .article-card:hover {
    border-color: #0079D3;
}

body.dark-mode .article-card h3 {
    color: #d7dadc;
}

body.dark-mode .article-card p {
    color: #818384;
}

body.dark-mode .article-source {
    color: #4fbcff;
}

body.dark-mode .sidebar {
    background-color: #1a1a1b;
}

body.dark-mode .sidebar h2 {
    color: #4fbcff;
}

body.dark-mode .sidebar-link,
body.dark-mode .setting-label {
    color: #d7dadc;
}

body.dark-mode .sidebar-link:hover {
    background-color: #272729;
}

body.dark-mode .close-btn {
    color: #818384;
}

body.dark-mode .loading p {
    color: #818384;
}

body.dark-mode .spinner {
    border-color: #343536;
    border-top-color: #0079D3;
}

body.dark-mode .error-message {
    background-color: #3a1a1a;
    border-color: #5a2a2a;
    color: #ff6b6b;
}

body.dark-mode footer {
    background-color: #1a1a1b;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .header-left {
        gap: 8px;
    }

    .logo {
        font-size: 24px;
    }

    .tagline {
        display: none;
    }

    #search-input {
        width: 180px;
    }

    .articles-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    header {
        padding: 0 12px;
    }

    #search-input {
        width: 140px;
        font-size: 13px;
    }

    #search-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .articles-grid {
        padding: 0 12px;
    }

    .article-card {
        padding: 12px;
    }

    .article-card h3 {
        font-size: 16px;
    }
}