/**
 * PCN Smart OCR — Styles
 * Modern dual-upload widget for parking notice scanning
 */

/* ===================================================================
 *  CONTAINER
 * ================================================================= */

.pcn-ocr-container {
    max-width: 640px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    color: #1a1a2e;
}

.pcn-ocr-container * {
    box-sizing: border-box;
}

/* ===================================================================
 *  INTRO
 * ================================================================= */

.pcn-ocr-intro {
    text-align: center;
    margin-bottom: 20px;
}

.pcn-ocr-heading {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #1a1a2e;
}

.pcn-ocr-subtext {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* ===================================================================
 *  UPLOAD ZONES
 * ================================================================= */

.pcn-ocr-zones {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 540px) {
    .pcn-ocr-zones {
        flex-direction: column;
    }
}

.pcn-ocr-zone {
    flex: 1;
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    background: #fafbfc;
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pcn-ocr-zone:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}

.pcn-ocr-zone--hover {
    border-color: #6366f1;
    background: #ede9fe;
    border-style: solid;
    transform: scale(1.02);
}

.pcn-ocr-zone--filled {
    border-style: solid;
    border-color: #10b981;
    background: #f0fdf4;
    cursor: default;
}

.pcn-ocr-zone--filled:hover {
    border-color: #10b981;
    background: #f0fdf4;
}

/* File input — hidden but functional */
.pcn-ocr-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: -1;
}

/* ===================================================================
 *  UPLOAD ZONE: EMPTY STATE
 * ================================================================= */

.pcn-ocr-zone-empty {
    text-align: center;
    padding: 24px 16px;
    pointer-events: none; /* Let clicks pass through to the zone container */
}

.pcn-ocr-zone .pcn-ocr-zone-empty {
    pointer-events: auto;
    cursor: pointer;
    width: 100%;
}

.pcn-ocr-zone-icon {
    color: #9ca3af;
    margin-bottom: 8px;
    transition: color 0.2s;
}

.pcn-ocr-zone:hover .pcn-ocr-zone-icon {
    color: #6366f1;
}

.pcn-ocr-zone-label {
    font-size: 14px;
    margin: 0 0 4px 0;
    color: #374151;
}

.pcn-ocr-required {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #dc2626;
    background: #fef2f2;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.pcn-ocr-optional {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.pcn-ocr-zone-hint {
    font-size: 13px;
    color: #9ca3af;
    margin: 0 0 2px 0;
}

.pcn-ocr-zone-formats {
    font-size: 11px;
    color: #d1d5db;
    margin: 0;
}

/* ===================================================================
 *  UPLOAD ZONE: FILLED STATE
 * ================================================================= */

.pcn-ocr-zone-filled {
    width: 100%;
    text-align: center;
    padding: 12px;
}

.pcn-ocr-preview {
    max-width: 100%;
    max-height: 140px;
    border-radius: 8px;
    object-fit: contain;
    margin-bottom: 8px;
}

.pcn-ocr-heic-placeholder {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.pcn-ocr-file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pcn-ocr-filename {
    font-size: 12px;
    color: #6b7280;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pcn-ocr-remove {
    background: none;
    border: 1px solid #e5e7eb;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}

.pcn-ocr-remove:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ===================================================================
 *  SCAN BUTTON
 * ================================================================= */

.pcn-ocr-actions {
    text-align: center;
    margin-bottom: 16px;
}

.pcn-ocr-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.pcn-ocr-btn-primary {
    background: #4f46e5;
    color: #fff;
}

.pcn-ocr-btn-primary:hover:not(:disabled) {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.pcn-ocr-btn-primary:disabled {
    background: #c7d2fe;
    cursor: not-allowed;
}

.pcn-ocr-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.pcn-ocr-btn-secondary:hover {
    background: #e5e7eb;
}

/* Spinner */
.pcn-ocr-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pcn-spin 0.6s linear infinite;
}

@keyframes pcn-spin {
    to { transform: rotate(360deg); }
}

/* ===================================================================
 *  PROGRESS BAR
 * ================================================================= */

.pcn-ocr-progress {
    margin-bottom: 16px;
}

.pcn-ocr-progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.pcn-ocr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.pcn-ocr-progress-text {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* ===================================================================
 *  RESULTS
 * ================================================================= */

.pcn-ocr-results {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.pcn-ocr-results-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 600;
}

.pcn-ocr-results-header.pcn-ocr-results--success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
}

.pcn-ocr-results-header.pcn-ocr-results--warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
}

.pcn-ocr-results-icon {
    font-size: 20px;
}

.pcn-ocr-results-body {
    padding: 16px 18px;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

.pcn-ocr-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    margin-bottom: 12px;
}

@media (max-width: 440px) {
    .pcn-ocr-results-grid {
        grid-template-columns: 1fr;
    }
}

.pcn-ocr-result-item {
    display: flex;
    flex-direction: column;
}

.pcn-ocr-result-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    margin-bottom: 2px;
}

.pcn-ocr-result-value {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
}

.pcn-ocr-defects-summary {
    padding: 10px 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
    margin-top: 4px;
}

.pcn-ocr-results-footer {
    padding: 12px 18px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 12px 12px;
}

.pcn-ocr-results-next {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

/* ===================================================================
 *  ERROR
 * ================================================================= */

.pcn-ocr-error {
    text-align: center;
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 12px;
    margin-bottom: 16px;
}

.pcn-ocr-error-text {
    font-size: 14px;
    color: #dc2626;
    margin: 0 0 12px 0;
}

/* ===================================================================
 *  TRANSITIONS & ANIMATIONS
 * ================================================================= */

.pcn-ocr-results,
.pcn-ocr-error,
.pcn-ocr-progress,
.pcn-ocr-actions {
    animation: pcn-fadeIn 0.3s ease;
}

@keyframes pcn-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===================================================================
 *  GF FORM INTEGRATION — ensure widget fits inside GF HTML field
 * ================================================================= */

.gfield .pcn-ocr-container {
    margin-top: 8px;
}

/* Override GF styles that might conflict */
.gform_wrapper .pcn-ocr-btn {
    line-height: 1.4;
}

.gform_wrapper .pcn-ocr-zone input[type="file"] {
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: none;
}

.gform_wrapper .pcn-ocr-remove {
    line-height: 1;
}
