/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

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

.header-actions {
    margin-top: 10px;
}

/* Main content */
main {
    flex: 1;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

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

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

.file-upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: translateY(-2px);
}

.file-upload-area.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.02);
}

.file-upload-area i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 20px;
    display: block;
}

.file-upload-area p {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #666;
}

.or {
    font-weight: bold;
    color: #999;
    margin: 20px 0 !important;
}

.browse-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

/* File info */
.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9ff;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-details i {
    font-size: 1.5rem;
    color: #667eea;
}

.remove-file-btn {
    background: #ff4757;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Replacement section */
.replacement-section h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.mode-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f3f4ff;
    border: 1px solid #e1e5e9;
    padding: 8px 12px;
    border-radius: 8px;
}

.replacement-pairs {
    margin-bottom: 25px;
}

.replacement-pair {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 15px;
    align-items: end;
    margin-bottom: 15px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.input-group input {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

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

.remove-pair-btn {
    background: #ff4757;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.remove-pair-btn:hover {
    background: #ff3742;
    transform: scale(1.05);
}

.translate-pane {
    background: #f8fff8;
    border: 1px solid #d6f5de;
    border-left: 4px solid #2ed573;
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.hint {
    margin-top: 10px;
    color: #4d6456;
    font-size: 0.9rem;
}


/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.add-pair-btn {
    background: #2ed573;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.add-pair-btn:hover {
    background: #26d466;
    transform: translateY(-2px);
}

.options {
    display: flex;
    gap: 25px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    color: #555;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

/* Process button */
.process-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

.process-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Progress section */
.progress-section {
    text-align: center;
    margin: 30px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e1e5e9;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

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

.progress-text {
    color: #666;
    font-size: 1rem;
}

/* Download section */
.download-section {
    text-align: center;
    padding: 30px;
    background: #f8fff8;
    border-radius: 15px;
    border: 2px solid #2ed573;
}

.success-message {
    margin-bottom: 25px;
}

.success-message i {
    font-size: 3rem;
    color: #2ed573;
    margin-bottom: 15px;
}

.success-message h3 {
    color: #333;
    margin-bottom: 10px;
}

.download-btn, .restart-btn {
    margin: 0 10px;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.download-btn {
    background: #2ed573;
    color: white;
}

.download-btn:hover {
    background: #26d466;
    transform: translateY(-2px);
}

.restart-btn {
    background: #667eea;
    color: white;
}

.restart-btn:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

/* Footer */
footer {
    text-align: center;
    color: white;
    opacity: 0.9;
}

.tech-info {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.tech-info span {
    background: rgba(255,255,255,0.1);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
}

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

.loading-spinner i {
    font-size: 3rem;
    color: white;
}

/* Table preview styles */
.preview-table table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
}
.preview-table th, .preview-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
    font-size: 0.95rem;
}
.preview-table th {
    background: #f5f7ff;
    font-weight: 700;
}
.preview-table tr:nth-child(even) td { background: #fafbff; }

/* Dark mode */
body.dark {
    color: #e6e6e6;
    background: linear-gradient(135deg, #1f1f2e 0%, #1a1f2e 100%);
}
body.dark main { background: #23263a; box-shadow: 0 20px 40px rgba(0,0,0,0.4); }
body.dark .file-upload-area { background: #2a2e46; border-color: #8ea2ff; }
body.dark .file-upload-area p, body.dark .progress-text { color: #d7dbff; }
body.dark .file-info { background: #2a2e46; }
body.dark .replacement-pair { background: #2a2e46; }
body.dark .input-group input, body.dark textarea#jsonGlossary { background: #1b1e2d; color: #e6e6e6; border-color: #3a3f5a; }
body.dark .preview-table th { background: #303552; }
body.dark .preview-table td { background: #2a2e46; border-color: #3a3f5a; }

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 25px;
    }
    
    .replacement-pair {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .options {
        justify-content: center;
    }
    
    .tech-info {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .file-upload-area {
        padding: 40px 15px;
    }
    
    .file-upload-area i {
        font-size: 2rem;
    }
    
    .browse-btn {
        padding: 12px 20px;
    }
    
    .download-btn, .restart-btn {
        width: 100%;
        margin: 5px 0;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-in {
    animation: slideIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}