/* --- 1. General Setup & Variables (Light Theme by Default) --- */
:root {
    --background-color: #F5F5F5;
    --text-color: #2c3e50;
    --box-background: #FFFFFF;
    --box-border-color: #bdc3c7;
    --button-background: #3498db;
    --button-text-color: #FFFFFF;
}

body.dark-theme {
    --background-color: #121212;
    --text-color: #ecf0f1;
    --box-background: #1e1e1e;
    --box-border-color: #555555;
}

body {
    font-family: 'Poppins', sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    text-align: center;
    width: 90%;
    max-width: 900px;
    /* Increased max-width for the new layout */
}

h1 {
    font-size: 2.5rem;
    font-weight: 300;
}

/* --- 2. Search Box Styling (Pill Shape) --- */
.search-box {
    display: flex;
    align-items: center;
    border: 2px solid var(--box-border-color);
    border-radius: 999px;
    overflow: hidden;
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--box-background);
}

#searchInput {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 1rem;
    font-size: 1rem;
    background-color: transparent;
    color: var(--text-color);
}

#searchButton {
    border: none;
    background-color: var(--button-background);
    color: var(--button-text-color);
    padding: 1rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#searchButton:hover {
    background-color: #2980b9;
}

/* --- 4. Theme Switcher Styling --- */
.theme-switcher-container {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

#themeSwitcher {
    background: none;
    border: 2px solid var(--box-border-color);
    font-size: 1.5rem;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

#themeSwitcher:hover {
    transform: scale(1.1);
    background-color: var(--box-background);
}

/* --- 6. Logo Styling --- */
.site-logo-link {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: block;
}

.site-logo {
    height: 80px;
    width: auto;
}

/* --- 7. Interactive Results Styling --- */
.results-container {
    display: flex;
    margin-top: 2rem;
    max-width: 900px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    gap: 1.5rem;
    background-color: var(--box-background);
    border: 1px solid var(--box-border-color);
    border-radius: 8px;
    min-height: 300px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

#resultsList {
    flex-basis: 35%;
    border-right: 1px solid var(--box-border-color);
    overflow-y: auto;
    padding-right: 1.5rem;
}

#selectedDefinition {
    flex-grow: 1;
    text-align: left;
    padding-top: 0.5rem;
}

.result-word {
    padding: 0.75rem 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: left;
}

.result-word:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.result-word.active {
    background-color: var(--button-background);
    color: var(--button-text-color);
    font-weight: bold;
}

.placeholder-text {
    color: #888;
    font-style: italic;
    text-align: center;
    margin-top: 5rem;
}

/* --- 8. Mobile Responsive Design --- */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding-top: 130px;
    }

    .container {
        width: 95%;
    }

    .site-logo {
        height: 60px;
    }

    #themeSwitcher {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }

    h1 {
        font-size: 2rem;
    }

    .results-container {
        flex-direction: column;
        min-height: auto;
        width: 100%;
    }

    #resultsList {
        border-right: none;
        border-bottom: 1px solid var(--box-border-color);
        padding-right: 0;
        padding-bottom: 1rem;
        flex-basis: auto;
        max-height: 200px;
    }
}

/* --- 9. Detailed Definition View Styling --- */
#selectedDefinition h3 {
    margin-top: 0;
    color: var(--button-background);
}

.definition-entry {
    border-bottom: 1px solid var(--box-border-color);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.definition-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tag.word-type {
    display: inline-block;
    background-color: #e9ecef;
    color: #495057;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 0.75rem;
}

.main-def {
    font-size: 1.1rem;
    line-height: 1.6;
}

.meta,
.example {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.5rem;
}

.dark-theme .meta,
.dark-theme .example {
    color: #bbb;
}

.dark-theme .tag.word-type {
    background-color: #343a40;
    color: #f8f9fa;
}

.example em {
    font-family: serif;
}

/* --- 10. Final UI Refinements --- */

/* This class will be added by JavaScript to hide non-selected words */
.result-word.hidden {
    display: none;
}

/* Make the new definition labels bold */
.meta strong,
.example strong {
    color: var(--text-color);
}

/* Style for clickable synonym links */
a.synonym-link {
    color: var(--button-background);
    text-decoration: none;
    font-weight: bold;
}

a.synonym-link:hover {
    text-decoration: underline;
}

/* Add some margin to the definition numbers */
.definition-entry .def-number {
    font-weight: bold;
    margin-right: 0.5rem;
}