/* ================================================================
   Product Options – Frontend  v2.5
   ================================================================ */

/* ── Field wrapper ─────────────────────────────────────────────── */
.po-group      { margin: 20px 0; }
.po-field-wrap { margin-bottom: 22px; }

/* ── Label row ─────────────────────────────────────────────────── */
.po-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.po-label {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
}
.po-req { color: #e00; }
.po-desc { font-size: 13px; color: #666; margin: 0 0 6px; }

/* Filled badge */
.po-filled-badge {
  display: none;
  align-items: center;
  gap: 5px;
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.po-filled-badge svg { flex-shrink: 0; }
.po-field-wrap.po-is-filled .po-filled-badge { display: inline-flex; }

/* ── Standard inputs ───────────────────────────────────────────── */
.po-input {
  width: 100%;
  max-width: 460px;
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.po-input:focus { border-color: #555; outline: none; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.po-textarea    { min-height: 96px; resize: vertical; }
.po-number      { max-width: 130px; }
.po-date        { max-width: 200px; }
.po-select {
  max-width: 320px;
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23555' d='M5 6L0 0h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.po-counter         { display: block; font-size: 12px; color: #999; margin-top: 3px; }
.po-counter.po-over { color: #e00; font-weight: 700; }

/* ── Radio / Checkbox ──────────────────────────────────────────── */
.po-radio-group, .po-checkbox-group { display: flex; flex-direction: column; gap: 7px; }
.po-radio-item, .po-checkbox-item   { display: flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.po-price-tag { font-size: 12px; color: #2a7c3f; }

/* ── Color swatches ────────────────────────────────────────────── */
.po-color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.po-color-swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.po-color-swatch:hover      { transform: scale(1.12); }
.po-color-swatch.is-selected{ border-color: #333; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333; }

/* ── Label swatches ────────────────────────────────────────────── */
.po-label-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.po-label-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2px solid #ddd; border-radius: 5px; padding: 6px 8px;
  cursor: pointer; transition: border-color .15s; max-width: 90px;
  text-align: center; font-size: 12px;
}
.po-label-swatch:hover       { border-color: #888; }
.po-label-swatch.is-selected { border-color: #333; box-shadow: 0 0 0 1px #333; }
.po-label-swatch img         { width: 52px; height: 52px; object-fit: cover; border-radius: 3px; }

/* ── Misc ──────────────────────────────────────────────────────── */
.po-heading   { margin: 6px 0; }
.po-paragraph { font-size: 14px; color: #444; line-height: 1.6; }
.po-divider   { border: none; border-top: 1px solid #e0e0e0; margin: 8px 0; }

/* ================================================================
   FILE UPLOAD FIELD
   ================================================================ */

.po-file-field { position: relative; }

/* ── Upload zone ── */
.po-upload-zone {
  border: 1.5px dashed #ccc;
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  transition: border-color .2s, background .2s;
  position: relative;
  cursor: pointer;
}
.po-upload-zone:hover:not(.po-zone-filled) {
  border-color: #aaa;
  background: #fafafa;
}

/* Hidden real input covers the full zone */
.po-file-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  font-size: 0;
}
.po-file-field.po-files-filled .po-file-input-hidden {
  pointer-events: none;
}

/* ── Status row inside zone ── */
.po-upload-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 10px;
}
.po-icon-upload { color: #aaa; flex-shrink: 0; }
.po-icon-check  { color: #2e7d32; flex-shrink: 0; }

/* ── Button row ── */
.po-upload-btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.po-choose-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #fff;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.po-choose-btn:hover     { border-color: #666; background: #f5f5f5; }
.po-file-hint-text       { font-size: 11px; color: #bbb; line-height: 1.5; }

/* ── FILLED state ── green zone */
.po-file-field.po-files-filled .po-upload-zone {
  border: 1.5px solid #4caf50;
  border-style: solid;
  background: #f0faf0;
  cursor: default;
}
.po-file-field.po-files-filled .po-upload-status { color: #2e7d32; }
.po-file-field.po-files-filled .po-upload-btn-row { display: none; }

/* ── ERROR state ── red zone border (added by JS after failed submit) */
.po-file-field.po-field-error .po-upload-zone {
  border-color: #e53935;
  border-style: dashed;
  background: #fff8f8;
}
.po-file-field.po-field-error .po-upload-status { color: #c62828; }
.po-file-field.po-field-error .po-icon-upload   { color: #e53935; }
.po-file-field.po-field-error .po-choose-btn    { border-color: #e53935; color: #c62828; }

/* ── Thumbnails (outside zone, below it) ── */
.po-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.po-thumb-item {
  position: relative;
  width: 72px; height: 72px;
  flex-shrink: 0;
}
.po-thumb-item img,
.po-thumb-icon {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid #e0e0e0;
  display: block;
  background: #f0f0f0;
}
.po-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.po-thumb-remove {
  position: absolute;
  top: -7px; right: -7px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  border: 2px solid #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: background .15s;
  z-index: 3;
  padding: 0;
  line-height: 1;
}
.po-thumb-remove:hover { background: #b71c1c; }

/* ── Progress ── */
.po-file-progress {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
  padding: 8px 0 0;
}
.po-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #ddd;
  border-top-color: #555;
  border-radius: 50%;
  animation: poSpin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes poSpin { to { transform: rotate(360deg); } }

/* ── Success ── */
.po-upload-success {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2e7d32;
  margin-top: 8px;
}
.po-file-field.po-files-filled .po-upload-success { display: flex; }

/* ── Validation error message (below zone) ── */
.po-file-err {
  font-size: 13px;
  color: #c62828;
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Crop Modal ─────────────────────────────────────────────────── */
#po-crop-modal {
  position: fixed; inset: 0; z-index: 999999;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#po-crop-bg { position: fixed; inset: 0; background: rgba(0,0,0,.72); }
#po-crop-box {
  position: relative; z-index: 1;
  background: #1a1a1a; border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
  width: 100%; max-width: 700px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 32px); overflow: hidden;
}
#po-crop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid #333;
  color: #fff; font-size: 15px; font-weight: 600; flex-shrink: 0;
}
#po-crop-x { background: none; border: none; color: #aaa; font-size: 22px; cursor: pointer; padding: 0 4px; }
#po-crop-x:hover { color: #fff; }
#po-crop-canvas { flex: 1; overflow: hidden; min-height: 0; max-height: 420px; background: #111; }
#po-crop-canvas img { display: block; max-width: 100%; }
#po-crop-controls {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 10px 14px; background: #222; border-top: 1px solid #333; flex-shrink: 0;
}
.po-cc {
  background: #333; border: 1px solid #444; color: #ddd;
  padding: 5px 11px; border-radius: 4px; font-size: 12px; cursor: pointer;
}
.po-cc:hover { background: #555; color: #fff; }
#po-crop-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid #333; background: #1a1a1a; flex-shrink: 0;
}
.po-crop-btn {
  padding: 9px 22px; border-radius: 6px; font-size: 14px;
  font-weight: 600; cursor: pointer; border: none;
  background: #444; color: #ddd;
  transition: background .15s;
}
.po-crop-btn:hover  { background: #555; }
.po-crop-apply      { background: #e67e22; color: #fff; }
.po-crop-apply:hover{ background: #d35400; }
@media (max-width: 600px) {
  #po-crop-canvas { max-height: 240px; }
  .po-cc { padding: 4px 8px; font-size: 11px; }
}
