/**
 * Enhanced Email Import System - CSS Styling
 * Styles for the multi-stage import modal and components
 */

/* Enhanced Import Modal */
.enhanced-import-modal .modal-content {
    position: relative;
    min-height: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Progress Indicator */
.import-progress-indicator {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    padding: 0 20px;
    position: relative;
}

.import-progress-indicator::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: #e5e7eb;
    z-index: 1;
}

.progress-step {
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

.progress-step.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.progress-step.completed {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* Import Stages - IMPORTANT: Hide all stages by default */
.enhanced-import-modal .import-stage {
    display: none !important;
    padding: 20px;
    min-height: 400px;
    background: #fff;
    border-radius: 8px;
    margin: 10px 0;
}

.enhanced-import-modal .import-stage.active {
    display: block !important;
    animation: fadeIn 0.3s ease-in;
}

/* Specific stage visibility rules */
#import-stage-1:not(.active),
#import-stage-2:not(.active),
#import-stage-3:not(.active),
#import-stage-4:not(.active),
#import-stage-5:not(.active) {
    display: none !important;
}

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

.import-stage h5 {
    margin-bottom: 20px;
    color: #1f2937;
    font-size: 18px;
}

.import-stage h6 {
    margin-bottom: 15px;
    color: #374151;
    font-size: 16px;
}

/* File Upload Area */
.file-upload-area {
    margin-bottom: 30px;
}

.file-drop-zone {
    border: 3px dashed #d1d5db;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.file-drop-zone:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.file-drop-zone.drag-over {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: scale(1.02);
}

.file-drop-content {
    max-width: 400px;
}

.file-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 20px;
}

.file-drop-content p {
    margin-bottom: 15px;
    color: #374151;
    font-size: 16px;
}

.file-drop-content p strong {
    color: #1f2937;
    font-size: 18px;
}

.file-info {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.file-selected {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f0f9ff;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    padding: 20px;
}

.file-selected .file-icon {
    font-size: 32px;
    margin-bottom: 0;
}

.file-details p {
    margin: 5px 0;
    color: #374151;
}

.clear-file-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    margin-left: auto;
}

.clear-file-btn:hover {
    background: #dc2626;
}

/* Analysis Results */
.analysis-summary {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 15px;
}

.analysis-summary h6 {
    color: #0369a1;
    margin-bottom: 10px;
}

.analysis-summary p {
    margin: 5px 0;
    font-size: 14px;
    color: #374151;
}

/* Field Mapping Interface */
.mapping-container {
    max-height: 500px;
    overflow-y: auto;
}

.mapping-help {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.mapping-help p {
    margin-bottom: 10px;
    color: #92400e;
}

.mapping-help ul {
    margin: 0;
    padding-left: 20px;
    color: #92400e;
}

.mapping-help li {
    margin-bottom: 5px;
}

.field-mapping-grid {
    margin-bottom: 20px;
}

.mapping-row {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 10px;
    background: white;
}

.mapping-row.required {
    border-left: 4px solid #ef4444;
    background: #fefefe;
}

.field-info {
    flex: 1;
    min-width: 200px;
}

.field-info label {
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 5px;
}

.required {
    color: #ef4444;
}

.field-description {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
}

.column-select {
    flex: 1;
    min-width: 200px;
}

.column-select select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.confidence-indicator {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 5px;
    display: inline-block;
}

.confidence-indicator.high-confidence {
    background: #dcfce7;
    color: #166534;
}

.confidence-indicator.medium-confidence {
    background: #fef3c7;
    color: #92400e;
}

.confidence-indicator.low-confidence {
    background: #fee2e2;
    color: #991b1b;
}

/* Confidence Summary */
.confidence-summary {
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}

.mapping-status {
    padding: 15px;
    border-radius: 8px;
    border: 1px solid;
}

.mapping-status.valid {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.mapping-status.invalid {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.mapping-status .warnings {
    margin-top: 10px;
}

.mapping-status .warnings ul {
    margin: 5px 0 0 15px;
}

/* Preview Section */
.preview-container {
    max-height: 500px;
    overflow-y: auto;
}

.validation-summary {
    margin-bottom: 30px;
}

.preview-summary {
    background: #f9fafb;
    border-radius: 8px;
    padding: 20px;
}

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

.stat-item {
    text-align: center;
    padding: 15px 10px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e7eb;
}

.stat-item.positive {
    border-color: #10b981;
    background: #ecfdf5;
}

.stat-item.negative {
    border-color: #ef4444;
    background: #fef2f2;
}

.stat-item.warning {
    border-color: #f59e0b;
    background: #fffbeb;
}

.stat-item.neutral {
    border-color: #6b7280;
    background: #f9fafb;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-item.positive .stat-number { color: #10b981; }
.stat-item.negative .stat-number { color: #ef4444; }
.stat-item.warning .stat-number { color: #f59e0b; }
.stat-item.neutral .stat-number { color: #6b7280; }

.stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
}

.errors-section, .warnings-section {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
}

.errors-section {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.warnings-section {
    background: #fffbeb;
    border: 1px solid #fed7aa;
}

.errors-section h6 {
    color: #991b1b;
    margin-bottom: 10px;
}

.warnings-section h6 {
    color: #92400e;
    margin-bottom: 10px;
}

.error-list, .warning-list {
    margin: 0;
    padding-left: 20px;
    max-height: 150px;
    overflow-y: auto;
}

.error-list li {
    color: #991b1b;
    margin-bottom: 3px;
    font-size: 13px;
}

.warning-list li {
    color: #92400e;
    margin-bottom: 3px;
    font-size: 13px;
}

/* Data Preview */
.data-preview {
    margin-top: 30px;
}

.preview-table-container {
    max-height: 300px;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th {
    background: #f9fafb;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
}

.preview-table td {
    padding: 8px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.preview-table tbody tr:hover {
    background: #f9fafb;
}

/* Import Options */
.import-options {
    margin-top: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.import-options h6 {
    margin-bottom: 15px;
    color: #374151;
}

.import-options label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.import-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Progress Section */
.progress-container {
    text-align: center;
    padding: 40px 20px;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 20px;
}

.import-status {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
}

.import-status p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* Results Section */
.import-results {
    padding: 20px 0;
}

.results-header {
    text-align: center;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.results-header.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.results-header.warning {
    background: #fffbeb;
    border: 1px solid #fed7aa;
    color: #92400e;
}

.results-header h6 {
    margin-bottom: 10px;
    font-size: 20px;
}

.results-stats {
    background: #f9fafb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}

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

.stat-row.success {
    color: #166534;
}

.stat-row.warning {
    color: #92400e;
}

.stat-row.error {
    color: #991b1b;
}

.error-details {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 20px;
}

.error-details h6 {
    color: #991b1b;
    margin-bottom: 15px;
}

.error-details ul {
    margin: 0;
    padding-left: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.error-details li {
    color: #991b1b;
    margin-bottom: 5px;
    font-size: 13px;
}

/* Stage Actions */
.stage-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 30px;
    border-top: 1px solid #e5e7eb;
    margin-top: 30px;
}

.stage-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Overlay */
.import-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.import-loading p {
    color: #374151;
    font-weight: 600;
    margin: 0;
}

/* Error Messages */
.import-error-message {
    margin: 0 -30px 20px -30px;
}

.error-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    padding: 15px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #991b1b;
}

.error-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #991b1b;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-close:hover {
    background: #fecaca;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .enhanced-import-modal .modal-content {
        max-width: 95% !important;
        margin: 20px auto;
    }
    
    .import-progress-indicator {
        font-size: 11px;
        padding: 0 10px;
    }
    
    .progress-step {
        padding: 6px 10px;
    }
    
    .mapping-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .summary-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-row {
        font-size: 12px;
    }
    
    .stage-actions {
        flex-direction: column;
    }
    
    .stage-actions button {
        width: 100%;
    }
}