/* AKK Files - shared styles */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: #1f2937;
  background: #f3f4f6;
  -webkit-tap-highlight-color: transparent;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

button, .btn {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  min-height: 44px;
}
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }
button:active:not(:disabled), .btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: #2563eb; color: #fff; border-color: #2563eb;
}
.btn-primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }

.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }

input[type="text"], input[type="password"], input[type="number"], input[type="email"], select, textarea {
  font-family: inherit;
  font-size: 16px;            /* 16px prevents iOS zoom-on-focus */
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  width: 100%;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  border-color: #2563eb;
}

label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: #374151; }

.app-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.app-bar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }

.container { max-width: 800px; margin: 0 auto; padding: 16px; }

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.list-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.list-item:hover { background: #f9fafb; }
.list-item .primary { font-weight: 600; }
.list-item .secondary { font-size: 13px; color: #6b7280; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tag-exact { background: #d1fae5; color: #047857; }
.tag-numeric { background: #dbeafe; color: #1d4ed8; }
.tag-prefix { background: #fef3c7; color: #92400e; }
.tag-substring { background: #f3f4f6; color: #6b7280; }
.tag-pending { background: #fef3c7; color: #92400e; }
.tag-processing { background: #dbeafe; color: #1d4ed8; }
.tag-failed { background: #fee2e2; color: #b91c1c; }
.tag-completed { background: #d1fae5; color: #047857; }

.toast-host {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  pointer-events: auto;
  animation: slideUp 0.2s ease-out;
}
.toast.success { background: #047857; }
.toast.error { background: #b91c1c; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.queue-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.queue-badge.has-failed { background: #fee2e2; color: #b91c1c; }
.queue-badge.idle { background: #f3f4f6; color: #6b7280; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 16px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 20px; max-width: 480px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

.error-text { color: #b91c1c; font-size: 13px; margin-top: 6px; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid #d1d5db;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scan-specific */
.scan-host {
  position: fixed; inset: 0;
  background: #000;
  display: flex; flex-direction: column;
}
.scan-video-wrap {
  flex: 1; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.scan-video-wrap video, .scan-video-wrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.scan-overlay { position: absolute; inset: 0; pointer-events: none; }
.scan-top-bar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 16px;
  display: flex; align-items: center; gap: 12px;
  color: #fff;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
  z-index: 5;
}
.scan-bottom {
  background: #111;
  padding: 12px;
}
.scan-strip {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 4px;
  scrollbar-width: thin;
}
.scan-thumb {
  flex: 0 0 80px;
  height: 100px;
  background: #333;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid transparent;
}
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scan-thumb .page-num {
  position: absolute; bottom: 2px; left: 2px;
  background: rgba(0,0,0,0.7); color: #fff;
  padding: 1px 6px; border-radius: 3px;
  font-size: 11px;
}
.scan-thumb .delete-btn {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,0.7); color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%; border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.scan-controls {
  display: flex; align-items: center; justify-content: space-around;
  padding: 16px;
  background: #111;
}
.scan-controls button { background: #333; color: #fff; border-color: #555; }
.scan-shutter {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: #fff !important;
  border: 4px solid #aaa !important;
}
.scan-shutter:active { background: #ddd !important; }

.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff; font-size: 14px;
}

/* Page edit screen */
.edit-host { position: fixed; inset: 0; background: #1a1a1a; z-index: 60; display: flex; flex-direction: column; }
.edit-canvas-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  overflow: auto;
}
.edit-canvas-wrap canvas { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.edit-toolbar {
  background: #222; color: #fff;
  padding: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.edit-toolbar button { background: #333; color: #fff; border-color: #555; min-width: 90px; }
.edit-toolbar button.active { background: #2563eb; border-color: #2563eb; }

/* Preview */
.preview-host { display: flex; flex-direction: column; height: 100vh; }
.preview-frame { flex: 1; overflow: auto; background: #2a2a2a; padding: 16px; text-align: center; }
.preview-frame canvas { background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.3); max-width: 100%; }
.preview-pager {
  background: #fff;
  padding: 8px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  border-top: 1px solid #e5e7eb;
}

/* Utilities */
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: #6b7280; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.small { font-size: 13px; }
