/* styles.css — Cyber/Tech Theme: เหลือง-ดำ ดิบ คม เท่
   โทน: ดำ #000, เหลือง #FFD600, เทา #666
   ห้าม: emoji, glossy, rainbow gradient */

:root {
  --black:     #000000;
  --dark:      #0a0a0a;
  --dark2:     #111111;
  --gray:      #666666;
  --gray-dim:  #333333;
  --gray-line: #1a1a1a;
  --white:     #ffffff;
  --accent:    #FFD600;
  --accent2:   #FFC107;
  --glow:      rgba(255, 214, 0, 0.15);
  --glow-md:   rgba(255, 214, 0, 0.4);
  --glow-hi:   rgba(255, 214, 0, 0.7);
  --mono: 'JetBrains Mono', ui-monospace, 'Roboto Mono', monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.hidden { display: none !important; }

html, body {
  background: var(--black);
  color: var(--white);
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* พื้นหลัง: dot grid เหลือง dim สไตล์ tech */
body {
  background-image: radial-gradient(circle, rgba(255, 214, 0, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ==================== Animations ==================== */

/* Hero เลื่อนขึ้นจากล่าง + fade in */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fade in ธรรมดา */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Brand dot เรืองแสงเหลืองเป็นจังหวะ */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 4px var(--glow-md), 0 0 12px var(--glow); }
  50%      { box-shadow: 0 0 8px var(--glow-hi), 0 0 24px var(--glow-md), 0 0 48px var(--glow); }
}

/* ตัวเลขโดดเมื่อพิมพ์ */
@keyframes digitBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ช่องรหัสสั่นเมื่อผิด */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(6px); }
}

/* Scan line ขวางจอ overlay */
@keyframes scanLine {
  0%   { top: -4px; }
  100% { top: 100%; }
}

/* Progress bar เรืองเหลืองเมื่อวิ่ง */
@keyframes progressGlow {
  0%, 100% { box-shadow: 0 0 6px var(--glow); }
  50%      { box-shadow: 0 0 14px var(--glow-md), 0 0 28px var(--glow); }
}

/* รหัส 6 หลัก pulse */
@keyframes codePulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px var(--glow); }
  50%      { opacity: 0.85; text-shadow: 0 0 16px var(--glow-md), 0 0 32px var(--glow); }
}

/* Stats float เบาๆ */
@keyframes floatStat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* Dropzone border ขอบเคลื่อนไหวเมื่อ drag */
@keyframes borderDance {
  0%   { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -40; }
}

/* ==================== Header ==================== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 1px solid var(--accent);
  box-shadow: 0 1px 20px var(--glow), 0 0 60px rgba(255, 214, 0, 0.05);
  animation: fadeIn 0.8s ease-out;
}
.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.18em;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
}
.brand-dot {
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulseGlow 2.5s ease-in-out infinite;
}
.brand-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* ==================== Main / Layout ==================== */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 40px 40px;
}

.hero-tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 18px;
  animation: fadeSlideUp 0.6s ease-out both;
}
.hero-title {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  animation: fadeSlideUp 0.7s ease-out 0.1s both;
}
.hero-title .hl {
  color: var(--accent);
  text-shadow: 0 0 20px var(--glow-md), 0 0 40px var(--glow);
}
.hero-sub {
  color: var(--gray);
  font-size: 15px;
  max-width: 580px;
  margin-bottom: 48px;
  animation: fadeSlideUp 0.8s ease-out 0.2s both;
}

/* กริด 2 ฝั่ง */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--gray-line);
  border: 1px solid var(--gray-line);
  animation: fadeSlideUp 0.9s ease-out 0.3s both;
}
.panel {
  background: var(--dark);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
}
.panel-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 22px;
  opacity: 0.9;
}

/* ==================== ฝั่งส่ง: Drop zone ==================== */
.dropzone {
  flex: 1;
  border: 1px dashed var(--gray-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 240px;
  padding: 28px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.dropzone:hover {
  border-color: var(--accent);
  background: rgba(255, 214, 0, 0.03);
  box-shadow: inset 0 0 30px var(--glow);
}
.dropzone.drag {
  border-color: var(--accent);
  background: rgba(255, 214, 0, 0.06);
  box-shadow: inset 0 0 50px var(--glow), 0 0 20px var(--glow);
  transform: scale(1.01);
}
.dz-icon {
  width: 36px; height: 36px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  margin-bottom: 18px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dropzone:hover .dz-icon {
  transform: rotate(45deg);
  box-shadow: 0 0 12px var(--glow-md);
}
.dz-icon::before, .dz-icon::after {
  content: '';
  position: absolute;
  background: var(--accent);
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.2s ease;
}
.dz-icon::before { width: 14px; height: 2px; }
.dz-icon::after { width: 2px; height: 14px; }
.dz-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  transition: color 0.2s ease;
}
.dropzone:hover .dz-title { color: var(--accent); }
.dz-sub { font-size: 13px; color: var(--gray); }

/* รหัส 6 หลักใหญ่ๆ ตัวหนา + เรือง */
.code-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 18px 0;
}
.code-display {
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0 0 14px 0;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 10px var(--glow-md), 0 0 30px var(--glow);
  transition: opacity 0.3s ease;
}
.code-display.show-code {
  animation: codePulse 3s ease-in-out infinite;
}
.btn-copy {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.btn-copy:hover {
  background: var(--accent);
  color: var(--black);
  box-shadow: 0 0 12px var(--glow-md);
}
.btn-copy:active {
  transform: scale(0.95);
}
.btn-copy.copied {
  border-color: #44ff44;
  color: #44ff44;
  box-shadow: 0 0 12px rgba(68, 255, 68, 0.4);
}
.status-line {
  font-size: 13px;
  color: var(--gray);
  min-height: 18px;
  margin-top: auto;
  transition: color 0.3s ease;
}
.status-line.error { color: #ff4444; }

/* ==================== ฝั่งรับ: ช่องรหัส ==================== */
.code-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
}
.code-digit {
  width: 52px;
  height: 64px;
  background: var(--dark);
  border: 1px solid var(--gray-dim);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.code-digit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--glow-md), 0 0 30px var(--glow);
}
.code-digit.bounce {
  animation: digitBounce 0.3s ease-out;
}
.code-digit.shake {
  animation: shake 0.5s ease-in-out;
}

/* ปุ่มรับไฟล์ — เหลืองสด */
.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--black);
  border: 1px solid var(--accent);
  padding: 14px 24px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  position: relative;
  overflow: hidden;
}
.btn:hover {
  background: transparent;
  color: var(--accent);
  box-shadow: 0 0 20px var(--glow-md), 0 0 40px var(--glow);
}
.btn:active {
  transform: scale(0.97);
}
.btn-block { width: 100%; }

/* ==================== Transfer overlay ==================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.3s ease-out;
}
.overlay.hidden { display: none; }

/* Scan line effect เมื่อกำลังส่ง */
.overlay.active::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--glow-md) 50%, transparent 100%);
  animation: scanLine 3s linear infinite;
  pointer-events: none;
  z-index: 10;
}

.overlay-card {
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--accent);
  background: var(--dark);
  padding: 36px 32px;
  box-shadow: 0 0 40px var(--glow), 0 0 80px rgba(255, 214, 0, 0.05);
  position: relative;
  animation: fadeSlideUp 0.4s ease-out;
}
.ov-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.ov-filename {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
  color: var(--white);
}
.ov-filesize {
  font-size: 13px;
  color: var(--gray);
  font-family: var(--mono);
}

/* progress bar: เหลืองเรืองเมื่อวิ่ง */
.progress-track {
  height: 3px;
  background: var(--gray-dim);
  margin: 28px 0 10px;
  position: relative;
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 2px;
  transition: width 0.2s linear;
  animation: progressGlow 1.5s ease-in-out infinite;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gray);
}
.progress-meta .pct { color: var(--accent); font-weight: 600; }
.speed-line {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}
.speed-line .lbl { color: var(--gray); }
.speed-line .val { color: var(--accent); font-weight: 600; }
.ov-close {
  position: absolute;
  top: 16px; right: 16px;
  background: transparent;
  border: 1px solid var(--gray-dim);
  color: var(--gray);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ov-close:hover { color: var(--accent); border-color: var(--accent); }

/* ==================== Footer (Global Stats) ==================== */
.site-footer {
  border-top: 1px solid var(--accent);
  padding: 28px 40px;
  margin-top: 64px;
  box-shadow: 0 -1px 20px var(--glow), 0 0 60px rgba(255, 214, 0, 0.03);
  animation: fadeIn 1s ease-out 0.5s both;
}
.stats-row {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-item:nth-child(1) { animation: floatStat 4s ease-in-out 0s infinite; }
.stat-item:nth-child(2) { animation: floatStat 4s ease-in-out 0.5s infinite; }
.stat-item:nth-child(3) { animation: floatStat 4s ease-in-out 1s infinite; }
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--gray);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 8px var(--glow);
  transition: color 0.3s ease;
}
.footer-note {
  max-width: 1180px;
  margin: 20px auto 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gray-dim);
  letter-spacing: 0.06em;
}
.footer-note .hl { color: var(--accent); opacity: 0.6; }

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--gray-dim); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ==================== Selection ==================== */
::selection {
  background: var(--accent);
  color: var(--black);
}

/* ==================== Responsive ==================== */
@media (max-width: 820px) {
  .site-header { padding: 18px 20px; }
  main { padding: 36px 20px; }
  .hero-title { font-size: 34px; }
  .hero-title .hl { }
  .panel-grid { grid-template-columns: 1fr; }
  .code-display { font-size: 40px; }
  .code-digit { width: 40px; height: 52px; font-size: 22px; }
  .stats-row { grid-template-columns: 1fr; gap: 18px; }
  .site-footer { padding: 24px 20px; }
  .overlay-card { padding: 28px 20px; }
}

/* เพิ่มการรองรับหน้าจอมือถือขนาดเล็กมากเป็นพิเศษ */
@media (max-width: 420px) {
  .brand-meta { display: none; } /* ซ่อนคำอธิบาย header เพื่อไม่ให้ล้นและบีบเบียด */
}

@media (max-width: 380px) {
  .code-row { gap: 6px; } /* ลดระยะห่างของกล่องกรอกรหัส */
  .code-digit { width: 34px; height: 48px; font-size: 18px; } /* ย่อขนาดกล่องกรอกรหัสให้พอดียิ่งขึ้น */
}

@media (max-width: 360px) {
  .code-display { font-size: 32px; } /* ลดขนาดรหัส 6 หลักฝั่งผู้ส่งเพื่อให้ไม่เกิด scrollbar แนวนอน */
}
