/* Thông báo thời gian thực */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.notification {
    background-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateX(0);
    animation: slide-in 0.3s ease-out;
}

.notification.fade-out {
    opacity: 0;
    transform: translateX(30px);
}

.notification-content {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-left: 4px solid #2196F3;
}

.notification.success .notification-content {
    border-left-color: #4CAF50;
}

.notification.warning .notification-content {
    border-left-color: #FF9800;
}

.notification.danger .notification-content {
    border-left-color: #F44336;
}

.notification-icon {
    margin-right: 12px;
    font-size: 18px;
    color: #2196F3;
}

.notification.success .notification-icon {
    color: #4CAF50;
}

.notification.warning .notification-icon {
    color: #FF9800;
}

.notification.danger .notification-icon {
    color: #F44336;
}

.notification-content span {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #9e9e9e;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-left: 5px;
}

.notification-close:hover {
    color: #333;
}

@keyframes slide-in {
    from {
        transform: translateX(30px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Style for the connection status indicator */
#connection-status {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#connection-status.connected {
    background-color: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

#connection-status.disconnected {
    background-color: rgba(244, 67, 54, 0.15);
    color: #F44336;
}

#connection-status i {
    margin-right: 5px;
}

/* Base styles */
:root {
    --primary-color: #4a5568; /* Medium Gray */
    --primary-darker: #2d3748; /* Dark Gray */
    --primary-gradient: linear-gradient(135deg, #718096, #4a5568);
    --primary-hover-gradient: linear-gradient(135deg, #4a5568, #2d3748);

    --secondary-color: #a0aec0; /* Light Gray */
    
    --danger-color: #7f1d1d; /* Dark Red-Gray */
    --danger-darker: #5f1717; /* Very Dark Red-Gray */
    --danger-gradient: linear-gradient(135deg, #b91c1c, #991b1b); /* Subtle Red Gradient */
    --danger-hover-gradient: linear-gradient(135deg, #991b1b, #7f1d1d);

    --success-color: #047857; /* Emerald 700 */
    --success-darker: #065f46; /* Emerald 800 */
    --success-gradient: linear-gradient(135deg, #10b981, #059669); /* Emerald 500 -> 600 */
    --success-hover-gradient: linear-gradient(135deg, #059669, #047857); /* Emerald 600 -> 700 */

    --light-gray: #f7fafc; /* Very Light Gray/Off-white */
    --medium-gray: #e2e8f0; /* Light Border Gray */
    --dark-gray: #2d3748; /* Dark Text Gray */
    --border-color: #cbd5e0; /* Medium Border Gray */
    --focus-ring-color: rgba(113, 128, 150, 0.5); /* Gray focus ring */
    --focus-ring-width: 3px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark-gray);
    background-color: #fff;
    /* Add scaling */
    transform: scale(0.88); /* Adjusted to 95% */
    transform-origin: top left; /* Scale from top-left corner */
    /* Optional: Adjust width/height if needed after scaling */
    /* width: calc(100% / 0.95);
       height: calc(100% / 0.95); */
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    z-index: 100;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Navigation */
.navbar {
    background-color: var(--light-gray);
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-link {
    color: var(--dark-gray);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* Apply specific styles to navbar buttons */
.navbar .btn, /* Target general buttons in navbar */
.navbar .nav-link { /* Target nav-links acting as buttons */
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    background: var(--primary-gradient); /* Default gradient */
    color: white;
    border: none; /* Remove border for gradient buttons */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-decoration: none; /* Ensure no underline */
    display: inline-block; /* Ensure proper layout */
    vertical-align: middle; /* Align items nicely */
    cursor: pointer;
}

.navbar .btn:hover,
.navbar .nav-link:hover,
.navbar .btn:focus,
.navbar .nav-link:focus {
    background: var(--primary-hover-gradient); /* Default hover gradient */
    color: white;
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
    transform: translateY(-1px);
}

/* Specific style for New Job Button */
#newJobButton {
    background: var(--success-gradient);
}

#newJobButton:hover,
#newJobButton:focus {
    background: var(--success-hover-gradient);
}

/* General nav link hover (outside navbar context) */
.nav-link:hover,
.nav-link:focus { 
    background-color: var(--medium-gray); /* Use medium gray for general hover */
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

/* Main content */
main {
    padding: 2rem 0;
}

h1 {
    margin-bottom: 2rem;
    color: var(--dark-gray);
}

/* Form styles */
.upload-form {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2.5rem;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.upload-form:hover {
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: #495057;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color); /* Keep primary color for focus border */
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

.form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #6c757d;
}

/* Button styles */
.btn {
    display: inline-block;
    font-weight: 500;
    text-align: center;
    padding: 0.4rem 0.8rem;
    font-size: 0.95rem;
    line-height: 1.5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: var(--primary-hover-gradient);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #e2e8f0; /* Lighter gray for secondary */
    color: var(--dark-gray); /* Darker text for contrast */
    border: 1px solid #cbd5e0; /* Border for definition */
}

.btn-secondary:hover {
    background-color: #cbd5e0; /* Slightly darker on hover */
    border-color: #a0aec0;
    color: var(--primary-darker);
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-danger:hover {
    background: var(--danger-hover-gradient);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

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

/* Results container */
.results-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.results-container h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0;
    border-bottom: 2px solid var(--medium-gray);
}

.tab {
    font-size: 1.3rem;
    padding: 0.75rem 0;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--dark-gray);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

/* Specific inactive styles */
.tab:not(.active)#mistralTab {
    color: #c53030; /* Brighter Red for inactive Mistral */
}

.tab:not(.active)#macosTab {
    color: #dd6b20; /* Brighter Orange */
}

.tab:hover {
    color: var(--primary-darker);
}

.tab.active {
    color: var(--primary-darker);
    border-bottom-color: var(--primary-color);
}

/* Tab Descriptions */
.tab-descriptions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 0.25rem;
    margin-bottom: 1.5rem;
    padding: 0;
}

.tab-descriptions .description {
    font-size: 0.9rem;
    color: #000; /* Default/Active color (or maybe var(--dark-gray)?) */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
    flex-basis: 48%;
    transition: color 0.3s ease;
}

/* Color the descriptions based on associated inactive tab */
/* This assumes only one tab is active at a time */
#mistralTab:not(.active) ~ .tab-descriptions .description[data-controls="mistralResults"] {
    color: #c53030; /* Brighter Red for inactive Mistral description */
}
#macosTab:not(.active) ~ .tab-descriptions .description[data-controls="macosResults"] {
    color: #dd6b20; /* Brighter Orange for inactive Apple description */
}

.tab-descriptions .description:last-child {
    text-align: right;
}

/* Download buttons */
.download-buttons {
    display: inline-flex;
    gap: 0.3rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.2rem;
    background-color: #e9ecef; /* Slightly darker background */
}

.download-buttons button {
    margin: 0;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    line-height: 1.2;
    background-color: white;
    border: 1px solid transparent; /* Remove border */
    color: var(--secondary-color);
    transition: background-color 0.2s, color 0.2s;
}

.download-buttons button:hover {
    background-color: #f8f9fa; 
    color: var(--primary-darker);
}

/* Differentiating Action Button Colors/Styles */
.download-buttons button:nth-child(1) { /* Copy */
    border-left: 2px solid var(--primary-color);
}
.download-buttons button:nth-child(2) { /* MD */
    border-left: 2px solid #63b3ed; /* Blue */
}
.download-buttons button:nth-child(3) { /* HTML */
    border-left: 2px solid #f6ad55; /* Orange */
}
.download-buttons button:nth-child(4) { /* DOCX */
    border-left: 2px solid #4299e1; /* Darker Blue */
}
.download-buttons button:nth-child(5) { /* TXT */
    border-left: 2px solid #a0aec0; /* Gray */
}

/* Ensure icons inside download buttons have appropriate color */
.download-buttons button i {
    color: inherit; /* Inherit color from button */
    margin-right: 0.4em; /* Add space between icon and text */
    vertical-align: middle;
}

/* Remove extra padding added for icon-only */
.download-buttons button:not(.btn-copy-modal):not(.btn-copy) i {
   /* Optional: Add padding if icon feels too small */
   /* padding: 0.1em 0.2em; */ /* No longer needed */
}

/* Adjustments for the history table download buttons */
.history-table .actions .download-buttons {
    display: inline-flex;
    gap: 0.25rem;
    margin-right: 0.5rem;
    border: none;
    padding: 0;
    background: none;
}

.history-table .actions .download-buttons button {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.2rem;
    background-color: white;
    border: 1px solid var(--border-color);
}

.history-table .actions .download-buttons button:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

/* Result content - Tall Responsive Adaptive Viewer */
.result-content {
    padding: 1.5rem;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    line-height: 1.6;
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    
    /* Tall responsive sizing - restoring your preferred tall height */
    min-height: 900px; /* Your preferred tall minimum height */
    height: calc(100vh - 200px); /* Your preferred tall calculation */
    max-height: calc(100vh - 180px); /* Your preferred maximum height */
    
    /* Enhanced scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
    /* Prevent scroll propagation to parent */
    overscroll-behavior: contain;
}

/* Responsive breakpoints - maintaining tall height preference */
@media (min-width: 1200px) {
    /* Large desktop screens - keep it extra tall */
    .result-content {
        min-height: 950px;
        height: calc(100vh - 180px);
        max-height: calc(100vh - 160px);
    }
}

@media (max-width: 1199px) and (min-width: 768px) {
    /* Tablets - still tall but responsive */
    .result-content {
        min-height: 700px;
        height: calc(100vh - 250px);
        max-height: calc(100vh - 220px);
        padding: 1.25rem;
    }
}

@media (max-width: 767px) {
    /* Mobile phones - responsive but still generous height */
    .result-content {
        min-height: 500px;
        height: calc(100vh - 300px);
        max-height: calc(100vh - 280px);
        padding: 1rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    /* Small mobile phones - minimum viable tall height */
    .result-content {
        min-height: 400px;
        height: calc(100vh - 350px);
        max-height: calc(100vh - 320px);
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

/* Special maximized sizing for modal result content */
.modal .result-content {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
}

.result-content::-webkit-scrollbar {
    width: 6px;
}

.result-content::-webkit-scrollbar-track {
    background: transparent;
}

.result-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.result-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Markdown Content Styling */
.result-content.markdown-content {
    white-space: normal;
    word-wrap: break-word;
}

.result-content.plain-text {
    white-space: pre-wrap;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
}

/* Markdown Typography */
.result-content h1,
.result-content h2,
.result-content h3,
.result-content h4,
.result-content h5,
.result-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: #1a202c;
}

.result-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.result-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.3rem;
}

.result-content h3 {
    font-size: 1.25rem;
}

.result-content h4 {
    font-size: 1.125rem;
}

.result-content h5,
.result-content h6 {
    font-size: 1rem;
}

.result-content p {
    margin-bottom: 1rem;
    color: #2d3748;
}

.result-content strong {
    font-weight: 600;
    color: #1a202c;
}

.result-content em {
    font-style: italic;
    color: #4a5568;
}

.result-content code {
    background: #f7fafc;
    color: #e53e3e;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.result-content pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

.result-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Lists */
.result-content ul,
.result-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.result-content li {
    margin-bottom: 0.5rem;
}

.result-content ul li {
    list-style-type: disc;
}

.result-content ol li {
    list-style-type: decimal;
}

/* Tables */
.result-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: #ffffff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.result-content th,
.result-content td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.result-content th {
    background: #f7fafc;
    font-weight: 600;
    color: #2d3748;
    border-bottom: 2px solid #cbd5e0;
}

.result-content tbody tr:hover {
    background: #f8f9fa;
}

.result-content tbody tr:last-child td {
    border-bottom: none;
}

/* Blockquotes */
.result-content blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid #4299e1;
    background: #ebf8ff;
    color: #2c5282;
    font-style: italic;
}

/* Links */
.result-content a {
    color: #3182ce;
    text-decoration: underline;
    text-decoration-color: rgba(49, 130, 206, 0.4);
    transition: all 0.2s;
}

.result-content a:hover {
    color: #2c5282;
    text-decoration-color: #2c5282;
}

/* Horizontal Rules */
.result-content hr {
    margin: 2rem 0;
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #cbd5e0, transparent);
}

.large-text {
    font-size: 1.2rem !important;
}

/* Progress section */
.progress-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.progress {
    height: 1.5rem;
    background-color: #e9ecef;
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background-color: #007bff;
    transition: width 0.3s ease;
}

.status-message {
    font-size: 1.1rem;
    color: #495057;
    margin: 1rem 0;
}

/* Error display */
.alert-danger {
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    border-radius: 4px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Ensure these table styles apply generally */
.history-table td {
    vertical-align: middle;
    padding: 1rem 1.5rem;
    border: 1px solid var(--border-color);
    background-color: white;
}

.history-table tbody tr:nth-child(even) td {
    background-color: #f8f9fa;
}

.history-table tbody tr:hover td {
    background-color: #e9ecef;
}

.history-table th {
    padding: 1rem 1.5rem;
    background-color: #e2e8f0;
    font-weight: 600;
    text-align: left;
    border: 1px solid var(--border-color);
}

/* Responsive adjustments */
/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    animation: modalFadeIn 0.3s ease-out;
}

.modal:not([hidden]) {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden; /* Prevent outer scroll */
}

/* Force modal to show when not hidden */
.modal[style*="display: flex"],
.modal[style*="display: block"] {
    display: flex !important;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 95vw; /* Use most of screen width */
    height: 90vh; /* Use most of screen height */
    max-width: none;
    max-height: none;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem 2rem; /* Reduced padding for more content space */
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: #495057;
    font-size: 1.5rem;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.2s ease;
}

.close-button:hover {
    background-color: #f8f9fa;
    color: #495057;
    transform: scale(1.1);
}

.modal-body {
    padding: 0;
    overflow: hidden; /* No scroll on modal body */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex children to shrink */
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

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

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .navbar .container {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    h1 {
        font-size: 1.8rem;
    }
    
    .upload-form {
        padding: 1rem;
    }

    .history-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .download-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .download-buttons button,
    .download-btn {
        width: 100%;
        text-align: center;
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .history-table th,
    .history-table td {
        padding: 0.5rem;
    }

    .modal-content {
        max-width: 95%;
        margin: 1rem auto;
    }

    .history-table .actions {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 2px;
    }
    
    .history-table .actions .download-buttons {
        flex: 0 0 auto;
        gap: 1px;
    }
    
    .history-table .actions .download-buttons button {
        padding: 3px 5px;
        min-width: 28px;
        font-size: 0.75rem;
    }
    
    .history-table .actions .btn {
        padding: 3px 6px;
        font-size: 0.75rem;
    }
}

/* Focus visible polyfill */
:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

:focus-visible {
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

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

.results-container,
.progress-section,
.alert {
    table {
        width: 100%;
        border-collapse: collapse;
        margin: 1rem 0;
        background: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    th, td {
        padding: 1rem;
        text-align: left;
        border-bottom: 1px solid var(--border-color);
    }

    th {
        background-color: #f8f9fa;
        font-weight: 600;
    }

    tr:hover {
        background-color: #f8f9fa;
    }

    @media (max-width: 768px) {
        .container {
            padding: 0 0.5rem;
        }
        
        .download-buttons {
            flex-direction: column;
        }
        
        .download-btn {
            width: 100%;
        }
        
        table {
            display: block;
            overflow-x: auto;
        }
    }

    .history-actions {
        margin-bottom: 1.5rem;
        display: flex;
        gap: 0.75rem;
    }

    .history-table {
    }

    .history-table thead th:first-child,
    .history-table tbody td:first-child {
        width: 40px;
        text-align: center;
    }

    .history-table td {
        vertical-align: middle;
        padding: 1rem 1.5rem;
        border: 1px solid var(--border-color);
        background-color: white;
    }

    .history-table tbody tr:nth-child(even) td {
        background-color: #f8f9fa;
    }
    
    .history-table tbody tr:hover td {
        background-color: #e9ecef;
    }

    .history-table th {
        padding: 1rem 1.5rem;
        background-color: #e2e8f0;
        font-weight: 600;
        text-align: left;
        border: 1px solid var(--border-color);
    }

    .history-table .actions {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 5px;
    }

    .history-table .actions .download-buttons {
        display: flex;
        flex-wrap: nowrap;
        margin-right: 5px;
        gap: 2px;
        align-items: center;
    }

    .history-table .actions .download-buttons button {
        padding: 4px 6px;  /* Make buttons smaller */
        min-width: 30px;
        font-size: 0.8rem;
    }

    .history-table .actions .btn {
        padding: 4px 8px;  /* Make View and Delete buttons smaller */
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Specific Column Spacing & Styling */
    .history-table .status-col {
        /* font-weight: 600; */ /* Optional: Make status bold */
    }
    .history-table .source-col {
        padding-left: 3rem; /* Add extra padding before Source column */
        /* font-style: italic; */ /* Optional: Italicize source */
    }

    /* Status Colors */
    .history-table .status-complete {
        color: var(--success-color); /* Dark Green-Gray */
        font-weight: 600;
    }
    .history-table .status-error {
        color: var(--danger-color); /* Dark Red-Gray */
        font-weight: 600;
    }
    .history-table .status-processing,
    .history-table .status-upload /* Add other potential statuses */ {
        color: var(--primary-color); /* Medium Gray */
    }

    /* Source Colors (Subtle) */
    .history-table .source-both {
        color: var(--primary-darker); /* Dark Gray */
        font-weight: 600;
    }
    .history-table .source-mistral {
        color: #0056b3; /* Example: A distinct blue */
    }
     .history-table .source-apple {
        color: #5a6268; /* Example: A distinct gray */
    }
}

.small-info-icon {
    font-size: 0.8em; /* Smaller icon */
    color: #6c757d; /* Subtle color */
    margin-left: 0.4em;
    vertical-align: middle;
}

/* Simple CSS Tooltip based on title attribute */
[title]:hover::after {
    content: attr(title); 
    position: absolute;
    bottom: 100%; 
    left: 50%;
    transform: translateX(-50%); 
    white-space: nowrap;
    background-color: var(--dark-gray); /* Use dark gray */
    color: #fff; 
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    z-index: 10;
    margin-bottom: 5px; 
}

[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(5px); 
    border: 5px solid transparent;
    border-top-color: var(--dark-gray); /* Match tooltip background */
    z-index: 11;
    margin-bottom: 0px; 
}

/* Styles for the new Home button */
.btn-home {
    background: linear-gradient(135deg, #4b76a4, #436ca4); /* Dark blue gradient */
    color: white;
    /* margin-right: auto; */ /* Removed to allow center alignment of brand */
    padding: 0.6rem 1.2rem; /* Match other navbar buttons */
    font-weight: 600; /* Match other navbar buttons */
    text-decoration: none; /* Remove underline from link */
    border-radius: 6px;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease-in-out;
}

.btn-home:hover,
.btn-home:focus {
    background: linear-gradient(135deg, #1a365d, #152a4a); /* Darker blue gradient */
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    outline: none;
}

/* Container for right-aligned buttons */
.navbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Space between buttons */
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.2rem;
}

/* Service Status Indicators */
.service-status-container {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.service-status {
    flex: 1;
    min-width: 280px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem; /* Reduced padding */
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Reduced gap */
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.service-card {
    cursor: default;
}

.service-card.complete:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.service-card.clickable {
    cursor: pointer;
    border: 2px solid transparent;
}

.service-card.clickable:hover {
    border-color: #007bff;
}

.service-status.processing {
    border-color: #007bff;
    background: #e3f2fd;
}

.service-status.complete {
    border-color: #28a745;
    background: linear-gradient(135deg, #e8f5e9, #f1f9f1);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.service-status.error {
    border-color: #dc3545;
    background: linear-gradient(135deg, #ffebee, #ffeaea);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
    opacity: 0.7;
}

.service-status.skipped {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fffbf0, #fff8e1);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.15);
    opacity: 0.8;
}

.service-icon {
    font-size: 2rem;
    color: #6c757d;
    min-width: 3rem;
    text-align: center;
}

.service-status.processing .service-icon {
    color: #007bff;
    animation: pulse 2s infinite;
}

.service-status.complete .service-icon {
    color: #28a745;
}

.service-status.error .service-icon {
    color: #dc3545;
}

.service-status.skipped .service-icon {
    color: #ffc107;
}

.service-info {
    flex: 1;
}

.service-info h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #333;
}

.service-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.progress-mini {
    flex: 1;
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-mini {
    height: 100%;
    background-color: #007bff;
    transition: width 0.3s ease;
}

.service-status.complete .progress-bar-mini {
    background-color: #28a745;
}

.service-status.error .progress-bar-mini {
    background-color: #dc3545;
}

.service-status.skipped .progress-bar-mini {
    background-color: #ffc107;
}

.service-percentage {
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

.service-message {
    margin: 0;
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.4;
}

.service-status-badge {
    font-size: 1.5rem;
    color: #6c757d;
}

.service-status.processing .service-status-badge {
    color: #007bff;
}

.service-status.complete .service-status-badge {
    color: #28a745;
}

.service-status.error .service-status-badge {
    color: #dc3545;
}

.service-status.skipped .service-status-badge {
    color: #ffc107;
}

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

.service-actions {
    margin-top: 0.75rem;
    text-align: center;
}

.btn-view-results {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.btn-view-results:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.completion-message {
    text-align: center;
    padding: 1rem;
    margin: 1rem 0;
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    color: #155724;
    font-size: 1.1rem;
    font-weight: 500;
    animation: fadeIn 0.5s ease-in;
}

.completion-message i {
    color: #28a745;
    margin-right: 0.5rem;
    font-size: 1.2rem;
}

.results-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.btn-back {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
    border: none;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: linear-gradient(135deg, #545b62, #454d55);
    transform: translateY(-1px);
    color: white;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.results-header h2 {
    margin: 0;
    text-align: center;
}

.service-navigation-container {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 1.5rem 0.5rem 1.5rem; /* Minimal margins */
    padding: 0;
    flex-wrap: wrap;
    flex-shrink: 0; /* Don't shrink in modal */
}

.results-nav-card {
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.results-nav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    opacity: 1;
    border-color: #007bff;
}

.results-nav-card.active {
    border-color: #007bff;
    opacity: 1;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.2);
}

.results-nav-card.complete {
    border-color: #28a745;
    background: linear-gradient(135deg, #e8f5e9, #f1f9f1);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.results-nav-card.error {
    border-color: #dc3545;
    background: linear-gradient(135deg, #ffebee, #ffeaea);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
    opacity: 0.6;
    cursor: not-allowed;
}

.results-nav-card.skipped {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fffbf0, #fff8e1);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.15);
    opacity: 0.6;
}

/* Service Cards Section - Always Visible */
.service-cards-section {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.service-cards-section .service-status-container {
    margin: 0;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.service-cards-section .service-card {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.8;
    position: relative;
}

.service-cards-section .service-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    opacity: 1;
    border-color: #007bff;
}

.service-cards-section .service-card.active {
    border-color: #007bff;
    opacity: 1;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.2);
    transform: translateY(-1px);
}

.service-cards-section .service-card.complete {
    border-color: #28a745;
    background: linear-gradient(135deg, #e8f5e9, #f1f9f1);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
    cursor: pointer;
    opacity: 1;
}

.service-cards-section .service-card.error {
    border-color: #dc3545;
    background: linear-gradient(135deg, #ffebee, #ffeaea);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
    opacity: 0.6;
    cursor: not-allowed;
}

.service-cards-section .service-card.processing {
    border-color: #17a2b8;
    background: linear-gradient(135deg, #e1f7fa, #bee5eb);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.15);
    opacity: 1;
    cursor: not-allowed;
}

.service-cards-section .service-card.skipped {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fffbf0, #fff8e1);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.15);
    opacity: 0.6;
    cursor: not-allowed;
}

/* Result Panels */
.tab-panel {
    flex: 1; /* Fill all remaining space */
    margin: 0 1.5rem 0.5rem 1.5rem; /* Minimal margins */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Allow content to shrink */
}

.tab-panel[hidden] {
    display: none !important;
}

/* Download Actions */
.download-actions-container {
    margin: 0.5rem 1.5rem 0.5rem 1.5rem; /* Minimal margins */
    padding: 0.75rem; /* Compact padding */
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0; /* Don't shrink in modal */
}

.download-actions-container h3 {
    margin: 0 0 0.5rem 0;
    text-align: center;
    color: #495057;
    font-size: 1.3rem;
    font-weight: 600;
}

.download-service-indicator {
    margin: 0 0 1.5rem 0;
    text-align: center;
    font-size: 0.95rem;
    color: #6c757d;
    font-style: italic;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.download-service-indicator.mistral-indicator {
    color: #4a5568;
    background: linear-gradient(135deg, rgba(74, 85, 104, 0.1), rgba(74, 85, 104, 0.05));
    border-left: 4px solid #4a5568;
    border-color: rgba(74, 85, 104, 0.2);
}

.download-service-indicator.macos-indicator {
    color: #2d3748;
    background: linear-gradient(135deg, rgba(45, 55, 72, 0.1), rgba(45, 55, 72, 0.05));
    border-left: 4px solid #2d3748;
    border-color: rgba(45, 55, 72, 0.2);
}

.download-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.download-card {
    flex: 1;
    min-width: 160px;
    max-width: 200px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.download-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-color: #007bff;
}

.download-card:active {
    transform: translateY(-1px);
}

.download-icon {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
    color: #6c757d;
    transition: color 0.3s ease;
}

.download-card:hover .download-icon {
    color: #007bff;
}

/* Specific icon colors */
.download-icon.markdown {
    color: #0366d6;
}

.download-card:hover .download-icon.markdown {
    color: #0056b3;
}

.download-icon.html {
    color: #e34c26;
}

.download-card:hover .download-icon.html {
    color: #d63200;
}

.download-icon.docx {
    color: #2b579a;
}

.download-card:hover .download-icon.docx {
    color: #1a365d;
}

.download-icon.txt {
    color: #6c757d;
}

.download-card:hover .download-icon.txt {
    color: #495057;
}

.download-info h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.download-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #6c757d;
    line-height: 1.4;
}

.download-card.disabled,
.download-card:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    border-color: #dee2e6 !important;
    pointer-events: none;
}

.download-card.disabled:hover,
.download-card:disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: #dee2e6;
}

.download-card.disabled .download-icon,
.download-card:disabled .download-icon,
.download-card.unavailable .download-icon {
    color: #6c757d !important;
}

.download-card.unavailable {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    border-color: #dee2e6 !important;
    pointer-events: none;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

.download-card.unavailable:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: #dee2e6;
}

.download-card.unavailable .download-info h4 {
    color: #adb5bd;
}

.download-card.unavailable .download-info p {
    color: #ced4da;
}

/* Responsive design for service status */
@media (max-width: 768px) {
    .service-status-container {
        flex-direction: column;
    }
    
    .service-status {
        min-width: auto;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .download-cards {
        flex-direction: column;
        align-items: center;
    }
    
    .download-card {
        max-width: 280px;
        width: 100%;
    }
}
