/* --- 1. General Setup & Variables --- */
: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;
}

html {
    height: 100%;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

main {
    flex-grow: 1;
}

.container,
.static-page-container {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding: 2rem 1rem;
}

.static-page-container {
    max-width: 800px;
    text-align: left;
    line-height: 1.7;
}

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

/* --- 2. Site Header (Redesigned) --- */
.site-header {
    background-color: var(--box-background);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    width: 100%;
    z-index: 1000;
    border-bottom: 1px solid var(--box-border-color);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 70px;
}

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

/* --- Navigation & Right Side Wrapper (Desktop) --- */
.nav-wrapper {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-grow: 1;
    justify-content: flex-end;
}

.main-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 20px;
}

.main-navigation a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    font-size: 16px;
    transition: color 0.3s;
}

.main-navigation a i {
    margin-right: 5px;
    color: var(--button-background);
}

.main-navigation a:hover {
    color: var(--button-background);
}

/* --- User Info & Buttons --- */
.header-right-side {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Updated Profile Display for Center Alignment */
.user-profile-display {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between image and text */
}

.profile-pic {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--box-border-color);
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1; /* Helps vertical centering */
}

.logout-link {
    color: #dc3545;
    font-size: 14px;
    text-decoration: none;
}

/* --- Google Login Button Styling --- */
.login-button.google-btn {
    background-color: #FFFFFF;
    color: #3c4043;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #dadce0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.login-button.google-btn:hover {
    background-color: #f7fafe;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-color: #d2e3fc;
}

.google-logo-svg {
    display: block;
    width: 18px;
    height: 18px;
}

/* Dark Mode Google Button Override */
body.dark-theme .login-button.google-btn {
    background-color: #131314; /* Dark gray */
    color: #e8eaed;
    border-color: #5f6368;
}

body.dark-theme .login-button.google-btn:hover {
    background-color: #303134;
}

/* --- Theme Switcher --- */
.theme-switcher-container button#themeSwitcher {
    background: none;
    border: 1px solid var(--box-border-color);
    font-size: 1.2rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}

/* --- Mobile Toggle Buttons --- */
.mobile-toggle,
.mobile-close {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
}

/* --- 3. Search & Results --- */
.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: 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;
}

.results-container {
    display: flex;
    margin-top: 2rem;
    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);
    background-color: var(--box-background);
}

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

#selectedDefinition {
    flex-grow: 1;
    padding-left: 1.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;
}

.result-word.hidden {
    display: none;
}

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

/* --- 4. Definition & Static Page Styling --- */
.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;
}

#selectedDefinition h3,
.static-page-container h1,
.static-page-container h2 {
    color: var(--button-background);
}

#selectedDefinition h3 {
    margin-top: 0;
}

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

.meta strong,
.example strong {
    color: var(--text-color);
}

a.synonym-link {
    color: var(--button-background);
    text-decoration: none;
    font-weight: bold;
}

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

.def-number {
    font-weight: bold;
    margin-right: 0.5rem;
}

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

.back-link {
    display: inline-block;
    margin-top: 2rem;
    font-weight: bold;
    color: var(--button-background);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

/* --- 5. Footer --- */
.site-footer {
    border-top: 1px solid var(--box-border-color);
    padding: 1rem 0;
    font-size: 0.8rem;
    text-align: center;
    color: #6c757d;
    margin-top: 3rem;
    flex-shrink: 0;
}

.dark-theme .site-footer {
    color: #a9aeb3;
}

.footer-links a {
    color: inherit;
    text-decoration: none;
    margin: 0 0.5rem;
}

.footer-links a:hover {
    color: var(--button-background);
}

.footer-copyright {
    margin-top: 0.5rem;
}

/* --- 6. Responsive (Tablets & Mobile) --- */
/* Changed breakpoint from 768px to 1024px to include Tablets */
@media screen and (max-width: 1024px) {
    h1 {
        font-size: 1.8rem;
    }

    /* --- Toggle Logic --- */
    .mobile-toggle {
        display: block;
    }

    /* Side Slide Menu */
    .nav-wrapper {
        position: fixed;
        top: 0;
        right: -100%;
        /* Push off screen */
        width: 280px; /* Slightly wider for tablets */
        height: 100vh;
        background-color: var(--box-background);
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 60px 20px;
        transition: right 0.3s ease-in-out;
        z-index: 999;
    }

    .nav-wrapper.active {
        right: 0;
    }

    .mobile-close {
        display: block;
        position: absolute;
        top: 20px;
        right: 20px;
    }

    /* Stack links vertically */
    .main-navigation ul {
        flex-direction: column;
        width: 100%;
        gap: 25px;
        margin-bottom: 30px;
    }

    .main-navigation a {
        font-size: 18px;
        display: block;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--box-border-color);
        width: 100%;
    }

    .theme-switcher-container {
        margin-top: auto;
    }

    .header-right-side {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 20px;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .user-profile-display {
        margin-bottom: 10px;
    }
    
    .login-button.google-btn {
        width: 100%; /* Full width button on mobile */
        justify-content: center;
    }

    /* --- Results Container Mobile --- */
    .results-container {
        flex-direction: column;
    }

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

    #selectedDefinition {
        padding-left: 0;
        padding-top: 1rem;
    }
}

/* --- 7. Forms, Modals & Share --- */
.contact-form {
    margin-top: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--box-border-color);
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
    background-color: var(--box-background);
    color: var(--text-color);
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--button-background);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.submit-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    background-color: var(--button-background);
    color: var(--button-text-color);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.submit-btn:hover {
    background-color: #2980b9;
}

.form-message {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}

.form-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* History Page List */
.history-list {
    list-style: none;
    padding-left: 0;
}

.history-list li a {
    text-decoration: none;
    display: block;
    padding: 0.5rem 0;
    color: var(--button-background);
}

.history-list li a:hover {
    text-decoration: underline;
}

/* Social Share Buttons */
.share-buttons-container {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--box-border-color);
    text-align: left;
}

.share-buttons-container p {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.share-button {
    display: inline-block;
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    margin-right: 8px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.2s;
    border: none;
    font-family: 'Poppins', sans-serif;
}

.share-button:hover {
    opacity: 0.85;
}

.share-button.facebook {
    background-color: #1877F2;
}

.share-button.twitter {
    background-color: #000000;
}

.share-button.whatsapp {
    background-color: #25D366;
}

.share-button.copy-link {
    background-color: #6c757d;
    cursor: pointer;
}

/* Pop-up Social Share Button */
.share-container {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--box-border-color);
    position: relative;
}

.share-trigger-button {
    background-color: var(--button-background);
    color: var(--button-text-color);
    border: none;
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.share-trigger-button:hover {
    background-color: #2980b9;
}

.share-trigger-button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.share-options {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    background-color: var(--box-background);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--box-border-color);
    width: 200px;
    z-index: 10;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
}

.share-options.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-options a,
.share-options button {
    display: block;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    text-align: left;
    background: none;
    border: none;
    font-size: 0.9rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
}

.share-options a:hover,
.share-options button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark-theme .share-options button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Report Error Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--box-background);
    color: var(--text-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.visible .modal-content {
    transform: translateY(0);
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.5rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--button-background);
}

.report-error-link {
    display: block;
    font-size: 0.8rem;
    text-align: right;
    margin-top: 1rem;
    color: #888;
    text-decoration: none;
}

.report-error-link:hover {
    text-decoration: underline;
    color: var(--button-background);
}

/* --- 8. Favorite Button Styling --- */
.favorite-button-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.favorite-button {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #ccc;
    transition: color 0.2s ease, transform 0.1s ease;
    padding: 0;
    line-height: 1;
}

.favorite-button:hover {
    color: #999;
    transform: scale(1.1);
}

.favorite-button.is-favorite {
    color: #f1c40f;
    text-shadow: 0 0 5px rgba(241, 196, 15, 0.4);
}

body.dark-theme .favorite-button {
    color: #555;
}

body.dark-theme .favorite-button:hover {
    color: #777;
}

body.dark-theme .favorite-button.is-favorite {
    color: #f1c40f;
}