/* ============================================
   Pixia - ID & Passport Photo Studio (id-photo.html)
   Complements css/ai-tool.css (.at-* primitives)
   Scope: body.at-id-photo
   ============================================ */

body.at-id-photo {
  --ip-accent: #ff9800;
  --ip-accent-2: #ffc947;
  --ip-ink: #241701;
  --ip-ok: #10b981;
  --ip-warn: #f59e0b;
  --ip-bad: #f43f5e;
  --ip-info: #06b6d4;
  --ip-shadow: 0 16px 34px -18px rgba(255, 152, 0, .7);
  --ip-ease: var(--at-ease, cubic-bezier(.22, .61, .36, 1));
}

body.at-id-photo [hidden] { display: none !important; }

body.at-id-photo .at-kicker {
  background: linear-gradient(135deg, #ff9800, #ffc947);
  color: #241701;
}
body.at-id-photo .at-btn {
  background: linear-gradient(135deg, #ff9800, #ffc947);
  color: var(--ip-ink);
  box-shadow: var(--ip-shadow);
}
body.at-id-photo .at-btn-alt {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.at-id-photo .at-progress-fill { background: linear-gradient(90deg, #ff9800, #ffc947); }
body.at-id-photo .at-drop-icon {
  background: linear-gradient(135deg, rgba(255, 152, 0, .18), rgba(255, 201, 71, .18));
  color: #e07d00;
}

/* ---------- Layout ---------- */
body.at-id-photo .ip-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  gap: 22px;
  align-items: start;
}
.ip-main {
  min-width: 0;
  display: grid;
  gap: 16px;
  align-content: start;
}
/* Preview follows the page scroll (sticky) while the controls column scrolls. */
.ip-main { position: sticky; inset-block-start: 84px; align-self: start; }
.ip-side {
  min-width: 0;
  position: sticky;
  inset-block-start: 84px;
  display: grid;
  gap: 16px;
}
@media (max-width: 1060px) {
  body.at-id-photo .ip-layout { grid-template-columns: 1fr; }
  .ip-main { position: static; }
  .ip-side { position: static; }
}
.ip-side .at-panel + .at-panel { margin-block-start: 0; }
body.at-id-photo .at-panel { min-height: 0; min-width: 0; }

.ip-panel h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-block-end: 4px;
}

.ip-count {
  margin-inline-start: auto;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px 10px;
}
.ip-check-badge-ok { color: var(--ip-ok) !important; }
.ip-check-badge-warn { color: var(--ip-warn) !important; }
.ip-check-badge-bad { color: var(--ip-bad) !important; }

/* ---------- Source ---------- */
.ip-drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 22px 16px;
  border: 1.6px dashed var(--glass-border);
  border-radius: var(--px-radius-md, 14px);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color .2s var(--ip-ease), background .2s var(--ip-ease), transform .2s var(--ip-ease);
  outline: none;
  margin-bottom: 10px;
}
.ip-drop:hover, .ip-drop:focus-visible {
  border-color: rgba(255, 152, 0, .55);
  background: rgba(255, 152, 0, .06);
}
.ip-drop.ip-drop-hot {
  border-color: var(--ip-accent);
  background: rgba(255, 152, 0, .1);
  transform: scale(1.01);
}
.ip-drop.ip-busy { opacity: .55; pointer-events: none; }
.ip-drop-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  margin-block-end: 2px;
}
.ip-drop-icon svg { width: 24px; height: 24px; }
.ip-drop-title { font-weight: 700; font-size: 14.5px; color: var(--text-primary); }
.ip-drop-sub { font-size: 12.2px; color: var(--text-secondary); max-width: 300px; line-height: 1.45; }
.ip-drop-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-block-start: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.ip-file {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 1px solid var(--glass-border);
  border-radius: var(--px-radius-sm, 10px);
  background: var(--glass-bg);
}
.ip-file-thumb {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: contain;
  background: #ddd;
  flex: none;
}
.ip-file-text { min-width: 0; flex: 1; display: grid; gap: 2px; }
.ip-file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ip-file-meta { font-size: 11.5px; color: var(--text-muted); }
.ip-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all .18s var(--ip-ease);
}
.ip-mini:hover { color: var(--text-primary); border-color: rgba(255, 152, 0, .5); }
.ip-mini svg { width: 14px; height: 14px; }
.ip-mini:disabled { opacity: .5; cursor: not-allowed; }

.ip-face-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ip-face-row .ip-status { margin-block-start: 0; }
.ip-face-btn { min-width: 0; }
.ip-face-ico { display: inline-flex; }
.ip-face-ico svg { width: 14px; height: 14px; }
.ip-ring { display: inline-flex; width: 15px; height: 15px; }
.ip-ring svg { width: 15px; height: 15px; transform: rotate(-90deg); }
.ip-ring circle { fill: none; stroke-width: 2.6; }
.ip-ring-track { stroke: rgba(255, 255, 255, .18); }
.ip-ring-fill {
  stroke: var(--ip-accent);
  stroke-linecap: round;
  stroke-dasharray: 56.55;
  stroke-dashoffset: 56.55;
  transition: stroke-dashoffset .28s var(--ip-ease);
}
.ip-face-btn.is-busy { border-color: rgba(255, 152, 0, .5); opacity: 1; }
.ip-face-btn.is-done .ip-ring-fill { stroke: #10b981; }

/* ---------- Fields ---------- */
.ip-field { display: grid; gap: 7px; margin-block-end: 14px; }
.ip-field:last-child { margin-block-end: 0; }
.ip-legend {
  font-size: 12.4px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: .02em;
}
.ip-hint {font-size: 11.6px;color: var(--text-muted);line-height: 1.5;margin: 0;margin-top: 10px;}

body.at-id-photo .at-select,
body.at-id-photo .ip-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 13.2px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 34px 10px 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
  transition: border-color .18s var(--ip-ease);
}
body.at-id-photo .at-select:hover,
body.at-id-photo .ip-select:hover { border-color: rgba(255, 152, 0, .5); }
[dir="rtl"] body.at-id-photo .at-select,
[dir="rtl"] body.at-id-photo .ip-select {
  padding: 10px 12px 10px 34px;
  background-position: left 11px center;
}

.ip-num-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.ip-num-cell { display: grid; gap: 4px; font-size: 11.4px; color: var(--text-muted); font-weight: 600; }
.ip-num {
  width: 100%;
  font: inherit;
  font-size: 13.2px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  padding: 8px 9px;
  text-align: center;
}
.ip-num:focus { outline: none; border-color: var(--ip-accent); }

body.at-id-photo .ip-range, body.at-id-photo input[type="range"].ip-range {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ip-accent) var(--fill, 50%), rgba(255, 255, 255, .12) var(--fill, 50%));
  outline: none;
  cursor: pointer;
}
body.at-id-photo .ip-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--ip-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  cursor: grab;
}
body.at-id-photo .ip-range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--ip-accent);
  cursor: grab;
}
.ip-range-row { display: flex; align-items: center; gap: 10px; }
.ip-range-out {
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 4px 6px;
}

.ip-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ip-chip {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ip-chip:hover { border-color: var(--ip-accent); color: var(--text-primary); }
.ip-chip.is-active {
  background: var(--ip-accent);
  border-color: var(--ip-accent);
  color: #fff;
}

.ip-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 12.6px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}
.ip-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ip-switch i {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid var(--glass-border);
  position: relative;
  flex: none;
  transition: background .2s var(--ip-ease);
}
.ip-switch i::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s var(--ip-ease);
}
.ip-switch input:checked + i { background: var(--ip-accent); }
.ip-switch input:checked + i::after { transform: translateX(16px); }
[dir="rtl"] .ip-switch i::after { left: auto; right: 2px; }
[dir="rtl"] .ip-switch input:checked + i::after { transform: translateX(-16px); }
.ip-switch input:focus-visible + i { outline: 2px solid var(--ip-accent); outline-offset: 2px; }

/* ---------- Spec strip ---------- */
.ip-spec {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-block-end: 12px;
}
.ip-spec-cell {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
}
.ip-spec-k { font-size: 10.6px; font-weight: 700; color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }
.ip-spec-v { font-size: 12.6px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---------- Background ---------- */
.ip-swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.ip-swatch {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 2px solid var(--glass-border);
  background: var(--sw, #fff);
  cursor: pointer;
  padding: 0;
  transition: transform .15s var(--ip-ease), border-color .15s var(--ip-ease), box-shadow .15s var(--ip-ease);
}
.ip-swatch:hover { transform: scale(1.1); }
.ip-swatch-on { border-color: var(--ip-accent); box-shadow: 0 0 0 2px rgba(255, 152, 0, .35); }
.ip-color-input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px dashed var(--glass-border);
  border-radius: 9px;
  background: none;
  cursor: pointer;
}
.ip-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.ip-color-input::-webkit-color-swatch { border: none; border-radius: 6px; }

.ip-status {
  font-size: 11.8px;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 16px;
  display: block;
  margin-block-start: 6px;
}

/* ---------- Stage ---------- */
.ip-stage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-block-end: 4px;
}
.ip-stage-head h2 { margin: 0; }
.ip-stage-tools {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ip-segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
}
.ip-seg {
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ip-seg:hover { color: var(--text-primary); }
.ip-seg.is-active { background: var(--ip-accent); color: #fff; }
.ip-seg:focus-visible { outline: 2px solid var(--ip-accent); outline-offset: 2px; }

.ip-stage {
  display: grid;
  place-items: center;
  padding: 18px 14px;
  border-radius: var(--px-radius-md, 14px);
  background:
    repeating-conic-gradient(rgba(127, 127, 127, .10) 0% 25%, transparent 25% 50%) 0 0 / 22px 22px,
    var(--bg-tertiary, #4a4747);
  border: 1px solid var(--glass-border);
  min-height: 340px;
  position: relative;
  overflow: hidden;
}
.ip-stage-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}
.ip-stage-empty svg { width: 42px; height: 42px; opacity: .55; }
.ip-stage-empty strong { font-size: 14.5px; color: var(--text-secondary); }
.ip-stage-empty span { font-size: 12.3px; max-width: 320px; line-height: 1.5; }

.ip-frame {
  position: relative;
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .16);
  cursor: grab;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}
.ip-frame:active { cursor: grabbing; }
.ip-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  pointer-events: none;
}
.ip-frame .ip-overlay { position: absolute; inset: 0; pointer-events: none; }

.ip-sheet-frame {
  position: relative;
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .16);
  overflow: hidden;
  background: #fff;
}
.ip-sheet-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ip-stage.is-sheet .ip-zoom,
.ip-stage.is-sheet #ipResetView,
.ip-stage.is-sheet .ip-zoom-btn { opacity: .45; pointer-events: none; }

.ip-zoom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 5px 12px;
}
.ip-zoom .ip-range { width: 110px; }
.ip-zoom-val {
  font-size: 11.6px;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
}
.ip-zoom-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all .18s var(--ip-ease);
}
.ip-zoom-btn:hover { color: var(--text-primary); border-color: rgba(255, 152, 0, .5); }
.ip-zoom-btn svg { width: 14px; height: 14px; }

.ip-stage-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-block-start: 10px;
}
.ip-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.8px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 5px 11px;
  font-variant-numeric: tabular-nums;
}
.ip-stat b { color: var(--text-primary); font-weight: 700; }
.ip-legend-guide {
  margin-inline-start: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.ip-legend-guide i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-inline-end: 4px;
  vertical-align: -1px;
}
.ip-legend-guide .lg-head { background: rgba(16, 185, 129, .8); }
.ip-legend-guide .lg-eye { background: rgba(6, 182, 212, .8); }

/* ---------- Compliance ---------- */
.ip-checks-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-block-end: 8px;
}
.ip-check-list { display: grid; gap: 7px; }
.ip-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
}
.ip-check-icon {
  width: 20px;
  height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-block-start: 1px;
}
.ip-check-icon svg { width: 13px; height: 13px; }
.ip-check-text { display: grid; gap: 1px; min-width: 0; }
.ip-check-text strong { font-size: 12.6px; color: var(--text-primary); font-weight: 700; }
.ip-check-text span { font-size: 11.4px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ip-check-ok .ip-check-icon { background: rgba(16, 185, 129, .16); color: var(--ip-ok); }
.ip-check-warn .ip-check-icon { background: rgba(245, 158, 11, .16); color: var(--ip-warn); }
.ip-check-fail .ip-check-icon { background: rgba(244, 63, 94, .16); color: var(--ip-bad); }
.ip-check-none .ip-check-icon { background: rgba(127, 127, 127, .16); color: var(--text-muted); }
.ip-check-ok { border-color: rgba(16, 185, 129, .28); }
.ip-check-warn { border-color: rgba(245, 158, 11, .28); }
.ip-check-fail { border-color: rgba(244, 63, 94, .3); }

/* ---------- Adjustments ---------- */
.ip-adj-row { display: grid; gap: 5px; margin-block-end: 12px; }
.ip-adj-row:last-child { margin-block-end: 0; }
.ip-adj-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ip-adj-head .ip-legend { margin: 0; }
.ip-adj-actions { display: flex; gap: 8px; margin-block-start: 10px; flex-wrap: wrap; }

/* ---------- Export ---------- */
.ip-export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}
.ip-export-btn {
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
  padding: 13px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font: inherit;
  font-size: 12.6px;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s var(--ip-ease);
}
.ip-export-btn svg { width: 20px; height: 20px; color: var(--ip-accent); }
.ip-export-btn:hover:not(:disabled) {
  border-color: rgba(255, 152, 0, .55);
  background: rgba(255, 152, 0, .07);
  transform: translateY(-1px);
}
.ip-export-btn:disabled { opacity: .45; cursor: not-allowed; }
.ip-export-btn.ip-export-primary {
  background: linear-gradient(135deg, rgba(255, 152, 0, .16), rgba(255, 201, 71, .16));
  border-color: rgba(255, 152, 0, .45);
}
.ip-export-hint {
  font-size: 11.4px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 10px 0 0;
}

.ip-sheet-info {
  font-size: 11.8px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-height: 16px;
}

/* ---------- Progress ---------- */
.ip-progress {
  display: grid;
  gap: 6px;
  margin-block-start: 10px;
}
.ip-progress-track {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.ip-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9800, #ffc947);
  transition: width .25s var(--ip-ease);
}
.ip-progress-msg {
  font-size: 11.6px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .ip-spec { grid-template-columns: 1fr 1fr; }
  .ip-export-grid { grid-template-columns: 1fr; }
  .ip-num-row { grid-template-columns: 1fr 1fr; }
  .ip-legend-guide { display: none; }
  .ip-stage { min-height: 260px; padding: 12px 8px; }
  .ip-zoom .ip-range { width: 80px; }
}
