/* ==========================================================================
   B.OCR Web - Shared Components (Buttons, Dropzone, Progress, Table, Modals)
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-outline {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ffffff;
}

.btn-sm {
  font-size: 11px;
  padding: 4px 8px;
}

.btn-lg {
  font-size: 13px;
  padding: 8px 16px;
  font-weight: 600;
}

/* Form Groups & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-hint {
  font-size: 11px;
  color: var(--text-subtle);
  line-height: 1.35;
}

.input-row {
  display: flex;
  gap: 6px;
}

.input-text, .input-select {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease;
}
.input-text:focus, .input-select:focus {
  border-color: var(--border-focus);
}
.input-text.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* Segmented Format Selector */
.format-segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.format-segment-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.format-segment-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.format-segment-btn.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent);
}
.format-segment-btn.active .format-title {
  color: #ffffff;
  font-weight: 600;
}
.format-segment-btn.active .format-icon-svg {
  color: var(--accent);
}

.format-icon-svg {
  color: var(--text-subtle);
  flex-shrink: 0;
}
.format-text-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.format-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
}
.format-preview {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.toggle-label {
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: .2s;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  border-radius: 50%;
  transition: .2s;
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
  background-color: #ffffff;
}

/* Shared Dropzone Component (Section 27) */
.shared-dropzone {
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.shared-dropzone:hover, .shared-dropzone.hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}
.shared-dropzone.selected {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.05);
}
.shared-dropzone.error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.dropzone-icon {
  color: var(--text-subtle);
  transition: color 0.15s ease;
}
.shared-dropzone:hover .dropzone-icon {
  color: var(--accent);
}
.dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.dropzone-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}
.dropzone-file-input {
  display: none;
}

/* Progress Bar & Metrics (Section 28) */
.progress-panel {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
}
.progress-label {
  font-weight: 600;
  color: var(--text);
}
.progress-percentage {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}
.progress-bar-track {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}
.progress-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Status Badges (Section 30) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  line-height: 1.3;
}
.badge-berhasil, .badge-success {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.25);
}
.badge-gagal, .badge-failed, .badge-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.25);
}
.badge-tidak-ada {
  background: var(--surface-2);
  color: var(--text-subtle);
  border: 1px solid var(--border);
}
.badge-perlu-review, .badge-warning {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.25);
}
.badge-memproses, .badge-info {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

/* Result Table (Section 29) */
.table-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 8px;
}
.empty-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  margin-bottom: 4px;
}
.empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.empty-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.4;
}

/* Reorderable File List (for Merge PDF & Split PDF) */
.reorder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 280px;
  padding-right: 2px;
}
.reorder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  gap: 8px;
}
.reorder-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}
.reorder-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.reorder-index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  width: 20px;
}
.reorder-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reorder-meta {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}
.reorder-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.btn-icon {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text);
}
.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
}
.btn-modal-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}
