/**
 * CaptureWidget Styles (DOC-002)
 *
 * Styles for the unified capture widget component.
 */

/* ═══════════════════════════════════════════════════════════════════════════════
   BASE WIDGET
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-widget {
  position: relative;
}

.capture-widget .hidden {
  display: none !important;
}

/* Dropzone styles */
.capture-dropzone {
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.capture-dropzone.capture-dragover {
  border-color: var(--primary, #2563eb) !important;
  background-color: rgba(37, 99, 235, 0.05);
}

/* Hidden file input */
.capture-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   CAPTURE BUTTONS
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.capture-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
  color: var(--text, #1f2937);
}

.capture-btn:hover {
  background: var(--surface-2, #f9fafb);
}

.capture-btn:active {
  transform: scale(0.98);
}

.capture-btn.btn-primary {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: white;
}

.capture-btn.btn-primary:hover {
  filter: brightness(0.95);
}

.capture-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

/* Full width button variant */
.capture-btn-full {
  width: 100%;
  justify-content: center;
  padding: 0.875rem 1rem;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   PREVIEW GRID
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-preview {
  margin-top: 1rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .preview-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .preview-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.capture-preview-item {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface-2, #f9fafb);
}

.capture-preview-item .aspect-\[3\/4\] {
  aspect-ratio: 3 / 4;
}

.capture-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Page number badge */
.capture-preview-item .page-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 0.25rem;
}

/* Remove button */
.capture-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.capture-preview-item:hover .capture-remove {
  opacity: 1;
}

.capture-remove svg {
  width: 1rem;
  height: 1rem;
}

/* Processing overlay */
.capture-preview-processing {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.capture-preview-processing svg {
  width: 2rem;
  height: 2rem;
  color: white;
  animation: spin 1s linear infinite;
}

/* Success overlay */
.capture-preview-success {
  position: absolute;
  inset: 0;
  background: rgba(16, 185, 129, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.capture-preview-success svg {
  width: 2rem;
  height: 2rem;
  color: white;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   UPLOAD PROGRESS BANNER
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-upload-banner {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border-left: 3px solid var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.1);
}

.capture-banner-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--primary, #2563eb);
  display: block;
}

.capture-banner-bar-track {
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.capture-banner-bar-fill {
  height: 100%;
  background: var(--primary, #2563eb);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.capture-banner-elapsed {
  font-size: 0.75rem;
  color: var(--muted, #6b7280);
  margin-top: 0.25rem;
  display: block;
}

.capture-upload-banner.phase-done {
  border-left-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.capture-upload-banner.phase-done .capture-banner-text {
  color: #10b981;
}

.capture-upload-banner.phase-done .capture-banner-bar-fill {
  background: #10b981;
}

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

@keyframes pulse-bar {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   BOTTOM SHEET (MOBILE)
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.capture-sheet.open {
  transform: translateY(0);
}

.capture-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.capture-sheet-content {
  position: relative;
  background: var(--surface, #fff);
  border-radius: 1rem 1rem 0 0;
  max-height: 80vh;
  overflow: hidden;
}

.capture-sheet-handle {
  width: 3rem;
  height: 0.375rem;
  margin: 0.5rem auto;
  background: var(--border, #e5e7eb);
  border-radius: 1rem;
}

.capture-sheet-header {
  padding: 0 1rem 0.75rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.capture-sheet-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text, #1f2937);
  margin: 0;
}

.capture-sheet-options {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.capture-sheet-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--surface-2, #f9fafb);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
  width: 100%;
}

.capture-sheet-option:hover {
  background: var(--surface, #e5e7eb);
}

.capture-sheet-option-icon {
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.capture-sheet-option-icon.camera {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.capture-sheet-option-icon.gallery {
  background: rgba(139, 92, 246, 0.1);
  color: #7c3aed;
}

.capture-sheet-option-icon.files {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.capture-sheet-option-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.capture-sheet-option-text {
  flex: 1;
}

.capture-sheet-option-title {
  font-weight: 500;
  color: var(--text, #1f2937);
}

.capture-sheet-option-desc {
  font-size: 0.875rem;
  color: var(--muted, #6b7280);
  margin-top: 0.125rem;
}

.capture-sheet-cancel {
  padding: 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

.capture-sheet-cancel button {
  width: 100%;
  padding: 0.75rem;
  text-align: center;
  color: var(--muted, #6b7280);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   DROP ZONE (WIZARD/SMART)
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-droparea {
  border: 2px dashed var(--border, #e5e7eb);
  border-radius: 0.75rem;
  padding: 2rem;
  text-align: center;
  transition: all 0.2s ease;
  background: var(--surface-2, #f9fafb);
}

.capture-droparea:hover {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.02);
}

.capture-droparea.dragover {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.05);
  border-style: solid;
}

.capture-droparea-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  color: var(--muted, #9ca3af);
}

.capture-droparea-text {
  color: var(--muted, #6b7280);
  font-size: 0.875rem;
}

.capture-droparea-text strong {
  color: var(--primary, #2563eb);
  cursor: pointer;
}

.capture-droparea-hint {
  color: var(--muted, #9ca3af);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   OCR BADGE (UPLOAD MODE)
   ═══════════════════════════════════════════════════════════════════════════════ */

.capture-ocr-badge {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.capture-ocr-badge--ok {
  background: rgba(16, 185, 129, 0.9);
  color: white;
}

.capture-ocr-badge--partial {
  background: rgba(245, 158, 11, 0.9);
  color: white;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   DARK THEME
   ═══════════════════════════════════════════════════════════════════════════════ */

:root.theme-dark .capture-btn {
  background: var(--surface, #1f2937);
  border-color: var(--border, #374151);
  color: var(--text, #f3f4f6);
}

:root.theme-dark .capture-btn:hover {
  background: var(--surface-2, #374151);
}

:root.theme-dark .capture-preview-item {
  border-color: var(--border, #374151);
  background: var(--surface-2, #1f2937);
}

:root.theme-dark .capture-sheet-content {
  background: var(--surface, #1f2937);
}

:root.theme-dark .capture-sheet-option {
  background: var(--surface-2, #374151);
}

:root.theme-dark .capture-sheet-option:hover {
  background: #4b5563;
}

:root.theme-dark .capture-upload-banner {
  background: rgba(96, 165, 250, 0.1);
}

:root.theme-dark .capture-banner-bar-track {
  background: rgba(255, 255, 255, 0.1);
}

:root.theme-dark .capture-upload-banner.phase-done {
  background: rgba(16, 185, 129, 0.1);
}

:root.theme-dark .capture-droparea {
  border-color: var(--border, #374151);
  background: var(--surface-2, #1f2937);
}

:root.theme-dark .capture-droparea:hover,
:root.theme-dark .capture-droparea.dragover {
  border-color: var(--primary, #60a5fa);
  background: rgba(96, 165, 250, 0.05);
}
