/* ============================================================
   Receipt Scanner Widget — receipt-scanner.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

/* ---- Widget container ---- */
.rts-widget {
    font-family: 'DM Sans', sans-serif;
    max-width: 560px;
    margin: 0 auto 32px;
    color: #1a1a2e;
}

/* ---- Drop zone ---- */
.rts-dropzone {
    position: relative;
    border: 2px dashed #c5c9e0;
    border-radius: 16px;
    background: #f8f9ff;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    outline: none;
}

.rts-dropzone:hover,
.rts-dropzone:focus,
.rts-dropzone.rts-drag-over {
    border-color: #4f46e5;
    background: #eef0ff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.rts-dropzone-inner {
    pointer-events: none;
}

.rts-icon {
    width: 48px;
    height: 48px;
    stroke: #4f46e5;
    stroke-width: 1.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-bottom: 12px;
}

.rts-label {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: #1a1a2e;
}

.rts-sublabel {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 6px;
}

.rts-browse-link {
    color: #4f46e5;
    text-decoration: underline;
    cursor: pointer;
}

.rts-formats {
    font-size: 0.78rem;
    color: #9ca3af;
    margin: 0;
}

/* Hidden real file input sits over the dropzone */
.rts-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* ---- Preview ---- */
.rts-preview {
    position: relative;
    margin-top: 16px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e0e2f0;
}

.rts-preview img {
    display: block;
    width: 100%;
    max-height: 240px;
    object-fit: cover;
}

.rts-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.92);
    border: 1px solid #e0e2f0;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.rts-remove-btn:hover {
    background: #fff;
    color: #ef4444;
    border-color: #ef4444;
}

/* ---- Status message ---- */
.rts-status {
    margin-top: 12px;
    font-size: 0.88rem;
    min-height: 20px;
    transition: color 0.2s;
}

.rts-status.rts-error   { color: #dc2626; }
.rts-status.rts-success { color: #16a34a; }
.rts-status.rts-info    { color: #4f46e5; }

/* ---- Scan button ---- */
.rts-scan-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
    padding: 14px 24px;
    background: #4f46e5;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.rts-scan-btn:hover:not(:disabled) {
    background: #4338ca;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}

.rts-scan-btn:active:not(:disabled) {
    transform: translateY(0);
}

.rts-scan-btn:disabled {
    background: #c7d2fe;
    box-shadow: none;
    cursor: not-allowed;
}

/* Spinner */
.rts-btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rts-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes rts-spin {
    to { transform: rotate(360deg); }
}

/* ---- Result card ---- */
.rts-result {
    margin-top: 24px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 14px;
    padding: 20px 24px;
    animation: rts-slide-in 0.3s ease;
}

@keyframes rts-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rts-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #15803d;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rts-result-title::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #16a34a;
    color: #fff;
    border-radius: 50%;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.rts-result-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    font-size: 0.88rem;
}

.rts-result-grid .rts-field-label {
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}

.rts-result-grid .rts-field-value {
    color: #111827;
    font-weight: 500;
    word-break: break-word;
}

.rts-result-note {
    margin: 14px 0 0;
    font-size: 0.8rem;
    color: #6b7280;
}

/* ---- Debug panel (admin only) ---- */
.rts-debug {
    margin-top: 24px;
    border: 2px dashed #f59e0b;
    border-radius: 10px;
    padding: 16px 20px;
    background: #fffbeb;
}

.rts-debug-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #92400e;
    margin: 12px 0 6px;
}

.rts-debug-title:first-child {
    margin-top: 0;
}

.rts-debug-pre {
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
}
