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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    padding: 40px;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.translation-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.translation-panel {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.translation-panel textarea {
    flex: 1;
    min-height: 150px;
    max-height: 150px;
    height: 150px;
    resize: none;
}

.translation-panel .result {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-top: 0;
    padding: 15px;
    min-height: 150px;
    max-height: 150px;
}

.translation-panel .result-text {
    flex: 1;
    min-height: 150px;
    max-height: 150px;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .translation-container {
        grid-template-columns: 1fr;
    }
}

.input-group {
    margin-bottom: 20px;
}

.voice-controls {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.voice-selector-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.voice-selector-group label {
    margin-bottom: 0;
    min-width: 60px;
}

.voice-selector-group select {
    flex: 1;
    margin-bottom: 0;
}

.speak-button {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}

.speak-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.speak-button:active {
    transform: translateY(0);
}

.translate-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    gap: 10px;
}

.button-group button {
    flex: 1;
}

.button-group .speak-button {
    flex: 0 0 auto;
    width: auto;
    min-width: 100px;
    max-width: 150px;
}

.playback-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.autoplay-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #555;
    font-size: 14px;
    user-select: none;
}

.autoplay-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

.speed-control label {
    margin-bottom: 0;
    min-width: 50px;
    font-weight: 600;
}

#speedSlider {
    flex: 1;
    max-width: 200px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#speedSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

#speedSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

#speedValue {
    min-width: 40px;
    font-weight: 500;
    color: #333;
}

.speed-reset-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speed-reset-btn:hover {
    background: #e0e0e0;
    border-color: #bbb;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.3s;
}

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

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.result {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.result-label {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-text {
    color: #333;
    font-size: 1.1em;
    line-height: 1.6;
}

.loading {
    display: none;
    text-align: center;
    color: #667eea;
    margin-top: 20px;
}

.loading.active {
    display: block;
}

.error {
    margin-top: 20px;
    padding: 15px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 10px;
    color: #c33;
}

.status {
    margin-top: 20px;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 8px;
    color: #2e7d32;
    font-size: 0.9em;
}

.models-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.models-title {
    color: #333;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 15px;
}

.flags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
}

.flag {
    width: 80px;
    height: 60px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flag.complete {
    background: #c8e6c9;
    border-color: #81c784;
}

.flag.complete:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: #4caf50;
}

.flag.complete.selected {
    border-color: #2196F3;
    border-width: 3px;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.6), 0 0 30px rgba(33, 150, 243, 0.4);
    transform: scale(1.05);
}

.flag.incomplete {
    background: #ffcdd2;
    border-color: #ef5350;
    opacity: 0.7;
    cursor: not-allowed;
}

.flag.incomplete::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    background: #d32f2f;
    transform: rotate(45deg);
    top: 50%;
    left: 0;
}

.flag.incomplete::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    background: #d32f2f;
    transform: rotate(-45deg);
    top: 50%;
    left: 0;
}

.flag-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5em;
    color: #666;
    white-space: nowrap;
    font-weight: 600;
}

.flag.complete .flag-label {
    color: #2e7d32;
}

.flag.incomplete .flag-label {
    color: #c62828;
}

select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

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

/* Hamburger Menu */
.hamburger-menu {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    cursor: pointer;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s;
}

.hamburger-menu:hover {
    transform: scale(1.1);
}

.hamburger-menu .line {
    width: 25px;
    height: 3px;
    background: #667eea;
    margin: 5px 0;
    border-radius: 2px;
    transition: 0.3s;
}

/* Side Menu Overlay */
.side-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.side-menu-overlay.active {
    display: block;
    opacity: 1;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -350px;
    width: 320px;
    height: 100%;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.side-menu.active {
    left: 0;
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.side-menu-header h2 {
    color: #333;
    font-size: 1.5em;
}

.close-menu {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-menu:hover {
    color: #667eea;
}

.history-language-item {
    padding: 15px;
    margin-bottom: 10px;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid #667eea;
    display: flex;
    align-items: center;
    gap: 15px;
}

.history-language-item:hover {
    background: #e8e8e8;
    transform: translateX(5px);
}

.history-flag {
    width: 40px;
    height: 30px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.history-language-item .lang-info {
    flex: 1;
}

.history-language-item .lang-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.history-language-item .lang-count {
    font-size: 0.9em;
    color: #666;
}

.history-language-item .lang-time {
    font-size: 0.8em;
    color: #999;
    margin-top: 5px;
}

/* History Tabs */
.history-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.history-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
    margin-bottom: -2px;
}

.history-tab:hover {
    color: #667eea;
    background: #f5f5f5;
}

.history-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

/* Chat View */
.chat-view {
    display: none;
}

.chat-view.active {
    display: block;
}

.main-view {
    display: block;
}

.main-view.hidden {
    display: none;
}

.back-button {
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.back-button:hover {
    background: #e8e8e8;
    border-color: #667eea;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.chat-header .flag {
    width: 40px;
    height: 30px;
    border-radius: 4px;
}

.chat-header h2 {
    color: #333;
    font-size: 1.8em;
}

/* History Table */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

.history-table thead {
    background: #f5f5f5;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #ddd;
    font-size: 13px;
}

.history-table th:nth-child(1) {
    width: 30%;
}

.history-table th:nth-child(2) {
    width: 45%;
}

.history-table th:nth-child(3) {
    width: 25%;
}

.history-row {
    border-bottom: 1px solid #e8e8e8;
    transition: background-color 0.2s;
}

.history-row:hover {
    background-color: #f9f9f9;
}

.history-row td {
    padding: 8px 12px;
    vertical-align: middle;
}

.history-english {
    color: #333;
    font-weight: 500;
}

.history-translated {
    color: #667eea;
    font-weight: 600;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.history-date {
    font-size: 12px;
    color: #999;
}

.history-speak-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    min-width: 40px;
}

.history-speak-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(76, 175, 80, 0.4);
}

.history-speak-btn:active {
    transform: translateY(0);
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.info-section {
    margin-top: 40px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-top: 3px solid #667eea;
}

.info-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.info-section .info-group {
    margin-bottom: 20px;
}

.info-section .info-group h4 {
    color: #555;
    margin-bottom: 10px;
    font-size: 1em;
    font-weight: 600;
}

.info-section .info-item {
    margin-bottom: 8px;
    color: #666;
    font-size: 0.9em;
}

.info-section .info-item strong {
    color: #333;
    margin-right: 5px;
}

.info-section .info-list {
    list-style: none;
    padding-left: 0;
}

.info-section .info-list li {
    margin-bottom: 5px;
    padding-left: 20px;
    position: relative;
    color: #666;
    font-size: 0.9em;
}

.info-section .info-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

.info-section .info-link {
    color: #667eea;
    text-decoration: none;
}

.info-section .info-link:hover {
    text-decoration: underline;
}

/* Voice Voting Styles */
.voice-voting {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 5px;
}

.vote-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vote-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.vote-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.vote-up {
    color: #2e7d32;
    border-color: #81c784;
    background: #f1f8f4;
}

.vote-up:hover:not(:disabled) {
    background: #c8e6c9;
    border-color: #66bb6a;
}

.vote-down {
    color: #c62828;
    border-color: #ef9a9a;
    background: #ffebee;
}

.vote-down:hover:not(:disabled) {
    background: #ffcdd2;
    border-color: #e57373;
}

