/* Default dark mode colors */
:root {
    --background-color: #121212;
    --text-color: #ffffff;
    --list-bg: #1e1e1e;
    --list-hover: #333333;
    --link-color: #bb86fc;
    --selected-bg: #bb86fc;
    --border-color: #555;
}

/* Light mode colors */
.light-mode {
    --background-color: #ffffff;
    --text-color: #000000;
    --list-bg: #f0f0f0;
    --list-hover: #e0e0e0;
    --link-color: #6200ea;
    --selected-bg: #6200ea;
    --border-color: #ccc;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main"
        "footer footer";
    grid-template-columns: 1fr 3fr;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
}

header {
    grid-area: header;
    padding: 10px;
    background-color: var(--list-bg);
    display: flex;
    gap: 10px;
}

#search {
    flex-grow: 1;
    padding: 10px;
    background-color: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

#mode-toggle {
    padding: 10px 15px;
    cursor: pointer;
    background-color: var(--list-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: background-color 0.1s, transform 0.1s;
}

#mode-toggle:hover {
    background-color: var(--list-hover);
    transform: scale(1.05);
}

#sidebar {
    grid-area: sidebar;
    background-color: var(--list-bg);
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    padding: 10px;
}

#sort-options {
    padding: 10px;
    display: flex;
    gap: 10px;
}

#sort-options button {
    padding: 10px 15px;
    cursor: pointer;
    background-color: var(--list-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: background-color 0.1s, transform 0.1s;
}

#sort-options button:hover {
    background-color: var(--list-hover);
    transform: scale(1.05);
}

#list {
    list-style: none;
    margin: 0;
    padding: 0;
}

#list li {
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.1s;
    border-radius: 5px;
    margin: 5px 0;
}

#list li:hover {
    background-color: var(--list-hover);
}

#list li.selected {
    background-color: var(--selected-bg);
    color: #ffffff;
}

#main {
    grid-area: main;
    padding: 20px;
    overflow-y: auto;
    position: relative; /* For positioning share button on desktop */
}

#main h2 {
    margin-top: 0;
}

#main .content {
    line-height: 1.6;
}

/* Styling for embedded images in older articles */
.content img {
    width: 250px;
    height: 250px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: transform 0.1s;
    cursor: pointer;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Photo container */
.photos {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Individual photo styling */
.article-photo {
    width: 250px; /* Fixed width for thumbnails */
    height: 250px; /* Fixed height for uniformity */
    object-fit: cover; /* Crop and zoom to fit */
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: transform 0.1s;
    cursor: pointer;
}

/* Hover effect for thumbnails */
.article-photo:hover {
    transform: scale(1.05);
}

/* Lightbox styles */
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 5px;
}

/* Close button for lightbox */
.lightbox-close {
    position: absolute;
    top: -20px;
    right: -20px;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* Button styles */
.button {
    padding: 8px 12px; /* Slightly smaller for elegance */
    cursor: pointer;
    background-color: var(--list-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: background-color 0.1s, transform 0.1s, opacity 0.1s;
    font-size: 0.9em; /* Slightly smaller text */
}

.button:hover {
    background-color: var(--list-hover);
    transform: scale(1.05);
    opacity: 0.9; /* Subtle hover effect */
}

/* Button container for grouping buttons */
.button-container {
    margin-bottom: 15px; /* Space below buttons */
}

/* Share container styles (desktop only) */
.share-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

/* Mobile optimization */
@media (max-width: 768px) {
    body {
        grid-template-areas:
            "header"
            "sidebar"
            "main"
            "footer";
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }

    #search {
        margin-bottom: 10px;
        padding: 10px;
    }

    #mode-toggle {
        padding: 10px 15px;
    }

    #sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px;
    }

    #sort-options button {
        padding: 10px 15px;
    }

    #list li {
        padding: 15px;
        font-size: 1.1em;
    }

    #main {
        padding: 10px;
    }

    .article-photo {
        width: 70%; /* Full width on mobile */
        height: 150px; /* Slightly smaller height on mobile */
        object-fit: cover;
    }

    .content img {
        width: 70%;
        height: 150px;
        object-fit: cover;
    }

    .photos {
        margin-bottom: 7em;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 40px;
    }

    /* Mobile button layout */
    .button-container {
        display: flex;
        justify-content: space-between; /* Space buttons evenly */
        align-items: center;
        margin-bottom: 10px;
    }

    .share-container {
        position: static; /* Remove absolute positioning on mobile */
    }

    .button {
        padding: 6px 10px; /* Even smaller on mobile */
        font-size: 0.8em;
    }
}

/* Welcome message styles */
.welcome-message {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.welcome-message h1 {
    font-size: 2.5em;
    margin: 0 0 10px 0;
    color: var(--text-color);
}

.welcome-message p {
    font-size: 1.2em;
    margin: 0;
    color: var(--text-color);
    opacity: 0.8;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .welcome-message h1 {
        font-size: 2em;
    }

    .welcome-message p {
        font-size: 1em;
    }
}

/* Footer styles */
footer {
    grid-area: footer;
    padding: 10px;
    text-align: center;
    font-size: 0.8em;
    background-color: var(--list-bg);
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
    position: relative;
}

footer p {
    margin: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

footer a {
    color: var(--link-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}