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

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

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

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

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

#settings-container {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid #e1e5e9;
}

#translation-container {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid #e1e5e9;
}

.language-selectors {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.lang-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.lang-select label {
    font-weight: 600;
    color: #555;
}

.lang-select select {
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.lang-select select:focus {
    outline: none;
    border-color: #ff8c00;
}

#swap-languages {
    background: #ff8c00;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 25px;
}

#swap-languages:hover {
    background: #ff7700;
    transform: rotate(180deg);
}

.text-areas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.input-section, .output-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-section label, .output-section label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

.input-section textarea, .output-section textarea {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.input-section textarea:focus {
    outline: none;
    border-color: #ff8c00;
}

.output-section textarea {
    background: #ffffff;
    cursor: text;
}

.text-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
}

.text-controls {
    display: flex;
    gap: 8px;
}

.text-info button {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.text-info button:hover {
    background: #e8eaed;
}

.translation-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
}

#evaluate-btn {
    background: #ff8c00;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 15px 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#evaluate-btn:hover {
    background: #ff7700;
}

#evaluate-btn:active {
    transform: translateY(0);
}

#evaluate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#loading {
    color: #ff8c00;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.hidden {
    display: none !important;
}

#evaluation-section {
    margin-top: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 15px;
    border: 1px solid #dee2e6;
}

#evaluation-section h3 {
    color: #495057;
    margin-bottom: 20px;
    text-align: center;
}

.score-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.score-label {
    font-weight: 600;
    color: #495057;
}

#quality-score {
    font-size: 24px;
    font-weight: bold;
    color: #28a745;
    padding: 8px 16px;
    background: #d4edda;
    border-radius: 8px;
}

.evaluation-details, .evaluation-feedback {
    margin-bottom: 20px;
}

.evaluation-details h4, .evaluation-feedback h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 16px;
}

#evaluation-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.metric-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.metric-label {
    font-weight: 600;
    color: #495057;
    display: block;
    margin-bottom: 5px;
}

.metric-value {
    font-size: 18px;
    font-weight: bold;
}

#ai-feedback {
    background: white;
    padding: 15px;
    border-radius: 8px;
    line-height: 1.6;
    color: #495057;
    border: 1px solid #e1e5e9;
    white-space: pre-wrap;
}


@media (max-width: 768px) {
    .text-areas {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .translation-controls {
        order: 2;
    }

    .language-selectors {
        flex-direction: column;
        gap: 15px;
    }

    #swap-languages {
        order: 3;
        margin-top: 0;
    }

    header h1 {
        font-size: 2rem;
    }

    #translation-container {
        padding: 20px;
    }

    #settings-container {
        padding: 20px;
    }
}

/* Settings Section Styles */
.settings-section h3 {
    margin-bottom: 20px;
    color: #495057;
    font-size: 1.3rem;
}

.api-key-section {
    margin-bottom: 25px;
}

.api-key-section label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.api-key-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.api-key-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s ease;
}

.api-key-input-group input:focus {
    outline: none;
    border-color: #ff8c00;
}

#toggle-api-key {
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

#toggle-api-key:hover {
    background: #e9ecef;
    border-color: #ff8c00;
}

.api-key-help {
    display: block;
    margin-top: 8px;
    color: #6c757d;
    font-size: 12px;
}

.api-key-help a {
    color: #ff8c00;
    text-decoration: none;
}

.api-key-help a:hover {
    text-decoration: underline;
}

.prompt-section {
    margin-bottom: 15px;
}

.prompt-section label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

#evaluation-prompt {
    width: 100%;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#evaluation-prompt:focus {
    outline: none;
    border-color: #ff8c00;
}

.prompt-controls {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.prompt-controls button {
    padding: 8px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    background: #f8f9fa;
    color: #495057;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.prompt-controls button:hover {
    background: #e9ecef;
    border-color: #ff8c00;
}

.toggle-btn {
    background: #ff8c00 !important;
    color: white !important;
    border-color: #ff8c00 !important;
}

.toggle-btn:hover {
    background: #ff7700 !important;
    border-color: #ff7700 !important;
}

/* Authentication Section Styles */
#api-auth-gate {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

#api-auth-gate h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

#api-auth-gate p {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
}

.auth-question {
    margin-bottom: 20px;
}

.auth-question label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

.auth-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

#auth-answer {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

#auth-answer:focus {
    outline: none;
    border-color: #ff8c00;
}

#auth-submit {
    background: #ff8c00;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

#auth-submit:hover {
    background: #ff7700;
}

.auth-help {
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
}

.auth-success {
    text-align: center;
    color: #28a745;
}

.auth-success h4 {
    color: #28a745 !important;
    margin-bottom: 8px;
}

.auth-success p {
    color: #155724;
    margin: 0;
}

.manual-api-section {
    margin-top: 15px;
}

/* Conversation Section Styles */
.conversation-section {
    margin-top: 25px;
    border-top: 1px solid #e1e5e9;
    padding-top: 20px;
}

.conversation-section h5 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 16px;
}

.conversation-history {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background: #fafafa;
}

.conversation-history:empty {
    display: none;
}

.conversation-message {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.conversation-message:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.message-header {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 14px;
}

.user-message .message-header {
    color: #ff8c00;
}

.ai-message .message-header {
    color: #495057;
}

.error-message .message-header {
    color: #dc3545;
}

.message-content {
    line-height: 1.5;
    color: #333;
    font-size: 14px;
}

.conversation-input {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#conversation-message {
    flex: 1;
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#conversation-message:focus {
    outline: none;
    border-color: #ff8c00;
}

#send-message {
    background: #ff8c00;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

#send-message:hover {
    background: #ff7700;
}

#send-message:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.auth-error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 10px;
    margin-top: 15px;
    font-size: 14px;
}