* {
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #333;
}

/* ================= HEADER ================= */
.top-bar {
  background: #2c3e50;
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.5rem;
}

/* ================= LAYOUT ================= */
.app {
  max-width: 900px;
  margin: auto;
  padding: 1rem;
}

.card {
  background: white;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.drop-zone {
  border: 2px dashed #aaa;
  padding: 2rem;
  text-align: center;
  border-radius: 8px;
  color: #666;
  cursor: pointer;
  transition: background 0.2s;
}

.drop-zone:hover {
  background: #f9fafb;
  border-color: #2563eb;
  color: #2563eb;
}

#fileInput {
  display: none;
}

/* ================= THUMBNAILS ================= */
.thumbnail-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 5px;
  border-top: 1px solid #eee;
  margin-top: 1rem;
}

/* TARGET ANY IMAGE INSIDE THE STRIP (Fixes the size issue) */
.thumbnail-strip img {
  width: 80px;           /* FORCE SIZE */
  height: 80px;          /* FORCE SIZE */
  object-fit: cover;     /* Prevent distortion */
  border-radius: 6px;
  cursor: pointer;
  border: 3px solid transparent; /* Placeholder for highlight */
  opacity: 0.6;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.thumbnail-strip img:hover {
  opacity: 1.0;
}

/* THE HIGHLIGHT CLASS (Fixes the selection issue) */
.thumbnail-strip img.active {
  border-color: #2563eb;  /* Bright Blue Border */
  opacity: 1.0;
  transform: scale(1.1);  /* Pop effect */
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.thumbnail-strip img.dragging {
  opacity: 0.35;
}

.thumbnail-strip img.drag-over {
  outline: 3px dashed #2563eb;
  outline-offset: 2px;
}

/* Base style for the image elements created by JS */
.thumbnail {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 3px solid transparent; /* Placeholder to prevent layout jump */
  opacity: 0.7;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.thumbnail:hover {
  opacity: 1.0;
}

/* The Active Highlight Class (Matches app.js) */
.thumb-selected {
  border-color: #2563eb; /* Primary Blue */
  opacity: 1.0;
  transform: scale(1.1); /* Pop out effect */
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

/* Wrapper styles (kept in case you use them for delete buttons later) */
.thumbnail-wrapper {
  position: relative;
  display: inline-block;
}

.thumbnail-wrapper button {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #c00;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  width: 20px;
  height: 20px;
  font-size: 12px;
}

/* Thumbnail wrapper so we can overlay a delete button */
.thumb {
  position: relative;
  display: inline-flex;
}

.thumb img {
  display: block;
}

/* Delete button overlay */
.thumb .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  line-height: 22px;
  padding: 0;
  opacity: 0.85;
}

.thumb:hover .delete-btn {
  opacity: 1;
}

/* Drag visuals */
.thumb.dragging {
  opacity: 0.35;
}

/* Insertion indicator (vertical line) */
.drop-indicator {
  width: 4px;
  border-radius: 2px;
  margin: 0 6px;
  align-self: stretch;
}

/* ================= PREVIEW ================= */
.large-preview {
  min-height: 300px;
  background: #f0f0f0;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.preview-placeholder {
  color: #999;
  font-style: italic;
}

.large-preview img {
  max-width: 100%;
  max-height: 400px;
  display: none; /* Hidden by default until JS shows it */
}

/* ================= CAMERA & CONTROLS ================= */
.camera {
  margin-top: 1rem;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

#video {
  width: 100%;
  display: block;
}

.camera-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 10px;
  background: #222;
}

/* ================= FORMS & BUTTONS ================= */
.form-row {
  margin-bottom: 1rem;
}

.form-row label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="datetime-local"],
select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  cursor: pointer;
}

/* Status Messages */
.status {
  margin-top: 10px;
  font-weight: bold;
}
.status.error { color: #b00020; }
.status.success { color: #0a7d2c; }

/* Icon Buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: white;
  color: #333;
  font-size: 1.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.icon-btn:hover:not(:disabled) {
  background: #e0e0e0;
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button Variants */
.icon-btn.primary {
  background: #2563eb;
  color: white;
  border: none;
  width: 100%; /* Full width for process button */
  border-radius: 6px; /* Rounded rect for main action */
}

.icon-btn.primary:hover {
  background: #1d4ed8;
}

.icon-btn.success {
  background: #16a34a;
  color: white;
  border: none;
  width: 100%;
  border-radius: 6px;
}

.icon-btn.success:hover {
  background: #15803d;
}

/* Spinner */
.spinner {
  width: 30px;
  height: 30px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
