/*
  app.css — Lenstag
  Colour palette matches iOS LenstagTheme.swift exactly:
    bgLight   #fafaf9  |  bgDark    #e0dedd
    nearBlack #2d2825  |  label     #78716c
    fieldBorder #bdbdbd|  warning   #d95940
*/

:root {
  --sidebar-width: 72px;

  /* Mirror the tokens defined in base.html <style> so any rule here
     can reference them without re-declaring the full set. */
  --stone-0: #fafaf9;
  --stone-1: #f5f4f3;
  --stone-2: #e0dedd;
  --stone-3: #bdbdbd;
  --stone-4: #a8a29e;
  --stone-5: #78716c;
  --stone-6: #57534e;
  --stone-7: #3d3936;
  --stone-8: #2d2825;
  --stone-9: #1e1b18;
  --danger:  #d95940;
}

body {
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  background-color: var(--stone-0) !important;
}

/* ── DRAG HANDLES ── */
.draggable-header.dragging  { opacity: 0.5; }
.draggable-header.drag-over { background-color: var(--stone-2); }

/* ── BADGE COLOURS ── */
.badge-warn-dark {
  background: #b45309;
  color: #fff !important;
}

.badge-red-dark {
  background: #b91c1c;
  color: #fff !important;
}

.badge-red-darker {
  background: #7f1d1d;
  color: #fff !important;
}

/* ── ROW STATE BORDERS ── */
/* Left accent uses the iOS palette: no electric blue */
.state-border-red     { border-left: 6px solid #b91c1c; }
.state-border-yellow  { border-left: 6px solid #b45309; }
.state-border-green   { border-left: 6px solid #15803d; }
.state-border-blue    { border-left: 6px solid var(--stone-6); }  /* warm, not electric */
.state-border-darkred { border-left: 6px solid #7f1d1d; }

/* data-state box-shadow accents (set via JS/Jinja) */
.gear-row[data-state="5"] td:first-child { box-shadow: inset 3px 0 0 #b91c1c; }
.gear-row[data-state="1"] td:first-child { box-shadow: inset 3px 0 0 #b45309; }
.gear-row[data-state="3"] td:first-child { box-shadow: inset 3px 0 0 var(--stone-6); }

/* ── TYPOGRAPHY ── */
.project-title {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 300;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── APP SHELL ── */
.app-shell {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: var(--sidebar-width);
  display: flex;
  justify-content: center;
}

.icon-nav {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* These classes are also set in base.html <style>; the values here are
   kept in sync but base.html wins if the user's browser loads it last. */
.icon-link {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--stone-5);
  text-decoration: none;
}

.icon-link i {
  font-size: 20px;
  line-height: 1;
  display: block;
}

.icon-link:hover {
  background: var(--stone-1);
  color: var(--stone-8);
}

.icon-link.active {
  background: rgba(255,255,255,.08);
  color: var(--stone-1);
}

.content {
  flex: 1;
  background: var(--stone-0);
}

/* ── GEAR TABLE ── */
.gear-table tbody tr { cursor: pointer; }

.gear-row { border-left: 6px solid transparent; }

/* ── THUMBNAILS ── */
.thumb-wrap {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--stone-1);
}

.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  display: block;
}

.thumb.placeholder {
  width: 44px;
  height: 44px;
  background: var(--stone-1);
}

/* ── MONO UTILITY ── */
.mono {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco,
               Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ── GEAR DETAIL PHOTO ── */
.detail-photo-wrap { width: 220px; }

.detail-photo {
  width: 220px;
  height: 220px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--stone-1);
  position: relative;
  border: 1px solid var(--stone-3);
}

.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-photo.clickable { cursor: pointer; }

/* ── CROPPER ── */
.cropper-wrap {
  width: 100%;
  max-height: 65vh;
  overflow: hidden;
  border-radius: 12px;
  background: var(--stone-1);
}

.cropper-wrap img {
  max-width: 100%;
  display: block;
}

/* ── DOCS GRID ── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.doc-chip {
  position: relative;
  border: 1px solid var(--stone-3);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.doc-chip a { text-decoration: none; }

.doc-chip .x-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: var(--stone-1);
  color: var(--stone-8);
  display: grid;
  place-items: center;
  font-size: 14px;
}

.doc-chip .x-btn:hover {
  background: #fdf1ee;
  color: var(--danger);
}

/* ── UPLOAD PROGRESS ── */
.upload-progress .progress {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}

/* ── PORTFOLIO FOOTER ── */
.portfolio-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
}

body.has-portfolio-footer { padding-bottom: 74px; }

/* ── TABLE OVERRIDE ── */
/* Suppress Bootstrap's default per-cell bg so our warm background shows */
.gear-table > :not(caption) > * > * {
  background-color: transparent;
  box-shadow: none;
}
/* ==========================================================================
 * ADDITIONS TO static/app.css — append to the end of the file.
 * ========================================================================== */

/* ── SERIAL NUMBER SCAN ── */
.serial-scan-wrap {
  position: relative;
}

/* Room for the camera button so long serials don't run under it */
.serial-scan-wrap .form-control {
  padding-right: 2.75rem;
}

.serial-scan-btn {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--bs-secondary-color);
  padding: 0.25rem 0.5rem;
  line-height: 1;
  font-size: 1.1rem;
  border-radius: 0.375rem;
  cursor: pointer;
}

.serial-scan-btn:hover,
.serial-scan-btn:focus-visible {
  color: var(--bs-primary);
}

.serial-scan-btn:disabled {
  color: var(--bs-secondary-color);
  cursor: default;
}

/* Drop-target affordance while dragging an image over the field */
.serial-drop-active .form-control {
  border-color: var(--bs-primary);
  border-style: dashed;
  background-color: rgba(var(--bs-primary-rgb), 0.05);
}

/* Candidate picker — anchored under the input, like the autocomplete */
.serial-candidates {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;
  border-radius: 0.5rem;
  overflow: hidden;
  max-height: 16rem;
  overflow-y: auto;
}

.serial-candidates-header {
  pointer-events: none;
  background-color: var(--bs-tertiary-bg);
}

/* Brief highlight when OCR fills the field */
@keyframes serial-flash-kf {
  0% {
    background-color: rgba(var(--bs-success-rgb), 0.25);
  }
  100% {
    background-color: transparent;
  }
}

.serial-flash {
  animation: serial-flash-kf 1.2s ease-out 1;
}


