/* Define a custom font */
/*@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');*/

@font-face {
    font-family: 'FallingSky';
    src: url('../fonts/FallingSky-JKwK.woff2') format('woff2'),
         url('../fonts/FallingSky-JKwK.woff') format('woff'),
         url('../fonts/FallingSky-JKwK.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Global & Body Styles - Light Mode (Default) */
body {
    /*font-family: 'Inter', sans-serif;*/
    font-family: 'FallingSky', 'Apple Gothic', 'Malgun Gothic', sans-serif, Helvetica, Arial;
    background-color: #ffffff; /* Pure White Background (Light Mode Default) */
    padding: 20px;
    margin: 0;
    line-height: 1.6;
    color: #111827; /* Very Dark Gray (near black) */
    transition: background-color 0.3s, color 0.3s;
}

/* --- Dark Mode Overrides (Applied via JS when system preference is dark) --- */
body.dark-mode {
    background-color: #1f2937; /* Dark Background */
    color: #f9fafb; /* Light Text */
}

/* Elements that need explicit background/border color changes in Dark Mode */
body.dark-mode .results-area,
body.dark-mode #search-term,
body.dark-mode #browsing-language {
    background-color: #374151; /* Slightly lighter dark background for contrast */
    border-color: #4b5563;
    color: #f9fafb;
}

body.dark-mode .header-container {
     border-bottom-color: #4b5563;
}

body.dark-mode .tab-item {
    color: #9ca3af;
}
body.dark-mode .tab-item:hover {
    color: #e5e7eb;
}

/* Dark Mode: Segmented Control Container and Separators */
body.dark-mode .language-options {
    border-color: #4b5563;
}
body.dark-mode .language-options label {
    background-color: #374151;
    color: #e5e7eb;
    border-right-color: #4b5563;
}
body.dark-mode .language-options label:hover {
    background-color: #4b5563;
}

/* Dark Mode: Selected Segment */
body.dark-mode .language-selector-widget input[type="radio"]:checked + label {
    background-color: #4c51bf; /* Indigo Accent remains */
    color: white;
    box-shadow: none;
}

body.dark-mode .suggestion-dropdown {
    background-color: #374151;
    border-color: #4c51bf;
}
body.dark-mode .suggestion-item {
    color: #f9fafb;
    border-bottom-color: #4b5563;
}
body.dark-mode .suggestion-item:hover {
    background-color: #4c51bf30; /* Faded Indigo hover */
    color: #f9fafb;
}

body.dark-mode .results-area p {
    color: #d1d5db; /* Light gray paragraph text */
}

body.dark-mode .copyright-footer {
    color: #9ca3af;
}

/* --- Application Branding (Logo and Title) --- */
.app-branding {
    max-width: 800px;
    width: 100%;
    /*margin: 0 auto 30px;*/
    margin: 0 auto 10px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #4c51bf; /* Indigo color for branding (Accent) */
}

.app-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

@media (min-width: 640px) {
    .app-title {
        font-size: 3rem;
    }
}

.app-logo {
    width: 40px;
    height: 40px;
    fill: #4c51bf;
    flex-shrink: 0;
}


/* --- Header Container for Tabs and Dropdown --- */
.header-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #ddd;
    margin-bottom: 15px;
    padding: 0 10px;
}

/* --- Right side controls wrapper (Dropdown) --- */
.controls-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    padding-bottom: 8px; /* Align with tab bottom border */
}


/* --- Tabs Styling --- */
.tabs-container {
    display: flex;
}
.tab-item {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: 600;
    color: #9ca3af;
    transition: color 0.2s, border-bottom 0.2s;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
    -webkit-user-select: none;
    user-select: none;
}
.tab-item:hover {
    color: #111827; /* Dark text on hover in Light Mode */
}
.tab-item.active {
    color: #4c51bf; /* Indigo Accent */
    border-bottom-color: #4c51bf;
}

/* --- Browsing Language Dropdown Styling --- */
.browsing-language-selector {
    font-size: 0.875rem;
    color: #111827;
    display: flex;
    align-items: center;
}

#browsing-language {
    /* PADDING FIX: Increased right padding to prevent text/arrow overlap */
    padding: 5px 30px 5px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Updated arrow for contrast in both modes */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%234c51bf'%3e%3cpath d='M4 8l6 6 6-6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center; /* Positioned 8px from the right edge */
    background-size: 15px;
    cursor: pointer;
    margin-left: 10px;
}


/* --- A. Main Container and Flex Layout --- */
.dictionary-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 10px;
}

/* --- B. Language Selector Widget (Segmented Control Styling) --- */

.language-selector-widget {
    width: 100%;
}

.language-selector-widget h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: inherit;
    margin-bottom: 10px;
    margin-top: 10px;
}

/* The segmented control box */
.language-options {
    display: flex;
    justify-content: stretch;
    gap: 0;
    border: 2px solid #ddd;
    border-radius: 10px;
    overflow: hidden; /* Ensures segments stay within the outer radius */
    width: 100%; /* Important for full width */
}

/* 1. Hide the default radio input */
.language-selector-widget input[type="radio"] {
    display: none;
}

/* 2. Style the <label> segments */
.language-selector-widget label {
    flex-grow: 1; /* Equal width segments */
    padding: 10px 12px;
    background-color: #f9fafb;
    color: #374151;
    border: none;
    border-radius: 0; /* Remove individual border radius */
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: background-color 0.2s, color 0.2s;
    -webkit-user-select: none;
    user-select: none;
    border-right: 1px solid #ddd; /* Separator line in Light Mode */
    line-height: 1.4;
}

/* Remove separator border on the last segment */
.language-options label:last-child {
    border-right: none;
}

/* 3. Style the label on HOVER */
.language-selector-widget label:hover {
    background-color: #e5e7eb;
}

/* 4. Style the SELECTED label (The blue fill) */
.language-selector-widget input[type="radio"]:checked + label {
    background-color: #4c51bf;
    color: white;
    font-weight: 600;
    position: relative;
    z-index: 1; /* Ensures the selected item overlaps border slightly for clean look */
}

/* --- C. Input Styling & Suggestion Dropdown --- */
.text-input-field {
    flex-grow: 1;
    position: relative;
}

/* Container for the input and icon */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

#search-term {
    width: 100%;
    padding: 12px 16px;
    padding-right: 50px;
    font-size: 18px;
    border: 3px solid #ddd;
    border-radius: 12px;
    box-sizing: border-box;
    transition: border-color 0.3s, border-radius 0.3s;
    background-color: white;
    color: #111827;
}

#search-term.dropdown-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: #4c51bf;
}

#search-term:focus {
    border-color: #4c51bf;
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 81, 191, 0.2);
}

/* Style for the search button/icon */
.search-icon-btn {
    position: absolute;
    /* if 24 px */
    /*
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    */

    /* if 32 px */
    right: 20px;
    top: 25%;
    transform: translateY(-33%);

    border: none;
    background: none;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
    color: #4c51bf;
    transition: color 0.2s;
    height: 24px;
    width: 24px;
}

.search-icon-btn:hover {
    color: #3b3f94;
}

.clear-icon-btn {
    position: absolute;

    /* if 32 px */
    right: 60px;
    top: 25%;
    transform: translateY(-33%);

    border: none;
    background: none;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
    color: #4c51bf;
    transition: color 0.2s;
    height: 24px;
    width: 24px;
}

.clear-icon-btn:hover {
    color: #3b3f94;
}

/* Not using this */
/*.search-icon { */
    /*
    width: 24px;
    height: 24px;
    */
/*
    width: 32px;
    height: 32px;
    fill: currentColor;
}
*/

/* Suggestion Dropdown Styles */
.suggestion-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
    padding-top: 3px;
    border: 3px solid #4c51bf;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    background-color: white;
    z-index: 20;
/*    max-height: 200px;*/
    overflow-y: auto;

    display: block;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    color: #111827;
    font-size: 16px;
    transition: background-color 0.2s, color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}
/*
body.dark-mode .suggestion-item:hover {
    background-color: #4c51bf30; /* Use a semi-transparent dark blue hover */
/*} */

body.dark-mode .suggestion-item-highlighted {
    background-color: #4c51bf30; /* Use a semi-transparent dark blue higlight */
}

/*
body:not(.dark-mode) .suggestion-item:hover {
    background-color: #f0f4ff; /* Light blue hover */
/*}
*/

body:not(.dark-mode) .suggestion-item-highlighted {
    background-color: #f0f4ff; /* Light blue highlight */
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* --- Results Area Styling --- */
.results-area {
    max-width: 800px;
    width: 100%;
    margin: 15px auto 0;
    padding: 25px;
    min-height: 150px;
    max-height: 50vh;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.results-area h4 {
    margin-bottom: 10px;
    margin-top: 10px;
}

/* --- New Result Row Styling --- */
.result-row-container {
    padding-top: 5px; /* slight padding above the results */
}

.result-row {
    padding: 15px 0;
    border-bottom: 1px solid #e0e0e0; /* Thin light gray line */
}

/* Remove border on the last row */
.result-row:last-child {
    border-bottom: none;
}

/* Dark Mode override for the separator */
body.dark-mode .result-row {
    border-bottom-color: #4b5563; /* Darker border for contrast */
}

/* Styling for the three lines of text inside the row */
.result-row .line1 {
    font-weight: 600;
    color: #4c51bf; /* Highlight the main translation/term */
    font-size: 1.1rem;
    margin-bottom: 4px;
}
.result-row .line2 {
    font-style: italic;
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.result-row .line3 {
    color: inherit; /* Inherits main text color */
    font-size: 1rem;
}
body.dark-mode .result-row .line2 {
     color: #9ca3af; /* Lighter color for description in dark mode */
}


/* --- Copyright Styling --- */
.copyright-footer {
    max-width: 800px;
    width: 100%;
    margin: 50px auto 20px;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
}
