/**
 * AI Product Data Auto-Fill CSS Styles
 * Extracted from JavaScript for better code organization
 */

.ai-modal-tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    background: #f8f9fa;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.ai-modal-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.ai-modal-tab:hover {
    background: #e9ecef;
    color: #495057;
}

.ai-modal-tab.active {
    background: white;
    color: #495057;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.ai-tab-content {
    padding: 25px;
    background: white;
}

.ai-search-option-info {
    margin-bottom: 25px;
}

.ai-search-option-info h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 18px;
    font-weight: 600;
}

.ai-search-option-info p {
    margin: 0 0 15px 0;
    color: #6c757d;
    line-height: 1.5;
}

.ai-search-benefits {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
}

.ai-search-benefits strong {
    color: #495057;
}

.ai-search-benefits ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
}

.ai-search-benefits li {
    margin-bottom: 5px;
    color: #495057;
}

.ai-search-action {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.ai-autofill-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 180px;
}

.ai-autofill-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ai-new-search-button {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 180px;
}

.ai-new-search-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Make tabs container relative for absolute positioning */
.tabs {
    position: relative;
}

.ai-window {
    position: absolute;
    width: 450px;
    max-width: 800px;
    max-height: 90vh;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: visible;
    background: white;
    border: 1px solid #dee2e6;
}

.ai-window.dragging {
    cursor: move;
    opacity: 0.9;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
}

.ai-window-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 90vh;
}

.ai-window-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.ai-window-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-window-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ai-window-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile touch target improvements */
@media (max-width: 768px) {
    .ai-window-close {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}

.ai-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.ai-loading {
    text-align: center;
    padding: 40px;
}

.ai-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-field {
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
}

.ai-field-readonly {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.ai-field-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
}

.ai-field-checkbox input {
    margin-right: 8px;
}

.ai-field-preview {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    position: relative;
}

.ai-field-preview::-webkit-scrollbar {
    width: 8px;
}

.ai-field-preview::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ai-field-preview::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.ai-field-preview::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.ai-modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.ai-apply-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
}

.ai-cancel-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
}

.ai-error {
    color: #dc3545;
    padding: 20px;
    text-align: center;
}

.ai-search-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 12px;
    margin-bottom: 15px;
}

.ai-cache-info {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 8px;
}

.ai-fresh-info {
    color: #28a745;
    font-size: 14px;
    margin-bottom: 8px;
}

.ai-search-queries {
    margin-top: 8px;
    font-size: 13px;
}

.ai-search-queries ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

.ai-search-queries li {
    color: #495057;
    font-style: italic;
}

.ai-search-sources {
    margin-top: 8px;
    font-size: 13px;
}

.ai-search-sources ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

.ai-search-sources a {
    color: #007bff;
    text-decoration: none;
}

.ai-search-sources a:hover {
    text-decoration: underline;
}

.ai-source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ai-show-domains-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.ai-show-domains-btn:hover {
    background: #0056b3;
}

.ai-source-domains {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
}

.ai-source-domains ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

.domain-name {
    color: #1a73e8;
    font-weight: 500;
    font-family: monospace;
}

.ai-citations-list {
    margin: 5px 0 0 20px;
    padding: 0;
}

.ai-search-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
    font-size: 13px;
}

/* Confidence badges */
.ai-confidence-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: center;
}

.ai-confidence-ean-priority {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.ai-confidence-official {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ai-confidence-fallback {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.ai-confidence-unknown {
    background-color: #e2e3e5;
    color: #383d41;
    border: 1px solid #d1d3d6;
}

/* Fallback data warning */
.ai-fallback-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.4;
}

.ai-fallback-warning strong {
    color: #721c24;
}

/* Prevent text selection while dragging */
.ai-window.dragging * {
    user-select: none;
}

/* Responsive design for modal */
@media (max-width: 1199px) {
    .ai-window {
        width: 90%;
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .ai-window {
        width: 95%;
        max-width: none;
    }
    
    .ai-modal-tab {
        font-size: 13px;
        padding: 12px 15px;
    }
    
    .ai-tab-content {
        padding: 20px;
    }
    
    .ai-search-option-info h4 {
        font-size: 16px;
    }
    
    .ai-search-option-info p {
        font-size: 14px;
    }
    
    .ai-autofill-button,
    .ai-new-search-button {
        width: 100%;
        max-width: 250px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Action buttons styling */
.ai-action-buttons {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e9ecef;
}

.btn-report, .btn-diff {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-report:hover, .btn-diff:hover {
    background: #5a6268;
}

.btn-report.reported {
    background: #28a745;
    cursor: not-allowed;
}

.btn-diff {
    background: #007bff;
}

.btn-diff:hover {
    background: #0056b3;
}

/* Diff modal styling */
.ai-diff-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-diff-modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.ai-diff-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-diff-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-diff-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.ai-diff-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
}

.diff-field {
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
}

.diff-field h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 16px;
}

.diff-content {
    font-family: monospace;
    font-size: 14px;
    line-height: 1.4;
}

.diff-insert {
    background: #d4fcbc;
    color: #155724;
    padding: 8px;
    border-radius: 3px;
    margin-bottom: 8px;
    border-left: 4px solid #28a745;
}

.diff-delete {
    background: #fbb6c2;
    color: #721c24;
    padding: 8px;
    border-radius: 3px;
    margin-bottom: 8px;
    border-left: 4px solid #dc3545;
    text-decoration: line-through;
}

.diff-equal {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 3px;
    color: #495057;
}

@media (max-width: 768px) {
    .ai-diff-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .ai-diff-modal-body {
        padding: 15px;
    }
    
    .diff-field {
        padding: 10px;
    }
}

/* Technical specifications formatting preservation */
textarea[name="spec"] {
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
    tab-size: 4;
}

/* CKEditor content area formatting for technical specs */
.cke_contents iframe body {
    white-space: pre-wrap;
}

/* Ensure CKEditor preserves line breaks in technical content */
#mce1_contents {
    white-space: pre-wrap;
}

/* Style for displayed technical specs to preserve formatting */
.spec-content,
.technical-info,
[data-field="spec"] {
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

/* Enhanced AI field preview for spec data */
.ai-field-preview[data-field="spec"] {
    font-family: 'Courier New', monospace;
    background: #f1f3f4;
    border-left: 3px solid #007bff;
}

/* Ensure line breaks are preserved in any technical specification display */
.technical-specifications,
.product-specs,
.spec-display {
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

/* ===== ENHANCED SOURCE SELECTION UI/UX ===== */

/* Source selection container improvements */
.ai-source-selection {
    padding: 25px;
}

.ai-source-selection-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.ai-source-selection-header h4 {
    color: #495057;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-source-selection-header p {
    color: #6c757d;
    font-size: 16px;
    margin: 0;
    line-height: 1.5;
}

/* Enhanced source cards */
.ai-sources-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 25px;
}

.ai-source-card {
    position: relative;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ai-source-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.ai-source-card.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.ai-source-card.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Hide default radio buttons */
.ai-source-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-source-card-content {
    display: block;
    padding: 20px;
    cursor: pointer;
    position: relative;
}

/* Source header with improved layout */
.ai-source-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 15px;
}

.ai-source-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.3;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Enhanced confidence badges */
.ai-source-confidence-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-confidence-official {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(72, 187, 120, 0.3);
}

.ai-confidence-trusted {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.ai-confidence-general {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(113, 128, 150, 0.3);
}

/* Source description with better typography */
.ai-source-description {
    color: #4a5568;
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 16px 0;
    padding-left: 4px;
}

/* Enhanced URL styling */
.ai-source-url {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.ai-source-url small {
    display: block;
    font-size: 14px;
}

.ai-source-url a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease;
    word-break: break-all;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.ai-source-url a:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    color: #5a67d8;
    transform: translateX(2px);
}

.ai-source-url a::after {
    content: '↗️';
    font-size: 12px;
    opacity: 0.7;
}

/* Selection indicator */
.ai-source-card.active .ai-source-card-content::after {
    content: '✓';
    position: absolute;
    top: 15px;
    right: 15px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    animation: checkmarkBounce 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkmarkBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Source type icons enhancement */
.ai-source-header h5::before {
    font-size: 20px;
    margin-right: 4px;
}

/* Action buttons improvements */
.ai-source-selection-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 2px solid #e9ecef;
    margin-top: 20px;
}

/* Translation options styling */
.ai-translation-options {
    width: 100%;
    margin-bottom: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.ai-checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.ai-checkbox-option input[type="checkbox"] {
    margin: 0;
    margin-top: 2px;
}

.ai-checkbox-text {
    font-weight: 500;
    color: #495057;
    line-height: 1.3;
}

.ai-option-help {
    display: block;
    color: #6c757d;
    font-size: 0.85em;
    margin-top: 4px;
    margin-left: 20px;
}

.ai-extract-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.ai-extract-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ai-extract-button:disabled {
    background: #e2e8f0;
    color: #a0aec0;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.ai-back-button {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.ai-back-button:hover {
    background: #667eea;
    color: white;
    transform: translateX(-2px);
}

/* Mobile responsiveness for source cards */
@media (max-width: 768px) {
    .ai-sources-list {
        gap: 12px;
    }
    
    .ai-source-card-content {
        padding: 16px;
    }
    
    .ai-source-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .ai-source-header h5 {
        font-size: 16px;
    }
    
    .ai-source-confidence-badge {
        align-self: flex-start;
        font-size: 12px;
        padding: 4px 10px;
    }
    
    .ai-source-description {
        font-size: 14px;
    }
    
    .ai-source-url a {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .ai-source-selection-actions {
        flex-direction: column;
    }
    
    .ai-extract-button {
        padding: 14px 20px;
        font-size: 14px;
    }
}

/* ===== ENHANCED INTERACTIVE ELEMENTS ===== */

/* Focus states for accessibility */
.ai-source-card:focus-within {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.ai-source-url a:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Enhanced button hover states */
.ai-autofill-button, .ai-new-search-button, .ai-extract-button {
    position: relative;
    overflow: hidden;
}

.ai-autofill-button::before, 
.ai-new-search-button::before, 
.ai-extract-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.ai-autofill-button:hover::before, 
.ai-new-search-button:hover::before, 
.ai-extract-button:hover:not(:disabled)::before {
    left: 100%;
}

/* Enhanced modal tab interactions */
.ai-modal-tab {
    position: relative;
    overflow: hidden;
}

.ai-modal-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.ai-modal-tab:hover::after {
    width: 80%;
}

.ai-modal-tab.active::after {
    width: 100%;
}

/* Enhanced form element states */
.ai-field-checkbox {
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 8px;
    margin: -8px;
}

.ai-field-checkbox:hover {
    background: #f8f9fa;
    transform: translateX(4px);
}

.ai-field-checkbox input[type="checkbox"] {
    transform: scale(1.2);
    transition: all 0.2s ease;
}

.ai-field-checkbox input[type="checkbox"]:checked {
    accent-color: #667eea;
}

/* Enhanced close button interactions */
.ai-window-close {
    position: relative;
    overflow: hidden;
}

.ai-window-close::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.ai-window-close:hover::before {
    width: 100%;
    height: 100%;
}

/* Enhanced confidence badge interactions */
.ai-source-confidence-badge {
    transition: all 0.3s ease;
    cursor: default;
}

.ai-source-confidence-badge:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Enhanced loading spinner */
.ai-spinner {
    position: relative;
}

.ai-spinner::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid transparent;
    border-top: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    animation: spin 2s linear infinite reverse;
}

/* Enhanced dropdown and select interactions */
select, input[type="text"], input[type="number"], textarea {
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
}

select:focus, input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
    transform: translateY(-1px);
}

select:hover, input[type="text"]:hover, input[type="number"]:hover, textarea:hover {
    border-color: #cbd5e0;
}

/* Enhanced action button group */
.ai-source-selection-actions {
    position: relative;
}

.ai-source-selection-actions::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-source-selection-actions:hover::before {
    opacity: 1;
}

/* ===== ENHANCED MOBILE RESPONSIVENESS & TOUCH TARGETS ===== */

/* Ensure minimum 44px touch targets for mobile */
@media (max-width: 768px) {
    /* Touch-friendly buttons */
    .ai-autofill-button, 
    .ai-new-search-button, 
    .ai-extract-button {
        min-height: 44px;
        padding: 14px 24px;
        font-size: 16px; /* Prevents zoom on iOS */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Touch-friendly modal tabs */
    .ai-modal-tab {
        min-height: 44px;
        padding: 15px 20px;
        font-size: 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Touch-friendly source cards */
    .ai-source-card {
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .ai-source-card-content {
        padding: 20px;
        min-height: 44px;
    }
    
    /* Touch-friendly URLs */
    .ai-source-url a {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Touch-friendly checkboxes */
    .ai-field-checkbox {
        min-height: 44px;
        padding: 12px;
        margin: 4px 0;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .ai-field-checkbox input[type="checkbox"] {
        min-width: 20px;
        min-height: 20px;
        transform: scale(1.5);
    }
    
    /* Touch-friendly form elements */
    select, input[type="text"], input[type="number"], textarea {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        touch-action: manipulation;
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    /* Touch-friendly modal footer buttons */
    .ai-apply-btn, .ai-cancel-btn {
        min-height: 44px;
        padding: 12px 24px;
        font-size: 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Touch-friendly back button */
    .ai-back-button {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Touch-friendly confidence badges */
    .ai-source-confidence-badge {
        min-height: 32px;
        padding: 8px 16px;
        font-size: 14px;
    }
    
    /* Touch-friendly report and diff buttons */
    .btn-report, .btn-diff {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        margin-bottom: 8px;
    }
    
    /* Enhanced modal positioning for mobile */
    .ai-window {
        width: 95vw;
        height: auto;
        max-height: 90vh;
        margin: 5vh auto;
        position: fixed;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }
    
    /* Mobile-optimized modal header */
    .ai-window-header {
        padding: 16px 20px;
        min-height: 60px;
    }
    
    .ai-window-header h3 {
        font-size: 18px;
        line-height: 1.3;
    }
    
    /* Mobile-optimized modal body */
    .ai-modal-body {
        padding: 20px 16px;
        max-height: calc(90vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile-optimized source selection */
    .ai-source-selection {
        padding: 20px 0;
    }
    
    .ai-source-selection-header {
        padding: 0 0 20px 0;
        margin-bottom: 20px;
    }
    
    .ai-source-selection-header h4 {
        font-size: 18px;
    }
    
    .ai-source-selection-header p {
        font-size: 14px;
    }
    
    /* Improved mobile scrolling */
    .ai-field-preview {
        max-height: 150px;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mobile-friendly loading state */
    .ai-loading {
        padding: 30px 20px;
    }
    
    .ai-spinner {
        width: 36px;
        height: 36px;
        margin-bottom: 16px;
    }
    
    /* Mobile gesture improvements */
    .ai-window.dragging {
        cursor: grab;
        cursor: -webkit-grab;
    }
    
    /* Prevent text selection on touch */
    .ai-source-card,
    .ai-modal-tab,
    .ai-autofill-button,
    .ai-new-search-button,
    .ai-extract-button {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection for URLs and descriptions */
    .ai-source-url a,
    .ai-source-description {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
}

/* Tablet-specific optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .ai-window {
        width: 85vw;
        max-width: 600px;
    }
    
    .ai-source-card-content {
        padding: 18px;
    }
    
    .ai-autofill-button, 
    .ai-new-search-button, 
    .ai-extract-button {
        min-height: 44px;
        font-size: 15px;
    }
}

/* ===== MICRO-ANIMATIONS & VISUAL POLISH ===== */

/* Entrance animations for modal */
.ai-window {
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Source card entrance animation */
.ai-source-card {
    animation: cardSlideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

.ai-source-card:nth-child(1) { animation-delay: 0.1s; }
.ai-source-card:nth-child(2) { animation-delay: 0.2s; }
.ai-source-card:nth-child(3) { animation-delay: 0.3s; }
.ai-source-card:nth-child(4) { animation-delay: 0.4s; }
.ai-source-card:nth-child(5) { animation-delay: 0.5s; }

@keyframes cardSlideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced button click feedback */
.ai-autofill-button:active,
.ai-new-search-button:active,
.ai-extract-button:active {
    transform: translateY(1px) scale(0.98);
    transition: transform 0.1s ease;
}

/* Loading state pulse animation */
.ai-loading {
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Enhanced confidence badge animations */
.ai-source-confidence-badge {
    animation: badgeFadeIn 0.6s ease-out;
}

@keyframes badgeFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Floating animation for selected source indicator */
.ai-source-card.active .ai-source-card-content::after {
    animation: checkmarkBounce 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), 
               float 3s ease-in-out infinite 0.3s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

/* Shimmer effect for loading buttons */
.ai-extract-button:disabled {
    position: relative;
    overflow: hidden;
}

.ai-extract-button:disabled::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Staggered fade-in for source list */
.ai-sources-list {
    animation: listFadeIn 0.6s ease-out;
}

@keyframes listFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced URL link hover effect */
.ai-source-url a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.ai-source-url a:hover::before {
    transform: scaleX(1);
}

/* Progress indicator entrance */
.ai-progress-indicator {
    animation: progressSlideDown 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes progressSlideDown {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced modal close button */
.ai-window-close:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Typewriter effect for step descriptions */
.ai-step-description {
    animation: typewriterFadeIn 0.8s ease-out;
}

@keyframes typewriterFadeIn {
    0% {
        opacity: 0;
        max-height: 0;
        padding: 0 16px;
    }
    50% {
        opacity: 0.5;
        max-height: 100px;
    }
    100% {
        opacity: 1;
        max-height: 200px;
        padding: 16px;
    }
}

/* Enhanced form field focus animation */
select:focus, input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
    animation: fieldFocusPulse 0.3s ease-out;
}

@keyframes fieldFocusPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.3);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.1);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }
}

/* Enhanced checkbox interaction */
.ai-field-checkbox input[type="checkbox"]:checked {
    animation: checkboxCheck 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkboxCheck {
    0% {
        transform: scale(1.2);
    }
    50% {
        transform: scale(1.6);
    }
    100% {
        transform: scale(1.2);
    }
}

/* Page transition for switching between steps */
.ai-tab-content {
    animation: contentFadeIn 0.4s ease-out;
}

@keyframes contentFadeIn {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Enhanced source selection actions entrance */
.ai-source-selection-actions {
    animation: actionsSlideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

@keyframes actionsSlideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Improved scroll behavior */
.ai-modal-body,
.ai-field-preview {
    scroll-behavior: smooth;
}

/* Enhanced loading spinner with orbit animation */
.ai-spinner {
    position: relative;
}

.ai-spinner::after {
    animation: spin 2s linear infinite reverse;
}

/* Add subtle particles effect for active states */
.ai-source-card.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(118, 75, 162, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 60% 80%, rgba(102, 126, 234, 0.05) 0%, transparent 50%);
    pointer-events: none;
    border-radius: 12px;
}

/* Enhanced button group stagger animation */
.ai-modal-footer .ai-apply-btn {
    animation: buttonSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both;
}

.ai-modal-footer .ai-cancel-btn {
    animation: buttonSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

@keyframes buttonSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .ai-spinner::after {
        animation: none;
    }
    
    .ai-progress-step.active .ai-progress-dot {
        animation: none;
    }
}

/* ===== ENHANCED ERROR STATES & RETRY MECHANISMS ===== */

/* Enhanced error container */
.ai-error {
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    border: 2px solid #feb2b2;
    border-radius: 12px;
    padding: 24px;
    margin: 20px;
    text-align: center;
    animation: errorSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ai-error::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #e53e3e, #c53030, #e53e3e);
    background-size: 200% 100%;
    animation: errorBorderFlow 2s linear infinite;
}

@keyframes errorSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes errorBorderFlow {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error icon and content */
.ai-error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.ai-error-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    animation: errorIconPulse 2s ease-in-out infinite;
}

@keyframes errorIconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(229, 62, 62, 0);
    }
}

.ai-error-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.ai-error-message {
    font-size: 14px;
    color: #4a5568;
    line-height: 1.5;
    margin: 0;
    max-width: 400px;
}

.ai-error-details {
    background: rgba(229, 62, 62, 0.1);
    border: 1px solid rgba(229, 62, 62, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-size: 13px;
    color: #744210;
    font-family: monospace;
    text-align: left;
    max-width: 100%;
    word-break: break-word;
}

/* Retry button styling */
.ai-retry-button {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    position: relative;
    overflow: hidden;
}

.ai-retry-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

.ai-retry-button:active {
    transform: translateY(0);
}

.ai-retry-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.ai-retry-button:hover::before {
    left: 100%;
}

.ai-retry-icon {
    font-size: 16px;
    animation: retryIconSpin 2s linear infinite paused;
}

.ai-retry-button:hover .ai-retry-icon {
    animation-play-state: running;
}

@keyframes retryIconSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Network error specific styling */
.ai-error.network-error {
    background: linear-gradient(135deg, #fffaf0 0%, #feebc8 100%);
    border-color: #f6ad55;
}

.ai-error.network-error::before {
    background: linear-gradient(90deg, #dd6b20, #c05621, #dd6b20);
}

.ai-error.network-error .ai-error-icon {
    background: linear-gradient(135deg, #dd6b20 0%, #c05621 100%);
}

/* API error specific styling */
.ai-error.api-error .ai-error-icon {
    background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
}

.ai-error.api-error {
    background: linear-gradient(135deg, #faf5ff 0%, #e9d8fd 100%);
    border-color: #c4b5fd;
}

.ai-error.api-error::before {
    background: linear-gradient(90deg, #9f7aea, #805ad5, #9f7aea);
}

/* Timeout error specific styling */
.ai-error.timeout-error .ai-error-icon {
    background: linear-gradient(135deg, #38b2ac 0%, #319795 100%);
}

.ai-error.timeout-error {
    background: linear-gradient(135deg, #f0fdfa 0%, #c6f6d5 100%);
    border-color: #9ae6b4;
}

.ai-error.timeout-error::before {
    background: linear-gradient(90deg, #38b2ac, #319795, #38b2ac);
}

/* Error action buttons group */
.ai-error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.ai-error-action-btn {
    background: transparent;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-error-action-btn:hover {
    border-color: #cbd5e0;
    background: #f7fafc;
    transform: translateY(-1px);
}

.ai-error-action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.ai-error-action-btn.primary:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Connection status indicator */
.ai-connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    padding: 8px 16px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #4a5568;
    margin-top: 12px;
}

.ai-connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e53e3e;
    animation: connectionPulse 2s ease-in-out infinite;
}

.ai-connection-status.connected .ai-connection-dot {
    background: #38a169;
    animation: none;
}

.ai-connection-status.checking .ai-connection-dot {
    background: #d69e2e;
    animation: connectionChecking 1s ease-in-out infinite;
}

@keyframes connectionPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

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

/* Progressive error disclosure */
.ai-error-expandable {
    margin-top: 12px;
}

.ai-error-toggle {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
    padding: 4px 0;
    transition: color 0.2s ease;
}

.ai-error-toggle:hover {
    color: #5a67d8;
}

.ai-error-expanded {
    margin-top: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 12px;
    color: #2d3748;
    text-align: left;
    animation: errorExpandSlide 0.3s ease-out;
}

@keyframes errorExpandSlide {
    0% {
        opacity: 0;
        max-height: 0;
        padding: 0 12px;
    }
    100% {
        opacity: 1;
        max-height: 200px;
        padding: 12px;
    }
}

/* Help and support links */
.ai-error-help {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.ai-error-help-link {
    color: #667eea;
    text-decoration: none;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.ai-error-help-link:hover {
    color: #5a67d8;
    text-decoration: underline;
}

/* Mobile responsiveness for error states */
@media (max-width: 768px) {
    .ai-error {
        margin: 15px;
        padding: 20px;
    }
    
    .ai-error-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .ai-error-title {
        font-size: 16px;
    }
    
    .ai-error-message {
        font-size: 13px;
    }
    
    .ai-retry-button {
        padding: 12px 20px;
        font-size: 14px;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .ai-error-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ai-error-action-btn {
        justify-content: center;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ===== PROGRESS INDICATION FOR 2-STEP WORKFLOW ===== */

.ai-progress-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.ai-progress-steps {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

.ai-progress-step.active {
    color: #667eea;
    font-weight: 600;
}

.ai-progress-step.completed {
    color: #28a745;
}

.ai-progress-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s ease;
}

.ai-progress-step.active .ai-progress-dot {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    animation: pulse 2s infinite;
}

.ai-progress-step.completed .ai-progress-dot {
    background: #28a745;
    color: white;
}

.ai-progress-step.completed .ai-progress-dot::before {
    content: '✓';
}

@keyframes pulse {
    0% {
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    }
    100% {
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
}

.ai-progress-connector {
    width: 40px;
    height: 2px;
    background: #e9ecef;
    position: relative;
    overflow: hidden;
}

.ai-progress-connector.completed {
    background: #28a745;
}

.ai-progress-connector.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    animation: progressMove 2s infinite;
}

@keyframes progressMove {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Enhanced step descriptions */
.ai-step-description {
    background: #f8f9ff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.ai-step-description h4 {
    margin: 0 0 8px 0;
    color: #2d3748;
    font-size: 16px;
    font-weight: 600;
}

.ai-step-description p {
    margin: 0;
    color: #4a5568;
    font-size: 14px;
    line-height: 1.5;
}

/* Mobile responsiveness for progress indicator */
@media (max-width: 768px) {
    .ai-progress-indicator {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .ai-progress-steps {
        gap: 12px;
    }
    
    .ai-progress-step {
        font-size: 13px;
    }
    
    .ai-progress-dot {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }
    
    .ai-progress-connector {
        width: 30px;
    }
    
    .ai-step-description {
        padding: 12px;
    }
    
    .ai-step-description h4 {
        font-size: 15px;
    }
    
    .ai-step-description p {
        font-size: 13px;
    }
}

/* ===== TRANSLATION STATUS BADGES AND CONTROLS ===== */

.ai-translation-badge {
    background: linear-gradient(135deg, #e6f3ff 0%, #cce7ff 100%);
    border: 2px solid #66b3ff;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
    color: #1a5490;
    position: relative;
    overflow: hidden;
    animation: translationSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-translation-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: translationShimmer 2s infinite;
}

@keyframes translationSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes translationShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.btn-show-original {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn-show-original::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-show-original:hover {
    background: linear-gradient(135deg, #357abd 0%, #2968a3 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-show-original:hover::before {
    left: 100%;
}

.btn-show-original:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-show-original:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

/* Translation badge states */
.ai-translation-badge.showing-original {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b3 100%);
    border-color: #ffb366;
    color: #8b4513;
}

.ai-translation-badge.showing-original .btn-show-original {
    background: linear-gradient(135deg, #ff8c00 0%, #e67300 100%);
}

.ai-translation-badge.showing-original .btn-show-original:hover {
    background: linear-gradient(135deg, #e67300 0%, #cc6600 100%);
}

/* Translation error states */
.ai-translation-badge.ai-translation-rate-limit {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #ffc107;
    color: #856404;
}

.ai-translation-badge.ai-translation-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 2px solid #dc3545;
    color: #721c24;
}

.ai-translation-error-header {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-translation-error-message {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
}

.ai-translation-user-action {
    font-size: 12px;
    font-style: italic;
    opacity: 0.9;
    margin-bottom: 12px;
}

.btn-retry-translation {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-retry-translation:hover {
    background: linear-gradient(135deg, #20c997 0%, #17a2b8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-retry-translation:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-retry-translation:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.3);
}

/* Mobile responsiveness for translation controls */
@media (max-width: 768px) {
    .ai-translation-badge {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
        font-size: 13px;
    }
    
    .btn-show-original {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

@media (max-width: 480px) {
    .ai-translation-badge {
        margin: 8px 0;
        padding: 14px;
        font-size: 12px;
    }
    
    .btn-show-original {
        padding: 14px 18px;
        border-radius: 8px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .ai-translation-badge,
    .btn-show-original {
        animation: none;
        transition: none;
    }
    
    .ai-translation-badge::before {
        animation: none;
    }
    
    .btn-show-original::before {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-translation-badge {
        background: #ffffff;
        border: 3px solid #000000;
        color: #000000;
    }
    
    .btn-show-original {
        background: #000000;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
    
    .btn-show-original:hover {
        background: #333333;
    }
}