/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Accessibility - Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 4px;
}

.skip-link:focus {
    top: 6px;
}

/* Enhanced focus indicators */
*:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support for accessibility */
@media (prefers-contrast: more) {
    .container {
        background: #000;
        color: #fff;
    }

    .search-container input {
        border: 2px solid #fff;
        background: #000;
        color: #fff;
    }

    button {
        border: 2px solid #fff;
        background: #000;
        color: #fff;
    }

    .checkbox-option-label {
        color: #fff;
    }

    .checkbox-option {
        border: 2px solid #fff;
        background: #000;
    }

    .translation-card {
        border: 2px solid #fff;
        background: #000;
        color: #fff;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #667eea;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Top navigation bar */
header nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(102, 126, 234, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    padding: 8px 20px;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    z-index: 1000;
}

.nav-title {
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
    text-decoration: none;
    margin: 0;
}

.nav-links {
    display: flex;
    gap: 0;
}

/* Hamburger menu button - hidden by default */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background-color: white;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Hamburger animation when active */
.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Adjust body to account for fixed nav */
body {
    padding-top: 45px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.full-dict-link {
    color: white;
    background: transparent;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 6px 16px;
    border-radius: 20px;
    margin: 0;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    white-space: nowrap;
    border: none;
    cursor: pointer;
}

.full-dict-link:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-1px);
}

.full-dict-link.active {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    font-weight: 600;
}

main {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.search-section {
    margin-bottom: 30px;
}

.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#searchInput {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
}

button {
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

#searchBtn {
    background: #667eea;
    color: white;
}

#searchBtn:hover {
    background: #5a6fd8;
}

#clearBtn {
    background: #6c757d;
    color: white;
}

#clearBtn:hover {
    background: #5a6268;
}

/* Button classes for consistent styling */
.btn {
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    background: #667eea;
    color: white;
}

.btn:hover {
    background: #5a6fd8;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.help-and-options {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.search-help {
    background: #f8f9fa;
    padding: 10px; /* Further reduced from 14px (another 30% reduction) */
    border-radius: 6px; /* Slightly smaller radius */
    border-left: 3px solid #667eea; /* Thinner border */
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    flex: 1;
}

.search-help:hover {
    background: #e9ecef;
    border-left-color: #5a67d8;
}

.search-options-side {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.search-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-help-header p {
    margin: 0;
}

.help-toggle {
    background: none;
    border: none;
    font-size: 1rem; /* Reduced from 1.2rem */
    font-weight: bold;
    color: #6c757d;
    cursor: pointer;
    padding: 3px 7px; /* Reduced from 5px 10px */
    border-radius: 3px; /* Smaller radius */
    transition: all 0.2s ease;
}

.help-toggle:hover {
    background: #e9ecef;
    color: #495057;
}

.help-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.help-content.collapsed {
    max-height: 0;
    margin: 0;
    padding: 0;
}

.search-help p {
    margin-bottom: 5px; /* Further reduced from 7px */
    font-weight: bold;
    font-size: 0.9rem; /* Further reduced from 0.9rem */
}

.search-help ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 7px; /* Further reduced from 10px */
}

.search-help li {
    margin: 2px 0; /* Further reduced from 3px */
    padding: 2px 0; /* Further reduced from 3px */
    font-size: 0.85rem; /* Further reduced from 0.85rem */
}

.search-help code {
    background: #e9ecef;
    padding: 1px 4px; /* Reduced from 2px 6px */
    border-radius: 3px; /* Smaller radius */
    font-family: 'Courier New', monospace;
    font-size: 0.8rem; /* Added smaller font size */
    color: #d63384;
}

.legend {
    margin-top: 7px; /* Further reduced from 10px */
    padding-top: 7px; /* Further reduced from 10px */
    border-top: 1px solid #dee2e6;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 3px; /* Further reduced from 5px */
    margin-top: 2px; /* Further reduced from 3px */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px; /* Further reduced from 6px */
    font-size: 0.85rem; /* Further reduced from 0.8rem */
    margin-left: 10px;
}

.help-link {
    color: #667eea;
    text-decoration: none;
    font-size: 0.85rem; /* Match legend-item font size */
    font-weight: normal; /* Match regular text weight */
}

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

.help-link:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Ensure anchor links account for fixed header */
#mission-heading,
#kiel-uzi-heading,
#tools-heading,
#history-heading {
    scroll-margin-top: 60px; /* Account for fixed nav height plus some padding */
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #667eea;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.translation-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.translation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.source-word {
    font-size: 1.3rem;
    font-weight: bold;
    color: #495057;
    margin-bottom: 5px;
}

.source-word.discouraged-word {
    /* Removed italic styling - "prefere" text already indicates discouraged words */
}

.recommendation-section {
    margin: 8px 0 5px 0;
}

.recommendation-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: lowercase;
}

.recommendation-label.discouraged {
    color: #dc3545;
}

.recommendation-label.alternative {
    color: #28a745;
}

.target-word {
    font-size: 1.5rem;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
}

.target-words {
    margin-bottom: 10px;
}

.translation-item {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 8px;
    margin: 2px 4px 2px 0;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.translation-count {
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
    margin-left: 8px;
}

.divided-form {
    font-size: 0.85em;
    color: #495057;
    font-weight: normal;
    font-style: italic;
    opacity: 0.8;
}

/* Divided forms inside translation items (on colored backgrounds) */
.translation-item .divided-form {
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

.source-annotation {
    font-size: 0.75rem;
    background: #e9ecef;
    color: #495057;
    padding: 2px 5px;
    border-radius: 3px;
    margin-left: 5px;
    cursor: help;
    font-weight: normal;
    font-style: normal;
    position: relative;
}

.source-annotation::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    margin-bottom: 5px;
}

.source-annotation::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.source-annotation:hover::after,
.source-annotation:hover::before {
    opacity: 1;
    visibility: visible;
}

.target-annotation {
    font-size: 0.7rem;
    background: #e9ecef;
    color: #495057;
    padding: 0px 3px;
    border-radius: 3px;
    margin-left: 5px;
    cursor: help;
    font-weight: normal;
    font-style: normal;
    position: relative;
}

.target-annotation::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    margin-bottom: 5px;
}

.target-annotation::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.target-annotation:hover::after,
.target-annotation:hover::before {
    opacity: 1;
    visibility: visible;
}

.context-note {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    margin-right: 5px;
}

.source-context {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}

.language-info {
    font-size: 0.9rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.hidden {
    display: none !important;
}

.admin-section {
    margin-top: 40px;
    border-top: 2px solid #dee2e6;
    padding-top: 30px;
}

.admin-toggle {
    background: #28a745;
    color: white;
    width: 100%;
    margin-bottom: 20px;
}

.admin-toggle:hover {
    background: #218838;
}

.admin-panel {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.admin-panel h3 {
    margin-bottom: 20px;
    color: #495057;
}

.form-group {
    margin-bottom: 15px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #495057;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

#addTranslationForm button, #editForm button, #updateTranslationForm button {
    background: #007bff;
    color: white;
}

#addTranslationForm button:hover, #editForm button:hover, #updateTranslationForm button:hover {
    background: #0056b3;
}

/* View toggle buttons - segmented control */
.view-toggle-group {
    display: flex;
    flex-direction: row; /* Force horizontal layout */
    flex-shrink: 0; /* Prevent shrinking */
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    overflow: hidden;
}

.view-toggle-btn {
    background: transparent;
    color: #4a5568;
    border: none;
    padding: 8px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid #cbd5e0;
    flex-shrink: 0; /* Prevent buttons from shrinking */
    min-width: 44px; /* Ensure minimum touch target size */
    border-right: none;
}

.view-toggle-btn:hover {
    background: transparent;
    color: #2d3748;
}

.view-toggle-btn.active {
    background: #667eea;
    color: white;
}

.view-toggle-btn.active:hover {
    background: #667eea;
    color: #eeeeee;
}

/* Mode toggle buttons */
.mode-toggle-group {
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    margin-right: 12px;
}

.mode-toggle-btn {
    background: transparent;
    color: #667eea;
    border: none;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-right: 1px solid rgba(102, 126, 234, 0.1);
    flex-shrink: 0;
    min-width: 60px;
    position: relative;
    border-right: none;
}

.mode-toggle-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #5a67d8;
}

.mode-toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Search options */
.search-options {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: right;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4a5568;
    user-select: none;
    position: relative;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.2);
    backdrop-filter: blur(10px);
}

.checkbox-label:hover {
    color: #2d3748;
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Hide default checkbox */
.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Custom checkbox */
.checkmark {
    position: relative;
    height: 18px;
    width: 18px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #cbd5e0;
    border-radius: 4px;
    margin-right: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

/* Checkbox hover state */
.checkbox-label:hover .checkmark {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* Checkbox checked state */
.checkbox-label input[type="checkbox"]:checked ~ .checkmark {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Checkmark icon */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Show checkmark when checked */
.checkbox-label input[type="checkbox"]:checked ~ .checkmark:after {
    display: block;
}

/* Checkbox text responsive display - handled by JavaScript */
.checkbox-text-full {
    display: inline;
}

.checkbox-text-short {
    display: none;
}

/* Focus state for accessibility */
.checkbox-label input[type="checkbox"]:focus ~ .checkmark {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Focus state for new checkbox options */
.checkbox-option:focus {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Checkbox container - stacked vertically */
.checkbox-container {
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Consistent checkbox styling for both options */
.checkbox-option-label {
    font-size: 13px;
    color: #666;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.checkbox-option-label:hover {
    color: #333;
}

.checkbox-option {
    width: 12px;
    height: 12px;
    margin: 0;
    cursor: pointer;
}

.checkbox-option-text {
    font-size: 12px;
    user-select: none;
}

/* List view styles - traditional dictionary appearance */
.results-container.list-view .results-grid {
    display: block;
    padding: 0;
}

.results-container.list-view .translation-card {
    display: block;
    margin-bottom: 12px;
    padding: 8px 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
}

.results-container.list-view .translation-card:last-child {
    border-bottom: none;
}

.results-container.list-view .source-word {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 4px;
    color: #2d3748;
    display: inline;
}

.results-container.list-view .recommendation-section {
    display: inline;
    margin: 0 8px 0 0;
}

.results-container.list-view .recommendation-label {
    font-size: 0.9rem;
    font-style: italic;
}

.results-container.list-view .target-words {
    display: inline;
    margin-left: 8px;
}

.results-container.list-view .translation-item {
    margin: 0 6px 0 0;
    padding: 2px 6px;
    font-size: 0.95rem;
}

/* Pri Ni page styles */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.page-header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: #666;
    font-size: 1.2rem;
    font-weight: 300;
}

.content-section {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

.about-section {
    padding: 2rem;
    background: white;
    border-radius: 12px;
}

.about-section h2 {
    color: #667eea;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.about-section p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: #333;
}

.about-section ul {
    margin: 1rem 0;
    padding-left: 2rem;
}

.about-section li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.inline-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

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

.participation-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.option-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.option-card h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.tool-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tool-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
}

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

.tool-card p {
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

/* Accessibility improvements for Pri Ni page */
.tool-link:focus,
.inline-link:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 2px;
}

.option-card:focus-within,
.tool-card:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Footer styles */
footer {
    padding: 8px;
    background: transparent;
    color: white;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.footer-left {
    justify-self: flex-start;
}

.footer-right {
    justify-self: flex-end;
}

.footer-link {
    color: white;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    transition: opacity 0.2s ease;
}

.footer-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.footer-link:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.facebook-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* Facebook corner link for Pri Ni page */
.facebook-corner-link {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    transition: opacity 0.2s ease;
}

/* Make main element relative positioned to contain the absolute positioned Facebook link */
#main {
    position: relative;
}

/* Logo centered at top for Pri Ni page */
.logo-center {
    display: block;
    margin: 0 auto 30px auto;
    width: 400px;
    height: auto;
}

/* Page navigation for Pri Ni page */
.page-navigation {
    max-width: 800px;
    margin: 0 auto 40px auto;
    padding: 0;
    background: transparent;
}

.page-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.page-nav-list li {
    margin: 0;
    flex: 1;
}

.page-nav-link {
    display: block;
    padding: 15px 20px;
    color: #667eea;
    text-decoration: none;
    background: white;
    border-right: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.page-nav-list li:last-child .nav-link {
    border-right: none;
}

.page-nav-link:hover {
    background: #667eea;
    color: white;
}

.page-nav-link:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

.facebook-corner-link:hover {
    opacity: 0.8;
}

.facebook-corner-icon {
    width: 48px;
    height: 48px;
    display: block;
}

/* Mobile footer layout */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-link {
        padding: 0.2rem 0.3rem;
        font-size: 0.85rem;
    }

    /* Adjust Facebook corner link for mobile */
    .facebook-corner-link {
        top: 10px;
        right: 10px;
    }

    .facebook-corner-icon {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    body {
        padding-top: 40px;
    }

    header nav {
        padding: 6px 15px;
        justify-content: space-between;
    }

    .nav-title {
        font-size: 1.1rem;
    }

    /* Show hamburger menu on mobile */
    .hamburger-menu {
        display: flex;
    }

    /* Hide nav links by default on mobile */
    .nav-links {
        display: none;
        position: fixed;
        top: 40px;
        left: 0;
        right: 0;
        background: #6f42c1;
        flex-direction: column;
        padding: 20px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    /* Show nav links when mobile menu is open */
    .nav-links.mobile-open {
        display: flex;
    }

    /* Style mobile nav links */
    .nav-links .full-dict-link {
        padding: 12px 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        text-align: center;
        font-size: 1.1rem;
    }

    .nav-links .full-dict-link:last-child {
        border-bottom: none;
    }

    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
    }

    .full-dict-link {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    /* Mobile responsive for Pri Ni page */
    .page-header h1 {
        font-size: 2rem;
    }

    .page-subtitle {
        font-size: 1rem;
    }

    .about-section {
        padding: 1.5rem;
    }

    .about-section h2 {
        font-size: 1.5rem;
    }

    .participation-options {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.75rem;
    }

    .tool-card {
        padding: 1rem;
    }

    /* Adjust logo for mobile */
    .logo-center {
        width: 80px;
        margin-bottom: 20px;
    }

    /* Mobile navigation adjustments */
    .page-navigation {
        margin: 0 auto 30px auto;
        padding: 0 10px;
    }

    .nav-list {
        flex-direction: column;
        border-radius: 6px;
    }

    .nav-link {
        padding: 12px 15px;
        font-size: 0.9rem;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        white-space: normal;
    }

    .nav-list li:last-child .nav-link {
        border-bottom: none;
    }

    .search-container {
        flex-direction: row; /* Keep search input and button horizontal */
        flex-wrap: wrap; /* Allow wrapping if needed */
        gap: 8px; /* Smaller gap on mobile */
        justify-content: flex-start; /* Left-align by default */
        align-content: flex-start; /* Align wrapped lines to top */
    }

    .search-container input {
        flex: 1 1 200px; /* Grow, shrink, basis 200px */
        min-width: 200px; /* Minimum width for usability */
        max-width: 100%; /* Don't exceed container */
    }

    .search-container button {
        flex-shrink: 0; /* Button doesn't shrink */
        margin-left: auto; /* Push search button to right */
    }

    /* Keep toggle buttons left-aligned */
    .view-toggle-group {
        margin-left: 0; /* Override auto margin for toggles */
    }

    /* Remove header margin-bottom on narrow screens to save space */
    header {
        margin-bottom: 20px; /* Reduced from 40px */
    }

    .help-and-options {
        flex-direction: row; /* Keep horizontal layout */
        gap: 10px; /* Smaller gap for mobile */
        align-items: flex-start;
    }

    .search-options-side {
        padding-top: 0;
        flex-shrink: 0; /* Prevent shrinking */
    }

    .search-help {
        flex: 1; /* Take remaining space */
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Hide mobile controls by default */
.mobile-controls-row {
    display: none;
}

/* Small mobile screens - reorganized layout */
@media (max-width: 480px) {
    /* First row: search input and search button stay together */
    .search-container {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }

    .search-container input {
        flex: 1;
        min-width: 0; /* Allow shrinking */
    }

    .search-container button {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Hide desktop view toggle from search container on mobile */
    .search-container .view-toggle-group {
        display: none;
    }

    /* Show mobile controls row */
    .mobile-controls-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        gap: 8px;
        width: 100%;
    }

    /* Mobile view toggle on left */
    .mobile-toggle {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }

    /* Hide desktop search options */
    .help-and-options > .search-options-side {
        display: none;
    }

    /* Mobile checkboxes on right */
    .mobile-controls-row .search-options-side {
        display: flex;
        flex-shrink: 0;
    }

    .mobile-controls-row .checkbox-container {
        display: flex;
        gap: 8px;
        margin: 0;
    }

    .mobile-controls-row .checkbox-option-label {
        font-size: 11px;
        white-space: nowrap;
    }

    /* Ensure consistent text size for both mobile checkboxes */
    .mobile-controls-row .checkbox-text-full,
    .mobile-controls-row .checkbox-text-short,
    .mobile-controls-row .checkbox-option-text {
        font-size: 11px;
    }

    .mobile-controls-row .checkbox-option {
        width: 10px;
        height: 10px;
    }

    /* Force help section to appear below mobile controls */
    .help-and-options {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .search-help {
        margin-top: 12px;
        width: 100%;
        order: 2;
    }

    /* Keep toggle buttons left-aligned */
    .view-toggle-group {
        margin-left: 0; /* Override auto margin for toggles */
        flex-shrink: 0;
    }

    .view-toggle-btn {
        padding: 6px 10px; /* Slightly smaller padding on very small screens */
        font-size: 1rem;
    }

    /* Further reduce header margin on very small screens */
    header {
        margin-bottom: 15px; /* Further reduced from 20px */
    }

    /* Ensure help and options stay horizontal on very small screens */
    .help-and-options {
        gap: 8px; /* Even smaller gap */
    }

    .search-help {
        min-width: 0; /* Allow shrinking if needed */
    }

    /* Responsive text now handled by JavaScript */
}

/* Text Analysis Section */
.text-analysis-section {
    margin-top: 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.text-analysis-section h3 {
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.text-analysis-section p {
    color: #4a5568;
    margin-bottom: 24px;
}

.text-input-container {
    margin-bottom: 24px;
}

.text-input-container textarea {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 400;
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

.text-input-container textarea:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.text-analysis-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: flex-end;
}

.analyzed-text-result {
    margin-top: 32px;
    padding: 24px;
    background: rgba(248, 250, 252, 0.8);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.analyzed-text-result h4 {
    color: #2d3748;
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.analyzed-text-content {
    line-height: 1.8;
    font-size: 16px;
    color: #2d3748;
}

/* Controls row layout */
.controls-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
}

/* Analysis mode toggle */
.analysis-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #4a5568;
}

.toggle-text {
    font-weight: 500;
}

/* Mode toggle buttons - matching main page design */
.mode-toggle-group {
    display: flex;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

.mode-toggle-btn {
    background: transparent;
    color: #667eea;
    border: none;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    min-width: 80px;
    position: relative;
}

.mode-toggle-btn:hover {
    background: transparent;
    color: #5a67d8;
}

.mode-toggle-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.mode-toggle-btn.active:hover {
    background: #667eea;
    color: #eeeeee;
}



/* Mobile responsive */
@media (max-width: 768px) {
    .controls-row {
        flex-direction: column-reverse;  /* Toggle below buttons */
        gap: 12px;
        align-items: stretch;
    }

    .analysis-mode-toggle {
        justify-content: center;
    }

    .text-analysis-buttons {
        justify-content: center;
    }
}



/* Interactive mode clickable words */
.dictionary-word.interactive {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.dictionary-word.interactive:hover {
    background-color: rgba(229, 62, 62, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dictionary-word.interactive.selected {
    background-color: rgba(102, 126, 234, 0.4);  /* Purple background */
    color: white;                                 /* White text */
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    border: 1px solid #667eea;                   /* Purple border */
}

/* Interactive results use the same translation-card styling as main page */

/* Translation popup */
.translation-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    margin: 20px;
    animation: popupFadeIn 0.2s ease-out;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.popup-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #718096;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 1001;
}

.popup-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.popup-translation-card {
    /* Space for close button */
    padding: 48px 24px 24px;
}

.popup-translation-card .translation-card {
    margin: 0;
    box-shadow: none;
    border: none;
}

/* Mobile responsive popup */
@media (max-width: 768px) {
    .popup-content {
        margin: 10px;
        max-width: 95vw;
        max-height: 85vh;
    }

    .popup-translation-card {
        padding: 16px;
        padding-top: 40px;
    }
}

.dictionary-word {
    color: #e53e3e;
    font-weight: 600;
}

.translation {
    color: #38a169;
    font-weight: 500;
}

.radical-word {
    color: #e53e3e;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radical-word:hover {
    background-color: rgba(229, 62, 62, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Analyze Page Specific Styles */
.analyze-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 40px;
    margin-top: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.analyze-description {
    margin-bottom: 30px;
    text-align: center;
}

.analyze-description h2 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 2rem;
    font-weight: 600;
}

.analyze-description p {
    color: #4a5568;
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
}

.analyze-help {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    margin-top: 20px;
}

.analyze-help:hover {
    background: #e9ecef;
    border-left-color: #5a67d8;
}

.analyze-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}

.analyze-help-header p {
    margin: 0;
    color: #495057;
    font-size: 0.95rem;
}

.analyze-help .help-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #667eea;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.analyze-help .help-toggle:hover {
    color: #5a67d8;
    transform: scale(1.1);
}

/* Tooltip styles for recommendation labels */
.recommendation-label.tooltip {
    position: relative;
    cursor: help;
}

.recommendation-label.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2d3748;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-weight: normal;
    text-transform: none;
}

.recommendation-label.tooltip::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.recommendation-label.tooltip:hover::after,
.recommendation-label.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Left-aligned tooltips for popups and narrow containers */
.recommendation-label.tooltip.left-align::after {
    left: 0;
    transform: translateX(0);
    white-space: normal;
    max-width: 280px;
    text-align: left;
}

.recommendation-label.tooltip.left-align::before {
    left: 20px;
    transform: translateX(0);
}

/* Reorder buttons for admin panel */
.reorder-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s ease;
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reorder-btn:hover {
    background: #5a67d8;
}

.reorder-btn:active {
    background: #4c51bf;
}

.reorder-btn.hidden {
    display: none;
}

.translation-set-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
}

/* Mobile responsive tooltips */
@media (max-width: 768px) {
    .recommendation-label.tooltip::after {
        font-size: 0.8rem;
        padding: 6px 10px;
        white-space: normal;
        max-width: 200px;
        bottom: 130%;
    }

    .recommendation-label.tooltip::before {
        bottom: 120%;
    }

    /* Force left-aligned tooltips on mobile */
    .recommendation-label.tooltip::after {
        left: 0;
        transform: translateX(0);
        max-width: 200px;
    }

    .recommendation-label.tooltip::before {
        left: 15px;
        transform: translateX(0);
    }

    .reorder-btn {
        padding: 3px 6px;
        font-size: 12px;
        min-width: 24px;
        height: 24px;
    }
}
