/**
 * Smart Field Mapping Interface Styles for MiniCRM Connect
 */

/* Main Interface Container */
.smart-field-mapping-interface {
    margin: 20px 0;
}

/* Validation Summary */
.mapping-validation-summary {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

.mapping-validation-summary h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #1d2327;
}

.validation-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    border-radius: 4px;
    background: #f6f7f7;
    min-width: 80px;
}

.stat-item.success {
    background: rgba(0, 163, 42, 0.1);
    border-left: 3px solid #00a32a;
}

.stat-item.warning {
    background: rgba(255, 185, 0, 0.1);
    border-left: 3px solid #ffb900;
}

.stat-item.error {
    background: rgba(214, 54, 56, 0.1);
    border-left: 3px solid #d63638;
}

.stat-number {
    font-size: 24px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #646970;
    text-align: center;
}

.validation-progress {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #dcdcde;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00a32a 0%, #4ab866 100%);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    white-space: nowrap;
}

/* Field Mapping Table */
.smart-field-mapping-table-container {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    margin-bottom: 20px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

.smart-field-mapping-table-container h4 {
    margin: 0;
    padding: 20px 20px 15px;
    font-size: 16px;
    color: #1d2327;
    border-bottom: 1px solid #c3c4c7;
}

.smart-field-mapping-table {
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    width: 100%;
}

.smart-field-mapping-table thead th {
    background: #f6f7f7;
    border-bottom: 1px solid #c3c4c7;
    padding: 12px 15px;
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
    text-align: left;
    white-space: nowrap;
}

.smart-field-mapping-table tbody td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f1;
    vertical-align: top;
}

.smart-field-mapping-table .column-source {
    width: 25%;
    min-width: 200px;
}

.smart-field-mapping-table .column-target {
    width: 30%;
    min-width: 250px;
}

.smart-field-mapping-table .column-compatibility {
    width: 20%;
    min-width: 120px;
}

.smart-field-mapping-table .column-validation {
    width: 15%;
    min-width: 120px;
}

.smart-field-mapping-table .column-actions {
    width: 10%;
    min-width: 100px;
}

/* Source Field Info */
.source-field-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-size: 14px;
    color: #1d2327;
    line-height: 1.3;
    margin: 0;
}

.required-indicator {
    color: #d63638;
    font-weight: 600;
    margin-left: 4px;
}

.field-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.field-type-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    border-radius: 12px;
    background: #dcdcde;
    color: #1d2327;
}

.field-type-badge[data-type="email"] {
    background: #e1f5fe;
    color: #0277bd;
}

.field-type-badge[data-type="phone"] {
    background: #f3e5f5;
    color: #7b1fa2;
}

.field-type-badge[data-type="url"] {
    background: #e8f5e8;
    color: #2e7d32;
}

.field-type-badge[data-type="date"] {
    background: #fff3e0;
    color: #ef6c00;
}

.field-type-badge[data-type="select"],
.field-type-badge[data-type="radio"] {
    background: #e3f2fd;
    color: #1565c0;
}

.field-type-badge[data-type="checkbox"],
.field-type-badge[data-type="multi-select"] {
    background: #f1f8e9;
    color: #558b2f;
}

.field-type-badge[data-type="number"] {
    background: #fce4ec;
    color: #c2185b;
}

.field-type-badge[data-type="file"] {
    background: #f9f9f9;
    color: #424242;
}

.field-id-info {
    font-size: 11px;
    color: #646970;
    font-family: monospace;
    background: #f6f7f7;
    padding: 2px 6px;
    border-radius: 3px;
}

/* MiniCRM Field Selector */
.minicrm-field-selector {
    width: 100%;
    max-width: none;
}

.minicrm-field-selector optgroup {
    font-weight: 600;
    font-size: 12px;
    color: #1d2327;
    margin-top: 4px;
}

.minicrm-field-selector option.compatible {
    color: #2e7d32;
    font-weight: 500;
}

.minicrm-field-selector option.convertible {
    color: #ef6c00;
}

.minicrm-field-selector option.incompatible {
    color: #d32f2f;
    font-style: italic;
}

.field-recommendation {
    margin-top: 8px;
}

.recommendation-text {
    font-size: 12px;
    color: #646970;
    font-style: italic;
}

/* Compatibility Indicators */
.compatibility-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.compatibility-status {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 12px;
    white-space: nowrap;
}

.compatibility-status.minicrm-bridge-compatible {
    background: #e8f5e8;
    color: #2e7d32;
}

.compatibility-status.minicrm-bridge-convertible {
    background: #fff3e0;
    color: #ef6c00;
}

.compatibility-status.minicrm-bridge-incompatible {
    background: #ffebee;
    color: #d32f2f;
}

.compatibility-status.not-mapped {
    background: #f6f7f7;
    color: #646970;
}

.validation-required-indicator,
.text-fallback-indicator {
    font-size: 14px;
    cursor: help;
}

.validation-required-indicator {
    color: #ffb900;
}

.text-fallback-indicator {
    color: #0073aa;
}

/* Validation Options */
.validation-selector {
    width: 100%;
}

.validation-selector optgroup {
    font-weight: 600;
    font-size: 12px;
}

/* Mapping Actions */
.mapping-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mapping-actions .button {
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
    line-height: 1.4;
}

/* Option Mapping Rows */
.option-mapping-row {
    background-color: #f8f9fa !important;
}

.option-mapping-row td {
    padding: 12px 15px !important;
    border-bottom: 1px solid #e5e5e5 !important;
}

.option-indent {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 20px;
}

.option-indent .dashicons {
    color: #0073aa;
    font-size: 16px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.option-value {
    font-size: 12px;
    color: #646970;
    margin-top: 4px;
}

.option-value code {
    background: #f6f7f7;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
}

.option-target-selector {
    width: 100%;
    max-width: 300px;
}

/* Recommendations Panel */
.mapping-recommendations-panel {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

.mapping-recommendations-panel h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #1d2327;
}

.recommendations-content {
    min-height: 60px;
}

.no-recommendations {
    color: #646970;
    font-style: italic;
    margin: 0;
}

.recommendation-item {
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    background: #fafafa;
}

.recommendation-item h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #1d2327;
}

.recommendation-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recommendation-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e5e5e5;
    font-size: 13px;
    color: #646970;
}

.recommendation-list li:last-child {
    border-bottom: none;
}

.recommendation-priority-high {
    border-left: 3px solid #d63638;
    padding-left: 12px;
}

.recommendation-priority-medium {
    border-left: 3px solid #ffb900;
    padding-left: 12px;
}

.recommendation-priority-low {
    border-left: 3px solid #00a32a;
    padding-left: 12px;
}

/* Row States */
.field-mapping-row.mapping-error {
    background-color: rgba(214, 54, 56, 0.1) !important;
}

.field-mapping-row.mapping-warning {
    background-color: rgba(255, 185, 0, 0.1) !important;
}

.field-mapping-row.mapping-success {
    background-color: rgba(0, 163, 42, 0.1) !important;
}

/* Loading States */
.mapping-loading {
    opacity: 0.6;
    pointer-events: none;
}

.mapping-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: mapping-spin 1s linear infinite;
}

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

/* Tooltip Styles */
.mapping-tooltip {
    position: relative;
    cursor: help;
}

.mapping-tooltip .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1000;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1d2327;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 8px;
    transition: opacity 0.3s;
}

.mapping-tooltip .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #1d2327;
}

.mapping-tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Responsive Design */
@media screen and (max-width: 1200px) {
    .validation-stats {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .smart-field-mapping-table .column-compatibility,
    .smart-field-mapping-table .column-validation {
        min-width: 100px;
    }
}

@media screen and (max-width: 960px) {
    .smart-field-mapping-table thead th,
    .smart-field-mapping-table tbody td {
        padding: 10px;
    }
    
    .smart-field-mapping-table .column-source {
        min-width: 150px;
    }
    
    .smart-field-mapping-table .column-target {
        min-width: 200px;
    }
    
    .validation-stats {
        gap: 10px;
    }
    
    .stat-item {
        min-width: 70px;
        padding: 8px 12px;
    }
    
    .stat-number {
        font-size: 20px;
    }
}

@media screen and (max-width: 600px) {
    .smart-field-mapping-table-container,
    .mapping-validation-summary,
    .mapping-recommendations-panel {
        margin-left: -20px;
        margin-right: -20px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .validation-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .stat-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .mapping-actions {
        flex-direction: row;
        gap: 4px;
    }
    
    .field-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Print Styles */
@media print {
    .mapping-actions,
    .mapping-recommendations-panel {
        display: none;
    }
    
    .smart-field-mapping-table-container,
    .mapping-validation-summary {
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .compatibility-status {
        border: 1px solid #000;
    }
}