/* ============================================================
   admin.css — Admin Panel UI (redesigned for ease of use)
   ============================================================ */

/* ---- Overlay backdrop ---- */
#admin-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 400;
  backdrop-filter: blur(2px);
}
#admin-overlay.active { display: block; }

/* ---- Admin Panel drawer ---- */
#admin-panel {
  position: fixed;
  top: 0; right: -420px;
  width: 400px;
  max-width: 100vw;
  height: 100%;
  background: #12141f;
  color: #d0d4e8;
  z-index: 500;
  transition: right .32s cubic-bezier(.4,0,.2,1);
  box-shadow: -12px 0 48px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  font-family: 'Sarabun', sans-serif;
}
#admin-panel.active { right: 0; }

/* ============================================================
   HEADER
   ============================================================ */
.admin-header {
  padding: 16px 20px;
  background: #0d0f1a;
  border-bottom: 1px solid #1e2236;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.admin-header__title {
  font-size: 17px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.admin-header__badge {
  background: #7c8cf8;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: .5px;
}
.admin-close {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: #a0a8c0;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.admin-close:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ============================================================
   TABS (icon + label, ใหญ่และชัด)
   ============================================================ */
.admin-tabs {
  display: flex;
  background: #0d0f1a;
  border-bottom: 1px solid #1e2236;
  flex-shrink: 0;
  padding: 0 4px;
  gap: 2px;
}
.admin-tab {
  flex: 1;
  padding: 10px 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #5a6080;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  font-family: 'Sarabun', sans-serif;
  line-height: 1.3;
  border-radius: 8px 8px 0 0;
}
.admin-tab .tab-icon { font-size: 18px; display: block; margin-bottom: 2px; }
.admin-tab:hover { color: #9aa0c0; }
.admin-tab.active {
  color: #fff;
  border-bottom-color: #7c8cf8;
  background: rgba(124,140,248,.08);
}

/* ============================================================
   SCROLLABLE CONTENT AREA
   ============================================================ */
.admin-content {
  flex: 1; overflow-y: auto; padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #2a2d45 transparent;
}
.admin-content::-webkit-scrollbar { width: 4px; }
.admin-content::-webkit-scrollbar-thumb { background: #2a2d45; border-radius: 4px; }

.admin-pane { display: none; padding: 16px; }
.admin-pane.active { display: block; }

/* ============================================================
   SECTION HEADER (ชื่อกลุ่ม)
   ============================================================ */
.admin-section {
  margin-bottom: 20px;
}
.admin-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #4a5080;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.admin-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #1e2236;
}

/* ============================================================
   FIELD + LABEL (ใหญ่ ชัด อ่านง่าย)
   ============================================================ */
.admin-field {
  margin-bottom: 12px;
}
.admin-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700;
  color: #8890b0;
  margin-bottom: 6px;
}
.admin-label-icon { font-size: 14px; }
.admin-hint {
  font-size: 11px; color: #4a5080;
  margin-top: 4px; line-height: 1.4;
}

/* ============================================================
   INPUT / TEXTAREA / SELECT
   ============================================================ */
.admin-input,
.admin-textarea,
.admin-select {
  width: 100%;
  padding: 10px 13px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  color: #e0e4f4;
  background: #1a1d2e;
  border: 1.5px solid #252840;
  border-radius: 10px;
  outline: none;
  transition: border-color .2s, background .2s;
  line-height: 1.5;
}
.admin-input:focus,
.admin-textarea:focus,
.admin-select:focus {
  border-color: #7c8cf8;
  background: #1e2138;
}
.admin-textarea { resize: vertical; min-height: 72px; }
.admin-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6080' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.admin-select option { background: #1a1d2e; }

/* ============================================================
   COLOR PICKER ROW
   ============================================================ */
.color-row {
  display: flex; align-items: center; gap: 10px;
}
.color-swatch {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 10px;
  border: 2px solid #252840;
  overflow: hidden; cursor: pointer;
  transition: transform .15s;
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch input[type=color] {
  width: 100%; height: 100%;
  border: none; padding: 0; cursor: pointer;
  background: transparent;
  transform: scale(1.4);
}
.color-hex {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.color-preview-label {
  font-size: 12px; color: #8890b0;
  margin-top: 4px;
}

/* ============================================================
   TOGGLE SWITCH (ON/OFF ชัดเจน)
   ============================================================ */
.toggle-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1a1d2e;
  border: 1.5px solid #252840;
  border-radius: 10px;
  margin-bottom: 8px;
  transition: border-color .2s;
}
.toggle-row:hover { border-color: #3a3f5c; }
.toggle-row__label {
  font-size: 14px; font-weight: 600; color: #c0c8e8;
  display: flex; align-items: center; gap: 8px;
}
.toggle-row__sublabel {
  font-size: 11px; color: #5a6080;
  display: block; margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 46px; height: 26px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: #252840;
  border-radius: 100px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #5a6080;
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle-switch input:checked ~ .toggle-track { background: #4caf7d; }
.toggle-switch input:checked ~ .toggle-track::after {
  transform: translateX(20px);
  background: #fff;
}

/* ============================================================
   PRODUCT CARD (Admin view)
   ============================================================ */
.admin-product-card {
  background: #1a1d2e;
  border: 1.5px solid #252840;
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color .2s;
}
.admin-product-card:hover { border-color: #3a3f5c; }
.admin-product-card.is-disabled { opacity: .5; }

.apc-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.apc-emoji {
  font-size: 28px; flex-shrink: 0;
  width: 44px; height: 44px;
  background: #12141f;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.apc-img {
  width: 44px; height: 44px;
  object-fit: cover; border-radius: 10px;
  flex-shrink: 0;
}
.apc-info { flex: 1; min-width: 0; }
.apc-name {
  font-size: 15px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.apc-price {
  font-size: 13px; color: #7c8cf8; font-weight: 600;
  margin-top: 2px;
}
.apc-controls {
  display: flex; align-items: center; gap: 6px;
}
.apc-chevron {
  font-size: 14px; color: #5a6080;
  transition: transform .2s;
  margin-left: 4px;
}
.admin-product-card.is-open .apc-chevron { transform: rotate(180deg); }

.apc-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid #1e2236;
  padding-top: 14px;
}
.admin-product-card.is-open .apc-body { display: block; }

.apc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.apc-grid .admin-field { margin-bottom: 0; }

/* ============================================================
   IMAGE / TEXT BLOCK CARD
   ============================================================ */
.admin-block-card {
  background: #1a1d2e;
  border: 1.5px solid #252840;
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}
.abc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer; user-select: none;
}
.abc-title {
  font-size: 14px; font-weight: 700; color: #c0c8e8;
  display: flex; align-items: center; gap: 8px;
}
.abc-controls { display: flex; align-items: center; gap: 6px; }
.abc-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid #1e2236;
  padding-top: 14px;
}
.admin-block-card.is-open .abc-body { display: block; }
.abc-chevron {
  font-size: 13px; color: #5a6080;
  transition: transform .2s;
}
.admin-block-card.is-open .abc-chevron { transform: rotate(180deg); }

/* Image preview inside block card */
.img-preview-box {
  width: 100%; height: 80px;
  background: #12141f;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #3a3f5c; font-size: 13px; gap: 6px;
}
.img-preview-box img {
  width: 100%; height: 100%; object-fit: cover;
}
/* preview สูงขึ้นสำหรับช่องอัพโหลด (โชว์สัดส่วน 4:5) */
.img-preview-box--tall { height: auto; aspect-ratio: 4 / 5; max-height: 220px; }
.img-preview-box--tall img { object-fit: contain; }
.upload-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.upload-row .ab { flex: 1; }

/* ============================================================
   POSITION BADGE
   ============================================================ */
.pos-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  background: rgba(124,140,248,.15);
  color: #7c8cf8;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: .5px;
  margin-left: 4px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.ab {  /* admin button base */
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px; font-weight: 700;
  font-family: 'Sarabun', sans-serif;
  border: none; border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .1s, opacity .15s;
  line-height: 1;
  white-space: nowrap;
}
.ab:active { transform: scale(.96); }
.ab:disabled { opacity: .4; cursor: not-allowed; }

.ab--primary { background: #7c8cf8; color: #fff; }
.ab--primary:hover { background: #6a7ae6; }

.ab--green  { background: #3aa366; color: #fff; }
.ab--green:hover { background: #2e8f58; }

.ab--red    { background: #c0392b; color: #fff; }
.ab--red:hover { background: #a93226; }

.ab--ghost  { background: rgba(255,255,255,.06); color: #a0a8c0; border: 1px solid #252840; }
.ab--ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

.ab--upload { background: #2980b9; color: #fff; }
.ab--upload:hover { background: #2471a3; }

.ab--full  { width: 100%; }
.ab--sm    { padding: 7px 12px; font-size: 12px; }
.ab--icon  { padding: 8px; width: 34px; height: 34px; border-radius: 8px; }

/* Add button row */
.add-btn-row {
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  border: 2px dashed #252840;
  border-radius: 12px;
  color: #5a6080;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  gap: 8px;
}
.add-btn-row:hover {
  border-color: #7c8cf8;
  color: #7c8cf8;
  background: rgba(124,140,248,.06);
}

/* ============================================================
   RANGE SLIDER
   ============================================================ */
.admin-range {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  background: #252840;
  border-radius: 100px;
  outline: none;
  cursor: pointer;
}
.admin-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: #7c8cf8;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(124,140,248,.4);
  transition: transform .15s;
}
.admin-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-value-badge {
  display: inline-block;
  background: rgba(124,140,248,.15);
  color: #7c8cf8;
  font-size: 13px; font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
  min-width: 48px; text-align: center;
}

/* ============================================================
   SAVE BAR
   ============================================================ */
.admin-save-bar {
  padding: 14px 16px;
  background: #0d0f1a;
  border-top: 1px solid #1e2236;
  display: flex; gap: 10px; flex-shrink: 0;
}
.save-bar-hint {
  font-size: 11px; color: #4a5080;
  text-align: center;
  margin-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}

/* ============================================================
   PASSWORD MODAL
   ============================================================ */
#admin-password-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 600;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#admin-password-modal.active { display: flex; }

.pw-box {
  background: #1a1d2e;
  border: 1px solid #252840;
  border-radius: 20px;
  padding: 36px 32px;
  width: 320px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: popIn .2s ease;
}
@keyframes popIn {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.pw-box__icon { font-size: 40px; margin-bottom: 12px; }
.pw-box__title {
  font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 6px;
}
.pw-box__sub {
  font-size: 13px; color: #5a6080; margin-bottom: 24px;
}
.pw-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  background: #12141f;
  border: 2px solid #252840;
  border-radius: 12px;
  color: #fff;
  outline: none;
  margin-bottom: 16px;
  font-family: 'Sarabun', sans-serif;
  transition: border-color .2s;
}
.pw-input:focus { border-color: #7c8cf8; }
.pw-input.shake {
  border-color: #c0392b;
  animation: shake .3s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-8px); }
  75%      { transform: translateX(8px); }
}
.pw-btns { display: flex; gap: 10px; }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
#admin-toast {
  position: fixed;
  bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1a1d2e;
  border: 1px solid #3a3f5c;
  color: #fff;
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 14px; font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
#admin-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#admin-toast.toast--success { border-color: #3aa366; }
#admin-toast.toast--error   { border-color: #c0392b; }

/* ============================================================
   INLINE BADGE / TAG
   ============================================================ */
.stock-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 100px;
}
.stock-badge--ok   { background: rgba(58,163,102,.15); color: #3aa366; }
.stock-badge--low  { background: rgba(243,156,18,.15);  color: #f39c12; }
.stock-badge--out  { background: rgba(192,57,43,.15);   color: #c0392b; }

/* ============================================================
   SETTINGS PAGE — CARD GROUPS
   ============================================================ */
.settings-group {
  background: #1a1d2e;
  border: 1.5px solid #252840;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.settings-group__title {
  font-size: 13px; font-weight: 800; color: #7c8cf8;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}

/* number input with unit label */
.input-with-unit {
  display: flex; align-items: center;
  background: #1a1d2e;
  border: 1.5px solid #252840;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .2s;
}
.input-with-unit:focus-within { border-color: #7c8cf8; }
.input-with-unit input {
  flex: 1;
  padding: 10px 13px;
  font-size: 14px; font-family: 'Sarabun', sans-serif;
  color: #e0e4f4; background: transparent;
  border: none; outline: none;
}
.input-with-unit__unit {
  padding: 10px 13px;
  font-size: 13px; font-weight: 700;
  color: #5a6080;
  background: #12141f;
  border-left: 1px solid #252840;
  white-space: nowrap;
}
