/* Reset some default styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
    margin 0;
    background-color: #121212;
    color: #e0e0e0;
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2em;
    height: var(--app-height);
}

.container {
    display: flex;
    flex-direction: column;
    height: 90vh;
    width: 70%;
    min-width: 300px;
    max-width: 90vw;
    background-color: #1e1e1e;
    padding: 2em;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.container-hidden {
    opacity: 0;
    transform: scale(0.95); /* Start with a slight scale down */
}

.hidden {
    display: none !important;
}

.visible {
    opacity: 1; /* Fully opaque when visible */
    transform: scale(1); /* Scale to normal size */
    transition: opacity .5s ease, transform .5s ease; /* Smooth transition for both properties */
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #ffffff;
    font-size: 2rem;
	font-family: monospace;
}

.top-button {
    position: absolute;
    top: 27px;
    background-color: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: underline;
	max-width: 6em;
}

.top-button:hover {
    color: #ffffff;
}

/* History Button */
.history-button {
    text-align:left;
    left: 30px;
}
/* Settings Button */
.settings-button {
    text-align:right;
    right: 30px;
}

.about-button {
    text-align:right;
    right: 170px;
}

.card-box {
    border: 3px solid rgb(94, 94, 94);
    border-radius: 5px;
    height: 30%;
    box-sizing: border-box;
    min-height: 150px;
}

/* Form Groups */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-group > button {
	font-family: monospace;
}

.label-inline {
    display: flex;
    align-items: center;
}

label {
    margin-bottom: 5px;
    font-size: 1rem;
}

.priority {
    border: 2px solid rgb(255, 255, 255) !important;
}

/* Language Options Container */
.language-section {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.language-settings {
    flex: 2;
    min-width: 200px;
}

.matching-field-settings {
    flex: 1;
    min-width: 150px;
}

.language-options {
    display: flex;
    gap: 10px;
    align-items: center;         /* Vertically center align items within language-options*/
}



/* Rest of the styles */
.language-section label {
    margin-bottom: 5px;        /* Reduce bottom margin within language-options */
    font-weight: bold;        /* keep these same styles as they don't have to change*/
    display: block;            /* Ensure labels take full width */
}

select {
	width: min-content;
}

select, input[type="text"] {
    border: none;
    background-color: #2c2c2c;
    color: #ffffff;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    height: 2.7em; /* Ensure consistent height */
	padding-left: 10px;
}

select:focus, input[type="text"]:focus {
    background-color: #3a3a3a;
    outline: none;
}

/* TTS Form Group */
.tts-form-group {
    position: relative; /* Establish a positioning context */
}

.tts-form-group input[type="text"] {
    width: 100%; /* Full width to accommodate the button */
}

.tts-form-group .tts-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: orange; /* Default to "Generate" state */
    text-decoration: underline;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    height: 100%;
}

.tts-form-group .tts-button.preview-button {
    color: green; /* "Preview TTS" state */
}


/* Settings View Hidden by Default */

/* Message Styles */
.message {
    margin-top: 20px;
    padding: 10px;
    border-radius: 4px;
    display: none;
}

.success {
    background-color: #d4edda;
    color: #155724;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
}

.loading {
    background-color: #fff3cd;
    color: #856404;
}

.info {
    background-color: #cce5ff;
    color: #004085;
}

.input-with-label {
    display: flex;
    flex-direction: row; /* Align items horizontally */
    align-items: center; /* Vertically center label and input */
    flex-grow: 1;
}

/* Input field width adjustment (optional) */
.input-with-label input[type="text"] {
    flex-grow: 1; /* Allow input to take remaining space */
}

.shortcut-label {
	width: 27px;
	margin-right: 10px; /* Add some spacing between label and input */
    font-size: 15px; /* Or adjust as needed */
    color: gray;       /* Or a subtle color */
	font-family: monospace;
}

/* Spacer for additional spacing */
.spacer {
    height: 20px;
}

/* Audio Section Styles */
#audio-section {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-filename {
    color: #4CAF50;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer; /* Indicate clickable */
}

/* New Styles for Flag Dropdowns */
.flag-dropdown {
    min-width: 80px; /* Increased minimum width */
    width: auto;
    padding: 5px;
    background-color: #2c2c2c;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    height: min-content; /* Match height with language dropdowns */
}

.flag-dropdown:focus {
    background-color: #3a3a3a;
    outline: none;
}

/* Checkboxes Group */
.checkboxes-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.checkbox-row label {
    margin: 0;
    white-space: nowrap;
}

#clear-settings {
    margin-left: auto;
    padding: 8px 16px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Responsive Adjustments for Smaller Screens */
@media (max-width: 768px) {
    body {
        padding: 0;

    }    

    .container {
        width: 80%;
        max-height: 100%;
    }

    .flag-dropdown {
        width: 50px; /* Slightly narrower on tablets */
        height: 35px;
    }

    select, input[type="text"], .flag-dropdown {
        height: 35px; /* Adjust height for smaller screens */
    }

    .language-options {
        gap: 8px;
    }

    .checkbox-row label {
        font-size: 0.9rem;
    }

    .checkbox-row input[type="checkbox"] {
        width: 1rem;
        height: 1rem;
    }

    /* Adjust TTS Button font size */
    .tts-form-group .tts-button {
        font-size: 0.9rem;
    }

	.desktop-only {
        display: none; 
    }
}

@media (max-width: 480px) {
    body {
        justify-content: flex-start; /* Align the container to the top */
        margin: 0;
    }

    .container {
        width: 100%; /* Make the container take up the full width */
        height: 100vh; /* Make the container take up the full height */
        max-width: 100%; /* Remove max-width restriction */
        border-radius: 0px; /* Remove border-radius for full-screen effect */
        padding: 20px; /* Adjust padding to make better use of space */
        margin: 0; /* Remove any margin */
    }

    h1 {
        font-size: 1.5rem; /* Reduce title size for smaller screens */
    }

    .top-button {
        font-size: 0.875rem;
        top: 10px;
    }

    .settings-button {
        right: 20px;
    }

    .history-button {
        left: 20px;
    }

    #translate-button, #save-button {
        width: 100%; /* Make buttons full-width on mobile */
    }

    #save-button {
        /*position: absolute;*/
        bottom: 10px;
        /*margin: 10px;*/
    }    

    .flag-dropdown {
        width: 40px; /* Further reduce width on small devices */
        height: 30px;
    }

    select, input[type="text"], .flag-dropdown {
        height: 30px; /* Adjust height for very small screens */
    }

    .checkboxes-group {
        flex-direction: column;
    }

    .checkbox-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .checkbox-row label {
        font-size: 0.875rem;
    }

    .checkbox-row input[type="checkbox"] {
        width: 1rem;
        height: 1rem;
        margin-top: 5px;
    }

    /* Adjust TTS Button for Very Small Screens */
    .tts-form-group .tts-button {
        font-size: 0.8rem;
    }
}

/* Extra Small Devices (Very Small Phones, 320px and below) */
@media (max-width: 320px) {
    .container {
        width: 100%;
        padding: 10px;
        border-radius: 0px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .top-button {
        font-size: 0.75rem;
        top: 5px;
    }

    .settings-button {
        right: 20px;
    }

    .history-button {
        left: 20px;
    }

    label, select, input[type="text"], button {
        font-size: 0.75rem;
    }

    #translate-button {
        padding: 0.375rem;
        font-size: 0.75rem;
    }

    .tts-form-group .tts-button {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }

    .spacer {
        height: 10px;
    }

    .message {
        font-size: 0.75rem;
    }

    select, input[type="text"], .flag-dropdown {
        padding: 8px;
        height: 30px;
    }

    button {
        padding: 0.5rem 0.75rem;
    }
}

/* New: Generating State */
.tts-form-group .tts-button.generating-button {
    color: grey; /* Grey text for "Generating..." */
    text-decoration: none; /* Remove underline */
    cursor: not-allowed; /* Indicate not clickable */
}

/* ----------------------- */
/*       SETTINGS VIEW     */
/* ----------------------- */

/* Scope all settings view styles within #settings-view */
#settings-view {
    height: 100%;
}

/* Add subheading styles */
.settings-subheading {
    font-size: 1.5rem; /* Adjust size as needed */
    margin-bottom: 10px;
    color: #ffffff; /* Color for the subheadings */
    font-family: monospace; /* Consistent font family */
}

/* Adjust form-group elements within settings view */
#settings-view .form-group {
    width: 50%; /* 50% width for desktop */
    margin-bottom: 10px; /* Reduced spacing between form groups */
}

/* Make select and input fields within settings view have full width */
#settings-view select:not(.flag-dropdown),
#settings-view input[type="text"] {
    width: 100%; /* Full width of the form-group container */
    font-size: 0.9rem; /* Reduced font size */
    height: 4vh;
}

/* Responsive width adjustments for settings view */
@media (min-width: 769px) {
    /* Desktop view: 50% width */
    #settings-view .form-group {
        width: 50%;
    }
}

@media (max-width: 768px) {
    /* Tablet view: 80% width */
    #settings-view .form-group {
        width: 80%;
    }
}

@media (max-width: 480px) {
    /* Mobile view: 80% width */
    #settings-view .form-group {
        width: 80%;
    }
}

/* Reduce spacing between labels and dropdowns within settings view */
#settings-view label {
    margin-bottom: 3px; /* Reduced from 5px */
    font-size: 1.2rem; /* Reduced font size */
}

/* Further reduce spacing if necessary */
#settings-view .language-section label {
    margin-bottom: 5px; /* Adjusted for language sections */
    font-size: 1.2rem; /* Reduced font size */
}

/* Apply specific background colors based on field IDs */

/* Source Language and Source Router: Blue */
#source-language,
#source-router {
    background-color: #1e3a8a; /* Blue shade */
}

#source-language:focus,
#source-router:focus {
    background-color: #2c5282; /* Darker blue on focus */
}

/* Target Language and Target Router: Green */
#target-language,
#target-router {
    background-color: #2f855a; /* Green shade */
}

#target-language:focus,
#target-router:focus {
    background-color: #276749; /* Darker green on focus */
}

/* TTS Language Settings and TTS Router: Orange */
#tts-language-settings,
#tts-router {
    background-color: #dd6b20; /* Orange shade */
}

#tts-language-settings:focus,
#tts-router:focus {
    background-color: #c05621; /* Darker orange on focus */
}

/* Ensure text color remains readable */
#settings-view select,
#settings-view input[type="text"] {
    color: #ffffff;
}

/* Uniform Styling for all form elements in settings view */
#settings-view .form-group {  
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
#settings-view .checkboxes-group {
    display: flex;
    align-items: flex-start;
    width: 100%;
}

/* Adjust matching field dropdowns */
#settings-view .matching-field-dropdown {
    width: 100%; /* Full width of form-group */
    font-size: 0.9rem; /* Reduced font size */
    margin-top: 2px; /* Minimal top margin */
}

/* Adjust language dropdowns */
#settings-view .language-dropdown {
    width: 100%; /* Full width of form-group */
    font-size: 0.9rem; /* Reduced font size */
    margin-top: 2px; /* Minimal top margin */
}

/* Adjust TTS language dropdown */
#settings-view .tts-language-dropdown {
    width: 100%; /* Full width of form-group */
    font-size: 0.9rem; /* Reduced font size */
    margin-top: 2px; /* Minimal top margin */
}

/* Optional: Add transitions for smooth background color changes */
#settings-view select,
#settings-view input[type="text"] {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Divider for separating sections */
.divider {
    width: 100%; /* Spans 100% of the container */
    height: 3px; /* Thickness of the line */
    background-color: #d3d3d3; /* Light grey color */
    align-self: center; /* Centers the divider within the container */
}

.term-magic-comment {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 100px;
    max-height: 400px; /* Add a max height */
    overflow-y: auto;
    margin: 10px 0;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
    border: 1px solid #ccc;
    color: #333;
    font-family: 'Merriweather', serif;
}

/* Add styles for the content container */
.term-magic-content {
    flex: 1;
    font-size: 1.1em;
    line-height: 1.5em;
    padding-bottom: 10px; /* Space for feedback */
}

/* Update feedback component styles */
translation-feedback {
    margin-top: auto; /* Push to bottom */
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Style specifically the suggestion spans */
.term-magic-comment .sugg {
  color: #2563eb; 
  font-weight: 500;
  background-color: orange;
  border-radius: 4px;
}

/* Fixed bottom buttons */
.bottom-buttons {
    margin-top: auto;
    background-color: #1e1e1e;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 15px;
}


#main-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Deck and Model Selection Container */
.deck-model-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

#deck-dropdown, #model-dropdown {
    flex: 1;
    min-width: 200px; /* Ensure minimum width */
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .deck-model-container {
        flex-direction: column;
        gap: 10px;
    }

    .language-section {
        flex-direction: column;
        gap: 10px;
    }

    .language-settings, .matching-field-settings {
        width: 100%;
    }

    .flag-dropdown {
        min-width: 60px;
    }

    .checkboxes-group {
        flex-direction: column;
        align-items: flex-start;
    }

    #clear-settings {
        width: 100%;
        margin-top: 10px;
    }
}

/* Checkbox Styles */
.checkbox-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px; /* Space between label and checkbox */
}

/* Styled Checkbox */
.styled-checkbox {
    width: 20px; /* Increase size */
    height: 20px; /* Increase size */
    cursor: pointer; /* Pointer cursor on hover */
    accent-color: #4CAF50; /* Change checkbox color */
}

/* Optional: Add hover effect */
.styled-checkbox:hover {
    transform: scale(1.1); /* Slightly enlarge on hover */
}

/* History Item Styles */
.history-item {
    border: 1px solid #ddd;
    margin: 10px 0;
    padding: 15px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.translation-content {
    flex-grow: 1;
}

.original-text {
    font-weight: bold;
    margin-bottom: 5px;
}

.actions {
    display: flex;
    gap: 10px;
}

#history-tab {
    cursor: pointer;
    padding: 10px;
}

/* Add or modify these styles */
.input-row {
    display: flex;
    gap: 0.5rem;  /* Reduced gap */
    align-items: stretch;
    width: 100%;
}

.input-row input {
    flex-grow: 1;
}

.input-row audio-button {
    flex-shrink: 0;
    width: fit-content;  /* Increased to accommodate the longer text */
}

audio-button button {
    white-space: nowrap;
    height: 100%;
    padding: 0.5rem;
    background-color: #2c2c2c;  /* Match your theme */
    border: none;
    color: #e0e0e0;
}

/* Ensure consistent height */
.input-row input,
.input-row button {
    height: 2.2rem;  /* Reduced height to match your UI */
    line-height: 2.2rem;
    margin: 0;
}

.about-view {
    padding: 2rem;
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.about-content {
    margin: 0 auto;
    max-width: 800px;  /* Limit content width for better readability */
    line-height: 1.8;  /* Increased line height for better readability */
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1.1rem;  /* Slightly larger base font size */
}

.about-content h1 {
    margin: 0 0 1.5rem;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;  /* Tighter letter spacing for headings */
    color: var(--text-primary);
}

.about-content h3 {
    margin: 2rem 0 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.about-content p {
    margin: 1.2rem 0;
    color: var(--text-secondary);
}

.about-content ul, 
.about-content ol {
    margin: 1.2rem 0;
    padding-left: 2.5rem;
}

.about-content li {
    margin: 0.8rem 0;
    color: var(--text-secondary);
}

.about-content code {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.9em;
    color: var(--text-accent);
}

.about-content a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.about-content a:hover {
    border-bottom-color: var(--link-color);
}

.about-content em {
    font-style: italic;
    color: var(--text-accent);
}

/* Make emoji stand out a bit */
.about-content p:first-of-type {
    font-size: 1.2rem;
}

/* Add some emphasis to key points */
.about-content ul li::marker {
    color: var(--text-accent);
}

/* Adjust for mobile */
@media (max-width: 768px) {
    .about-button {
        right: 95px;
    }
}

@media (max-width: 480px) {
    .about-button {
        right: 80px;
    }
}

.version-info {
    font-size: 0.8rem;
    opacity: 0.7;
}

.badge-dev {
    background: #ff4444;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-size: 0.7rem;
} 

.app-footer {
    position: fixed;
    bottom: 0;
    right: 0;
    background: inherit;
    padding: 1rem;
    text-align: center;
    /* Optional: add slight gradient to blend with content */
    background: linear-gradient(to bottom, transparent, var(--background-color) 20%);
}

/* Add some bottom padding to main container to prevent footer overlap
#mainContainer {
    padding-bottom: 4rem;
} */
