/* ═══════════════════════════════════════════════════
   MediaTool - Dark Glassmorphism Design System
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS 변수 ─────────────────────────────────── */
:root {
  --bg-base:       #080b14;
  --bg-surface:    #0d1220;
  --bg-card:       rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border:        rgba(255, 255, 255, 0.08);
  --border-active: rgba(139, 92, 246, 0.5);

  --primary:       #8b5cf6;
  --primary-light: #a78bfa;
  --primary-dark:  #7c3aed;
  --accent:        #ec4899;
  --grad-primary:  linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #ec4899 100%);
  --grad-btn:      linear-gradient(135deg, #8b5cf6, #ec4899);
  --grad-yt:       linear-gradient(135deg, #ef4444, #f97316);

  --success:       #10b981;
  --warning:       #f59e0b;
  --error:         #ef4444;
  --info:          #3b82f6;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-btn:  0 4px 20px rgba(139, 92, 246, 0.4);

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 리셋 & 기본 ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── 배경 애니메이션 ───────────────────────────── */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse 60% 40% at 20% 20%, rgba(124, 58, 237, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 60% 10%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(2%, 2%) scale(1.03); }
}

/* ── 레이아웃 ─────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 0 80px;
  min-height: 100dvh;
}

/* ── 헤더 ─────────────────────────────────────── */
.header {
  padding: 28px 20px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(8, 11, 20, 0.95) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.header-icon {
  width: 36px;
  height: 36px;
  background: var(--grad-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-btn);
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── 탭 네비게이션 ────────────────────────────── */
.tab-nav {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 4px;
  margin: 12px 20px 0;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn .tab-icon { font-size: 1rem; }

.tab-btn.active {
  background: var(--grad-primary);
  color: white;
  box-shadow: var(--shadow-btn);
}

.tab-btn:not(.active):hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

/* ── 패널 ─────────────────────────────────────── */
.panel { display: none; padding: 16px 20px 0; }
.panel.active { display: block; }

/* ── 카드 ─────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── 드래그앤드롭 영역 ────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grad-primary);
  opacity: 0;
  transition: var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  transform: scale(1.01);
}

.drop-zone.dragover::before { opacity: 0.06; }

.drop-zone-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
  display: block;
  position: relative;
  z-index: 1;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.drop-zone-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
  margin-bottom: 4px;
}

.drop-zone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

/* iOS Safari: display:none 이면 .click() 무시됨 → 시각적 숨김으로 대체 */
#fileInput,
#audioToMp4Input,
#srtFileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ── 파일 미리보기 ────────────────────────────── */
.file-preview {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.file-preview.show { display: flex; }

.file-preview-icon {
  width: 40px;
  height: 40px;
  background: rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.file-preview-info { flex: 1; min-width: 0; }

.file-preview-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition);
  flex-shrink: 0;
}

.file-preview-remove:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }

/* ── 입력 필드 ─────────────────────────────── */
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.select-field {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
}

.select-field:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── 비트레이트 선택 ──────────────────────────── */
.bitrate-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bitrate-btn {
  flex: 1;
  min-width: 60px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.bitrate-btn.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
  color: var(--primary-light);
}

.bitrate-btn:hover:not(.active) {
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--text-primary);
}

/* ── 포맷 선택 (YT) ───────────────────────────── */
.format-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.format-card {
  padding: 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  font-family: inherit;
  color: var(--text-secondary);
}

.format-card.active {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--primary);
  color: var(--text-primary);
}

.format-card:hover:not(.active) {
  border-color: rgba(139, 92, 246, 0.4);
}

.format-card-icon { font-size: 1.6rem; margin-bottom: 4px; display: block; }
.format-card-name { font-size: 0.88rem; font-weight: 700; }
.format-card-desc { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── 입력 ─────────────────────────────────────── */
.input-group {
  position: relative;
}

.input-field {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.input-field::placeholder { color: var(--text-muted); }

.input-field:focus {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.06);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.input-paste-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 12px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-sm);
  color: var(--primary-light);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.input-paste-btn:hover { background: rgba(139, 92, 246, 0.25); }

/* ── 버튼 ─────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--grad-btn);
  color: white;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-yt {
  background: var(--grad-yt);
  color: white;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.35);
}

.btn-yt:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.45);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── 진행률 카드 ───────────────────────────────── */
.progress-card {
  display: none;
  animation: slideIn 0.3s ease;
}

.progress-card.show { display: block; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.progress-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-pct {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-light);
}

.progress-bar-track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: 99px;
  transition: width 0.4s ease;
  position: relative;
  min-width: 0;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.3));
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  from { opacity: 0; }
  50%  { opacity: 1; }
  to   { opacity: 0; }
}

.progress-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── 스피너 ───────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── 결과 카드 ────────────────────────────────── */
.result-card {
  display: none;
  animation: slideIn 0.35s ease;
}

.result-card.show { display: block; }

.result-success {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.result-success-icon {
  width: 44px;
  height: 44px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.result-success-text h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--success);
}

.result-success-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.result-filename {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.result-filename-icon { font-size: 1.2rem; flex-shrink: 0; }

.result-filename-info { flex: 1; min-width: 0; }

.result-filename-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-filename-size { font-size: 0.72rem; color: var(--text-muted); }

.btn-download {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  margin-bottom: 8px;
}

.btn-download:hover {
  background: rgba(16, 185, 129, 0.25);
  transform: translateY(-1px);
}

.btn-reset {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-reset:hover { color: var(--text-primary); border-color: var(--border-active); }

/* ── 오류 카드 ────────────────────────────────── */
.error-card {
  display: none;
  animation: slideIn 0.3s ease;
}

.error-card.show {
  display: block;
  border-color: rgba(239, 68, 68, 0.3);
}

.error-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.error-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }

.error-text {
  font-size: 0.85rem;
  color: #fca5a5;
  line-height: 1.5;
  word-break: break-all;
}

/* ── 알림 허용 배너 ───────────────────────────── */
.notify-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 0.82rem;
}

.notify-banner.show { display: flex; }

.notify-banner-text {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  flex: 1;
}

.notify-allow-btn {
  padding: 6px 14px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: var(--radius-sm);
  color: #93c5fd;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.notify-allow-btn:hover { background: rgba(59, 130, 246, 0.3); }

/* ── 섹션 레이블 ──────────────────────────────── */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  display: block;
}

/* ── Telegram 배지 ────────────────────────────── */
.tg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(37, 183, 254, 0.12);
  border: 1px solid rgba(37, 183, 254, 0.25);
  border-radius: 99px;
  font-size: 0.7rem;
  color: #67e8f9;
  font-weight: 600;
  margin-left: 8px;
}

/* ── 반응형 ───────────────────────────────────── */
@media (min-width: 520px) {
  #app { padding: 0 0 100px; }
  .header { padding: 36px 24px 20px; }
  .panel { padding: 20px 24px 0; }
  .header h1 { font-size: 1.6rem; }
  .drop-zone { padding: 40px 24px; }
  .card { padding: 24px; }
}

@media (max-width: 380px) {
  .format-group { grid-template-columns: 1fr 1fr; }
  .tab-btn { font-size: 0.78rem; padding: 9px 8px; }
}
