/* ==========================================================================
   GIF Studio — สไตล์เสริมจาก Tailwind
   ========================================================================== */

:root {
  --brand: #5b6bff;
  --brand-soft: rgba(91, 107, 255, .18);
}

html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0e0e15; }
::-webkit-scrollbar-thumb { background: #252533; border-radius: 8px; border: 2px solid #0e0e15; }
::-webkit-scrollbar-thumb:hover { background: #343446; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .35s cubic-bezier(.22,1,.36,1) both; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin .8s linear infinite; }

@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.toast { animation: toastIn .25s cubic-bezier(.22,1,.36,1) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- ปุ่มแท็บ ---------- */
.tab {
  border-radius: .6rem;
  padding: .55rem .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: #94a3b8;
  transition: background .18s, color .18s;
}
.tab:hover { color: #e2e8f0; }
.tab-active { background: #1a1a25; color: #fff; box-shadow: inset 0 0 0 1px #252533; }

/* ---------- การ์ด ---------- */
.card {
  border-radius: 1rem;
  border: 1px solid rgba(37, 37, 51, .7);
  background: rgba(14, 14, 21, .6);
  padding: 1rem;
}
.card-title {
  margin-bottom: .75rem;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
}

/* ---------- ชิปตัวเลือก ---------- */
.chip {
  border-radius: .6rem;
  border: 1px solid #252533;
  background: #13131c;
  padding: .5rem .4rem;
  font-size: .75rem;
  font-weight: 500;
  line-height: 1.25;
  color: #cbd5e1;
  transition: border-color .16s, background .16s, color .16s, transform .1s;
}
.chip:hover { border-color: #4a4a60; color: #fff; }
.chip:active { transform: scale(.97); }
.chip-active,
.chip-active:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(91,107,255,.35);
}

/* ---------- ฟอนต์ไทยสำหรับซับ (ตัวเดียวกับที่ FFmpeg ใช้เบิร์น) ---------- */
@font-face {
  font-family: 'Sarabun';
  src: url('../../vendor/fonts/Sarabun-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Sarabun';
  src: url('../../vendor/fonts/Sarabun-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

/* ---------- รายการบรรทัดซับ ---------- */
.subrow {
  border-radius: .6rem;
  border: 1px solid #252533;
  background: #13131c;
  padding: .5rem .6rem;
  transition: border-color .16s, background .16s;
}
.subrow:hover { border-color: #4a4a60; }
.subrow-active { border-color: var(--brand); background: var(--brand-soft); }
.subrow-out { opacity: .4; }
.subrow textarea {
  width: 100%;
  resize: vertical;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  font-size: .75rem;
  line-height: 1.45;
  outline: none;
  min-height: 2.2em;
}
.subrow input[type="text"] {
  background: transparent;
  border: 0;
  outline: none;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  width: 5.6em;
}
.subrow input[type="text"]:focus { color: #fff; }

/* ---------- ตัวเลือกสีลายน้ำ ---------- */
.swatch {
  height: 22px;
  width: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .18);
  transition: transform .12s, box-shadow .12s;
}
.swatch:hover { transform: scale(1.12); box-shadow: 0 0 0 2px rgba(91, 107, 255, .5); }

/* ---------- ตัวเลือกตำแหน่งลายน้ำ (ตาราง 3x3) ---------- */
.poschip {
  position: relative;
  height: 34px;
  border-radius: .5rem;
  border: 1px solid #252533;
  background: #13131c;
  transition: border-color .16s, background .16s;
}
.poschip:hover { border-color: #4a4a60; }
.poschip::after {
  content: "";
  position: absolute;
  height: 7px;
  width: 7px;
  border-radius: 2px;
  background: #4a4a60;
  transition: background .16s;
}
.poschip[data-pos^="t"]::after { top: 6px; }
.poschip[data-pos^="m"]::after { top: 50%; margin-top: -3.5px; }
.poschip[data-pos^="b"]::after { bottom: 6px; }
.poschip[data-pos$="l"]::after { left: 6px; }
.poschip[data-pos$="c"]::after { left: 50%; margin-left: -3.5px; }
.poschip[data-pos$="r"]::after { right: 6px; }
.poschip-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 1px rgba(91, 107, 255, .35);
}
.poschip-active::after { background: #a3aeff; }

/* ---------- อินพุต ---------- */
.inp {
  width: 100%;
  border-radius: .75rem;
  border: 1px solid #252533;
  background: #13131c;
  padding: .55rem .7rem;
  font-size: .85rem;
  color: #fff;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,107,255,.18); }
.inp::-webkit-outer-spin-button,
.inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- สไลเดอร์ ---------- */
.range {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: #252533;
  outline: none;
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px; width: 16px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #0e0e15;
  box-shadow: 0 0 0 1px rgba(91,107,255,.5);
  transition: transform .12s;
}
.range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range::-moz-range-thumb {
  height: 14px; width: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #0e0e15;
}

/* ---------- ไทม์ไลน์ ---------- */
.tl-handle::before {
  content: "";
  position: absolute;
  inset: 0;
}
.tl-handle:active > div,
.tl-handle.dragging > div { background: #a3aeff; }

#tlTicks .tick {
  position: absolute;
  bottom: 0;
  font-size: 9px;
  color: #64748b;
  transform: translateX(-50%);
  padding-bottom: 2px;
  user-select: none;
  white-space: nowrap;
}
#tlTicks .tick::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  height: 5px;
  width: 1px;
  background: #343446;
}

#tlThumbs img {
  height: 100%;
  flex: 1 1 0;
  min-width: 0;
  object-fit: cover;
  filter: saturate(.85) brightness(.9);
}

/* ---------- กริดช่วยจัดองค์ประกอบ ---------- */
.grid-overlay {
  background-image:
    linear-gradient(to right, rgba(255,255,255,.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.22) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
  background-position: -1px -1px;
}

/* ---------- พื้นหลังตาหมากรุก (โชว์ความโปร่งใสของ GIF) ---------- */
.checker {
  background-image:
    linear-gradient(45deg, #1a1a25 25%, transparent 25%),
    linear-gradient(-45deg, #1a1a25 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1a25 75%),
    linear-gradient(-45deg, transparent 75%, #1a1a25 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ---------- ทูลทิป ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  z-index: 70;
  white-space: nowrap;
  border-radius: .5rem;
  background: #1a1a25;
  box-shadow: 0 0 0 1px #343446, 0 8px 24px -8px rgba(0,0,0,.8);
  padding: .35rem .55rem;
  font-size: 11px;
  font-weight: 500;
  color: #e2e8f0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s, transform .16s;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 640px) { [data-tip]::after { display: none; } }

/* ---------- Dropzone ตอนลากไฟล์เข้ามา ---------- */
#dropzone.dragover {
  border-color: var(--brand);
  background: rgba(91,107,255,.08);
  box-shadow: 0 0 0 4px rgba(91,107,255,.12);
}

/* ---------- สถานะปุ่มถูกปิด ---------- */
button:disabled { cursor: not-allowed; opacity: .45; }
