/* ═══════════════════════════════════════
   Receipt Upload — drop zone + preview
   ═══════════════════════════════════════ */

.receipt-upload {
  margin-bottom: var(--space-md);
}

/* ── Drop zone ── */
.receipt-upload__zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background var(--transition-fast),
              box-shadow var(--transition-fast);
}

.receipt-upload__zone:hover,
.receipt-upload__zone--dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.receipt-upload__zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.receipt-upload__zone[hidden] {
  display: none;
}

.receipt-upload__zone-icon {
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.receipt-upload__zone:hover .receipt-upload__zone-icon,
.receipt-upload__zone--dragover .receipt-upload__zone-icon {
  opacity: 0.8;
  color: var(--accent);
}

.receipt-upload__zone-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.receipt-upload__zone-hint {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

/* ── Preview strip (after file selection) ── */
.receipt-upload__preview {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  animation: receipt-fade-in 0.25s var(--ease-spring);
}

.receipt-upload__preview[hidden] {
  display: none;
}

@keyframes receipt-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.receipt-upload__thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--surface-2);
}

.receipt-upload__thumb[hidden] {
  display: none;
}

.receipt-upload__pdf-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.receipt-upload__pdf-icon[hidden] {
  display: none;
}

.receipt-upload__file-info {
  flex: 1;
  min-width: 0;
}

.receipt-upload__file-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-upload__file-size {
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: 1px;
}

.receipt-upload__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.receipt-upload__remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.receipt-upload__error {
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--danger);
  padding: var(--space-xs) var(--space-sm);
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
}

.receipt-upload__error[hidden] {
  display: none;
}

/* ── Existing receipt in edit mode ── */
.receipt-upload__existing {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-sm);
}

.receipt-upload__existing-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.receipt-upload__existing-thumb:hover {
  opacity: 0.8;
}

.receipt-upload__existing-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  flex-shrink: 0;
}

.receipt-upload__existing-link {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.receipt-upload__existing-link:hover {
  color: var(--accent-hover);
}

.receipt-upload__replace-btn {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  transition: color var(--transition-fast);
}

.receipt-upload__replace-btn:hover {
  color: var(--text);
}

/* ── Receipt indicator on card ── */
.receipt-upload__indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-upload__indicator a {
  color: var(--text-faint);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  transition: color var(--transition-fast);
}

.receipt-upload__indicator a:hover {
  color: var(--accent);
}

/* ── OCR status message ── */
.receipt-upload__status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  animation: receipt-fade-in 0.25s var(--ease-spring);
}

.receipt-upload__status[hidden] {
  display: none;
}

.receipt-upload__status--loading {
  color: var(--accent);
  background: var(--accent-muted);
}

.receipt-upload__status--success {
  color: var(--success);
  background: var(--success-bg);
}

.receipt-upload__status--error {
  color: var(--warning);
  background: var(--warning-bg);
}

/* ── Spinner ── */
.receipt-upload__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: receipt-spin 0.6s linear infinite;
  flex-shrink: 0;
}

.receipt-upload__spinner[hidden] {
  display: none;
}

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

/* ── OCR field highlight ── */
.receipt-upload__ocr-filled {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 3px var(--success-bg) !important;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ── Mobile: larger tap target ── */
@media (max-width: 640px) {
  .receipt-upload__zone {
    padding: var(--space-3xl) var(--space-lg);
  }

  .receipt-upload__zone-icon {
    opacity: 0.6;
  }

  .receipt-upload__zone-label {
    font-size: var(--text-base);
  }
}

/* ── Receipt modal / lightbox ── */
.receipt-modal__backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--backdrop);
  backdrop-filter: blur(4px);
  animation: receipt-fade-in 0.2s ease;
}

.receipt-modal__backdrop[hidden] {
  display: none;
}

.receipt-modal__content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  background: var(--surface);
}

.receipt-modal__close {
  position: absolute;
  top: calc(-36px - var(--space-sm));
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.receipt-modal__close:hover {
  background: var(--surface-3);
}

.receipt-modal__image {
  display: block;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-xl);
}

.receipt-modal__image[hidden] {
  display: none;
}

.receipt-modal__embed {
  width: 80vw;
  height: 85vh;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--surface-2);
}

.receipt-modal__embed[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .receipt-upload__zone {
    gap: var(--space-xs);
    padding: var(--space-md) var(--space-md);
  }

  .receipt-modal__content {
    max-width: 96vw;
    max-height: 94vh;
  }

  .receipt-modal__image {
    max-width: 96vw;
    max-height: 90vh;
  }

  .receipt-modal__embed {
    width: 96vw;
    height: 90vh;
  }
}

/* ── Light theme ── */
[data-theme="light"] .receipt-upload__zone {
  background: var(--surface);
}

[data-theme="light"] .receipt-upload__zone:hover,
[data-theme="light"] .receipt-upload__zone--dragover {
  background: var(--accent-muted);
}

[data-theme="light"] .receipt-upload__preview,
[data-theme="light"] .receipt-upload__existing {
  box-shadow: var(--shadow-sm);
}
