/**
 * Rating Plate Extractor - Modal Styles
 * Matches the app's modal design system
 */

/* ==========================================================================
   Modal Overlay
   ========================================================================== */

.extractor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease-out, visibility 0.15s ease-out;
    will-change: opacity;
}

.extractor-overlay.active,
.extractor-overlay.minimized {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Modal Container
   ========================================================================== */

.extractor-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 900px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    transform: scale(0.95);
    transition: transform 0.15s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: transform;
}

.extractor-overlay.active .extractor-modal {
    transform: scale(1);
}

/* ==========================================================================
   Modal Header
   ========================================================================== */

.extractor-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.extractor-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.extractor-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.extractor-component-badge {
    padding: 4px 10px;
    background: #ecf0f1;
    color: #7f8c8d;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.extractor-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.extractor-minimize-btn,
.extractor-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #95a5a6;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.extractor-minimize-btn:hover,
.extractor-close-btn:hover {
    background: #f0f0f0;
    color: #2c3e50;
}

/* ==========================================================================
   Modal Body - Two Column Layout
   ========================================================================== */

.extractor-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Left Column - Image Viewer */
.extractor-image-column {
    width: 50%;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
}

.extractor-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: 30px;
}

.extractor-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

.extractor-image {
    max-width: calc(100% - 20px);
    max-height: calc(100% - 20px);
    object-fit: contain;
    border-radius: 4px;
    transition: transform 0.15s ease;
    cursor: grab;
    user-select: none;
    transform-origin: center center;
}

.extractor-image.panning {
    cursor: grabbing;
    transition: none;
}

.extractor-image.zoomed {
    cursor: grab;
}

.extractor-image-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.extractor-zoom-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.extractor-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.extractor-zoom-level {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    min-width: 50px;
    text-align: center;
}

/* Right Column - Fields */
.extractor-fields-column {
    width: 50%;
    display: flex;
    flex-direction: column;
    background: #fafbfc;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.extractor-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.extractor-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.extractor-loading-text {
    font-size: 14px;
    color: #7f8c8d;
}

/* ==========================================================================
   Error State
   ========================================================================== */

.extractor-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.extractor-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.extractor-error-message {
    font-size: 14px;
    color: #e74c3c;
    margin-bottom: 16px;
}

.extractor-retry-btn {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.extractor-retry-btn:hover {
    background: #2980b9;
}

/* ==========================================================================
   Results - Fields Section
   ========================================================================== */

.extractor-results {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.extractor-section {
    margin-bottom: 24px;
}

.extractor-section:last-child {
    margin-bottom: 0;
}

.extractor-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.extractor-fields-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
}

/* Selection Controls */
.extractor-selection-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.extractor-select-all-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3498db;
}

.extractor-select-all-label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.extractor-selected-count {
    margin-left: auto;
    font-size: 12px;
    color: #888;
}

/* Field Rows */
.extractor-field-row {
    display: grid;
    grid-template-columns: 20px minmax(100px, 130px) 1fr 45px;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-radius: 4px;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.extractor-field-row:not(.selected) {
    opacity: 0.5;
}

.extractor-field-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

.extractor-field-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3498db;
}

.extractor-field-label {
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.extractor-field-input {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.extractor-field-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.extractor-field-confidence {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.05);
}

.extractor-field-confidence.confidence-high {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

.extractor-field-confidence.confidence-medium {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.1);
}

.extractor-field-confidence.confidence-low {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Additional Info Section */
.extractor-additional-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
}

.extractor-additional-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.extractor-additional-item:last-child {
    border-bottom: none;
}

.extractor-additional-label {
    font-size: 13px;
    color: #7f8c8d;
}

.extractor-additional-value {
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
}

/* Overall Confidence */
.extractor-overall-confidence {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-top: 16px;
}

.extractor-confidence-label {
    font-size: 13px;
    color: #7f8c8d;
}

.extractor-confidence-value {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
}

.extractor-confidence-value.confidence-high {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

.extractor-confidence-value.confidence-medium {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.1);
}

.extractor-confidence-value.confidence-low {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* No Fields State */
.extractor-no-fields {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
    font-size: 14px;
}

/* ==========================================================================
   Modal Footer
   ========================================================================== */

.extractor-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    background: white;
    flex-shrink: 0;
}

.extractor-footer-left {
    display: flex;
    gap: 8px;
}

.extractor-footer-right {
    display: flex;
    gap: 8px;
}

.extractor-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.extractor-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.extractor-btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.extractor-btn-secondary:hover {
    background: #d5dbdb;
}

.extractor-btn-primary {
    background: #3498db;
    color: white;
}

.extractor-btn-primary:hover {
    background: #2980b9;
}

.extractor-btn-success {
    background: #27ae60;
    color: white;
}

.extractor-btn-success:hover {
    background: #229954;
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

/* ==========================================================================
   Responsive - Tablet
   ========================================================================== */

@media (max-width: 900px) {
    .extractor-modal {
        width: calc(100vw - 40px);
    }
    
    .extractor-field-row {
        grid-template-columns: 24px 120px 1fr 45px;
    }
}

/* ==========================================================================
   Responsive - Mobile
   ========================================================================== */

@media (max-width: 700px) {
    .extractor-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .extractor-body {
        flex-direction: column;
    }
    
    .extractor-image-column {
        width: 100%;
        height: 250px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .extractor-fields-column {
        width: 100%;
        flex: 1;
    }
    
    .extractor-field-row {
        grid-template-columns: 24px 1fr 45px;
        gap: 8px;
    }
    
    .extractor-field-label {
        grid-column: 2 / 3;
    }
    
    .extractor-field-input {
        grid-column: 2 / 3;
    }
    
    .extractor-selection-controls {
        flex-wrap: wrap;
    }
    
    .extractor-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .extractor-footer-left,
    .extractor-footer-right {
        flex-direction: column;
        width: 100%;
    }
    
    .extractor-btn {
        width: 100%;
    }
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.extractor-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #27ae60;
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

.extractor-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.extractor-toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.extractor-toast-icon {
    font-size: 18px;
}

.extractor-toast-action {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-left: auto;
}

/* ==========================================================================
   Minimized Bar
   ========================================================================== */

.extractor-minimized-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: #2c3e50;
    padding: 10px 20px;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    cursor: pointer;
    transition: box-shadow 0.15s ease, background 0.15s ease;
}

.extractor-minimized-bar:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.extractor-overlay.minimized {
    background: transparent;
    pointer-events: none;
}

.extractor-overlay.minimized .extractor-minimized-bar {
    display: flex;
    pointer-events: auto;
}

.extractor-overlay.minimized .extractor-modal {
    display: none;
}

/* Status indicator dot */
.extractor-minimized-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #95a5a6;
    flex-shrink: 0;
}

.extractor-minimized-bar.status-loading .extractor-minimized-status {
    background: #3498db;
    animation: pulse 1.5s ease-in-out infinite;
}

.extractor-minimized-bar.status-success .extractor-minimized-status {
    background: #27ae60;
}

.extractor-minimized-bar.status-error .extractor-minimized-status {
    background: #e74c3c;
}

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

.extractor-minimized-title {
    flex: 1;
    white-space: nowrap;
}

.extractor-minimized-expand {
    background: #f0f0f0;
    border: none;
    color: #2c3e50;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s ease;
}

.extractor-minimized-expand:hover {
    background: #e0e0e0;
}

/* ==========================================================================
   Unsaved Changes Dialog - Uses App Modal Style
   ========================================================================== */

.extractor-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    animation: fadeIn 0.2s ease;
}

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

.extractor-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 24px;
    max-width: 420px;
    width: 90%;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.extractor-dialog__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.extractor-dialog__header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
}

.extractor-dialog__icon {
    font-size: 24px;
}

.extractor-dialog__message {
    color: #5a6c7d;
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.extractor-dialog__note {
    color: #7f8c8d;
    font-size: 12px;
    line-height: 1.5;
    margin: 0 0 20px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.extractor-dialog__buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.extractor-dialog__btn {
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.extractor-dialog__btn--discard {
    background: #ecf0f1;
    color: #2c3e50;
}

.extractor-dialog__btn--discard:hover {
    background: #e74c3c;
    color: white;
}

.extractor-dialog__btn--cancel {
    background: #ecf0f1;
    color: #2c3e50;
}

.extractor-dialog__btn--cancel:hover {
    background: #d5dbdb;
}

.extractor-dialog__btn--save {
    background: #3498db;
    color: white;
}

.extractor-dialog__btn--save:hover {
    background: #2980b9;
}

/* Mobile dialog */
@media (max-width: 500px) {
    .extractor-dialog__buttons {
        flex-direction: column;
    }
    
    .extractor-dialog__btn {
        width: 100%;
    }
}

/* ==========================================================================
   Status Badges — Inline labels next to field titles in Properties panel.
   Shown after "Apply Values" — "✓ Applied" or "✗ reason" per field.
   ========================================================================== */

/* Badge base — sits inline next to .property-label text */
.extractor-status-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0.2px;
    white-space: nowrap;
    vertical-align: middle;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.extractor-status-badge--visible {
    opacity: 1;
    transform: translateX(0);
}

/* Applied — green */
.extractor-status-badge--applied {
    color: #1e8449;
    background: rgba(39, 174, 96, 0.12);
}

/* Failed — orange/red */
.extractor-status-badge--failed {
    color: #c0392b;
    background: rgba(231, 76, 60, 0.10);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Skipped Fields Note — shown at bottom of Properties section
   for fields the component type doesn't have.
   ========================================================================== */

.extractor-skipped-fields-note {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fef9e7;
    border: 1px solid #f9e79f;
    border-radius: 8px;
    font-size: 12px;
    color: #7d6608;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.extractor-skipped-fields-note--visible {
    opacity: 1;
    transform: translateY(0);
}

.extractor-skipped-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-bottom: 8px;
}

.extractor-skipped-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.extractor-skipped-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.extractor-skipped-tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(125, 102, 8, 0.08);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #7d6608;
}

/* ==========================================================================
   Status Badges & Skipped Note — Responsive
   ========================================================================== */

/* Tablet & mobile — badges shrink, show full reason on hover/tap */
@media (max-width: 700px) {
    .extractor-status-badge {
        font-size: 9px;
        padding: 1px 6px;
        margin-left: 6px;
    }

    .extractor-status-badge--failed {
        max-width: 140px;
    }

    .extractor-skipped-fields-note {
        padding: 8px 12px;
        font-size: 11px;
    }

    .extractor-skipped-tag {
        font-size: 10px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .extractor-status-badge--failed {
        max-width: 100px;
    }
}
