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

html,
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ===== Layout ===== */
#app {
    min-height: 100vh;
}

.section {
    background-color: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 40px 0;
}

.section:first-child {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 60px 0;
}

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

/* ===== Typography ===== */
h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 600;
}

h2 {
    font-size: 2em;
    margin-bottom: 10px;
    color: #333;
}

h3 {
    font-size: 1.3em;
    margin-bottom: 15px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 30px;
}

#input-section .subtitle {
    opacity: 0.95;
}

/* ===== Input Section ===== */
.input-group {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.file-input {
    flex: 1;
    min-width: 300px;
}

.file-input label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.file-input input[type="file"] {
    display: block;
    width: 100%;
    padding: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    margin-bottom: 8px;
}

.file-input input[type="file"]::file-selector-button {
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 10px;
}

.file-input input[type="file"]::file-selector-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.file-name {
    font-size: 0.9em;
    opacity: 0.8;
    display: block;
}

/* ===== Buttons ===== */
.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

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

.btn-secondary:hover {
    background-color: #555;
}

.btn-warning {
    background-color: #f44336;
    color: white;
}

.btn-warning:hover {
    background-color: #da190b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

/* ===== Loading Spinner ===== */
.loading {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.1em;
}

.spinner {
    border: 4px solid rgba(102, 126, 234, 0.1);
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Progress Bar */
.progress-container {
    width: 100%;
    max-width: 500px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background-color: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

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

.progress-text {
    text-align: center;
    font-size: 0.95em;
    color: #667eea;
    font-weight: 500;
}

/* ===== Matrix Section ===== */
.matrix-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    max-height: 800px;
    overflow-y: auto;
    position: relative;
}

/* Removed media query to keep columns side-by-side */

.matrix-column {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
}

.alignment-column {
    display: none;
}

@media (max-width: 1200px) {
    .alignment-column {
        display: none;
    }
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    position: sticky;
    top: -20px;
    background-color: white;
    z-index: 10;
}

.column-header h3 {
    margin: 0;
}

.btn-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    color: #667eea;
}

.btn-toggle input[type="checkbox"] {
    cursor: pointer;
}

/* ===== Chapter Entry ===== */
.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chapter-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    height: 70px;
    flex-shrink: 0;
    overflow: hidden;
}

.chapter-entry.chapter-inactive {
    opacity: 0.6;
    background-color: #ffebee;
    border-color: #f44336;
}

.chapter-entry.chapter-active {
    background-color: #f1f8f4;
    border-color: #4caf50;
}

.chapter-entry:hover {
    border-color: #667eea;
    background-color: #f5f7ff;
    transform: translateX(4px);
}

.chapter-entry.dragging {
    opacity: 0.4;
    border-style: dashed;
    transform: scale(0.98);
}

.chapter-entry.drag-over {
    border-top: 4px solid #667eea;
    background-color: #e8eaf6;
}

.chapter-entry.chapter-inactive:hover {
    background-color: #ffcdd2;
}

.chapter-entry.chapter-active:hover {
    background-color: #e8f5e9;
}

.chapter-info {
    flex: 1;
    min-width: 0;
}

.chapter-info h3 {
    margin: 0;
    font-size: 1em;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
    max-height: 2.4em;
}

.chapter-info small {
    display: block;
    color: #666;
    font-size: 0.85em;
}

.chapter-entry.alignment-success {
    border-color: #4caf50;
    background-color: #f1f8f4;
}

.chapter-entry.alignment-warning {
    border-color: #ff9800;
    background-color: #fff3f0;
}

.chapter-entry.alignment-error {
    border-color: #f44336;
    background-color: #ffebee;
}

/* ===== Alignment Display ===== */
.alignment-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.alignment-arrow {
    font-size: 1.5em;
    color: #667eea;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.alignment-arrow.orphaned {
    color: #f44336;
}

/* ===== Error Message ===== */
.error-message {
    background-color: #ffebee;
    border-left: 4px solid #f44336;
    color: #c62828;
    padding: 16px;
    margin: 20px;
    border-radius: 4px;
    font-weight: 500;
}

/* ===== Scrollbar Styling ===== */
.chapter-list::-webkit-scrollbar {
    width: 8px;
}

.chapter-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chapter-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.chapter-list::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.4em;
    }

    .input-group {
        flex-direction: column;
        gap: 20px;
    }

    .file-input {
        min-width: 100%;
    }

    .matrix-container {
        padding: 10px;
    }

    .matrix-column {
        padding: 15px;
    }
}

/* ===== Fixed Bottom Progress Bar ===== */
.bottom-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.progress-info {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.progress-status {
    font-size: 1.1em;
    font-weight: 600;
}

.progress-time {
    font-size: 0.9em;
    opacity: 0.9;
    font-style: italic;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 15px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    .progress-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-time {
        font-size: 0.8em;
    }
}

/* ===== Machine Translation Options Panel ===== */
.translation-options-panel {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.toggle-container label {
    font-size: 1.1em;
    cursor: pointer;
}

.mt-settings-panel {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeIn 0.3s ease-out;
}

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

.settings-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.setting-item {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-weight: 600;
    font-size: 0.95em;
}

.setting-item select,
.setting-item input {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.3s;
}

.setting-item select option {
    background-color: #764ba2;
    color: white;
}

.setting-item select:focus,
.setting-item input:focus {
    border-color: #00f2fe;
}

/* Greyed-out state for translation container when machine translation is enabled */
.file-input.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.file-input.disabled input[type="file"] {
    cursor: not-allowed;
}