/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

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

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

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

/* Main Content */
main {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

/* Section Styles */
section {
    margin-bottom: 40px;
}

section h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
}

/* API Key Section */
.api-key-section {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid #e0e6ed;
}

.api-key-config h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.api-key-input-group {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.api-key-input-group input {
    flex: 1;
    padding: 12px 50px 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.api-key-input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.toggle-api-key {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.toggle-api-key:hover {
    opacity: 1;
}

.api-key-info {
    font-size: 0.9rem;
    color: #666;
    margin: 5px 0;
}

.api-key-info a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

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

.privacy-notice {
    background: #f0f9ff;
    border: 1px solid #0ea5e9;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #0c4a6e;
}

.privacy-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.privacy-text {
    line-height: 1.4;
}

.api-key-status {
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-top: 10px;
}

.api-key-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.api-key-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.api-key-status.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.api-key-status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.upload-area:hover {
    border-color: #5a67d8;
    background: #f0f4ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #4c51bf;
    background: #e6fffa;
    transform: scale(1.02);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #4a5568;
}

.upload-content p {
    color: #718096;
    margin-bottom: 5px;
}

.file-info {
    font-size: 0.9rem;
    color: #a0aec0 !important;
}

.file-preview {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
}

.file-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-weight: 600;
    color: #2d3748;
}

.file-size {
    color: #718096;
    font-size: 0.9rem;
}

.remove-file {
    background: #fed7d7;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: #e53e3e;
    font-weight: bold;
    transition: all 0.2s ease;
}

.remove-file:hover {
    background: #feb2b2;
    transform: scale(1.1);
}

/* Language Section */
.language-config {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 40px;
    align-items: start;
}

.source-language, .target-languages {
    background: #f7fafc;
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.language-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

select {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.detected-language {
    background: #c6f6d5;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #9ae6b4;
    animation: fadeIn 0.3s ease;
}

.detected-label {
    font-weight: 600;
    color: #22543d;
}

.detected-value {
    color: #2f855a;
    margin-left: 5px;
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-1px);
}

.language-option input:checked + .language-label {
    color: #667eea;
    font-weight: 600;
}

.language-option input {
    accent-color: #667eea;
    transform: scale(1.2);
}

.language-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.action-btn.primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-btn.secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.action-btn.secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

/* Preview Section */
.preview-section {
    background: #f7fafc;
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.file-stats {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

.stat-label {
    font-size: 0.9rem;
    color: #718096;
}

.code-preview {
    background: #1a202c;
    border-radius: 10px;
    overflow: hidden;
}

.code-preview pre {
    padding: 20px;
    color: #e2e8f0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Controls Section */
.controls-section {
    background: #f7fafc;
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

/* Character Usage Display */
.character-usage {
    background: #fff8e1;
    border: 2px solid #ffcc02;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.character-usage h4 {
    margin: 0 0 15px 0;
    color: #f57c00;
    font-size: 1.1rem;
    font-weight: 600;
}

.usage-details {
    display: grid;
    gap: 8px;
}

.usage-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #fff3c4;
}

.usage-stat:last-child {
    border-bottom: none;
}

.usage-stat.highlight {
    background: #ffecb3;
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-weight: 600;
    border-bottom: none;
}

.usage-stat.percentage {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    font-weight: 600;
}

.usage-stat.percentage.warning {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

.usage-stat.percentage.danger {
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

.usage-label {
    color: #555;
    font-size: 0.9rem;
}

.usage-value {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.translation-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.translation-info {
    text-align: center;
    padding: 15px;
    background: #e6fffa;
    border: 1px solid #81e6d9;
    border-radius: 10px;
    max-width: 500px;
}

.api-info {
    color: #2c7a7b;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Progress Section */
.progress-section {
    background: #f7fafc;
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.progress-languages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.language-progress {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.language-progress.completed {
    border-color: #48bb78;
    background: #f0fff4;
}

.language-progress.failed {
    border-color: #f56565;
    background: #fffafa;
}

.language-flag {
    font-size: 1.2rem;
    min-width: 24px;
}

.language-name {
    font-weight: 600;
    color: #2d3748;
    min-width: 80px;
}

.progress-bar {
    background: #e2e8f0;
    border-radius: 50px;
    height: 8px;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    background: linear-gradient(90deg, #667eea, #764ba2);
    height: 100%;
    border-radius: 50px;
    transition: width 0.3s ease;
    width: 0%;
}

.language-progress.completed .progress-fill {
    background: linear-gradient(90deg, #48bb78, #38a169);
}

.language-progress.failed .progress-fill {
    background: linear-gradient(90deg, #f56565, #e53e3e);
}

.language-status {
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 60px;
    text-align: right;
}

.language-progress.completed .language-status {
    color: #38a169;
}

.language-progress.failed .language-status {
    color: #e53e3e;
}

.progress-text {
    text-align: center;
    font-weight: 600;
    color: #667eea;
    display: none; /* Hide the percentage text */
}

.translation-log {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    max-height: 150px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9rem;
    color: #4a5568;
}

/* Results Section */
.results-section {
    background: #f7fafc;
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.results-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

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

.result-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.language-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 1.1rem;
}

.translation-stats {
    font-size: 0.9rem;
    color: #718096;
}

.result-actions {
    display: flex;
    gap: 10px;
}

.result-actions button {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f7fafc;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #718096;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #e53e3e;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.language-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.tab-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tab-btn:hover:not(.active) {
    border-color: #667eea;
    background: #f8f9ff;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 15px;
    background: #f7fafc;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid #667eea;
    max-width: 300px;
    animation: slideIn 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toast.success {
    border-left-color: #48bb78;
}

.toast.error {
    border-left-color: #e53e3e;
}

.toast.warning {
    border-left-color: #ed8936;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #718096;
    margin-left: 10px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 25px;
    }
    
    .language-config {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .language-grid {
        grid-template-columns: 1fr;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .results-list {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .language-tabs {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .file-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .upload-area {
        padding: 30px 20px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
}