/**
 * TikTok Downloader Stylesheet
 * Thiết kế hiện đại phong cách TikTok (Cyan #00f2fe & Pink #fe2c55)
 * Hỗ trợ hoàn hảo Dark/Light mode, tối ưu hóa di động (320px - 430px)
 * Tác giả: Huỳnh Nguyễn Thành Đạt
 */

.tiktok-dl-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3.5rem;
}

/* ================= 1. HERO HEADER ================= */
.tiktok-hero-section {
  text-align: center;
  margin-bottom: 1.75rem;
}

.tiktok-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.15), rgba(254, 44, 85, 0.15));
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--text-primary, #fff);
  margin-bottom: 0.85rem;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.1);
}

.tiktok-hero-title {
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 0.65rem;
  background: linear-gradient(135deg, #00f2fe 0%, #ffffff 45%, #fe2c55 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

[data-theme="light"] .tiktok-hero-title {
  background: linear-gradient(135deg, #0284c7 0%, #0f172a 45%, #e11d48 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tiktok-hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted, #94a3b8);
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ================= 2. MAIN INPUT CARD ================= */
.tiktok-card {
  background: var(--card-bg, rgba(22, 27, 34, 0.8));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  margin-bottom: 1.75rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.tiktok-input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-secondary, rgba(15, 23, 42, 0.6));
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  padding: 0.35rem 0.5rem 0.35rem 0.85rem;
  transition: all 0.25s ease;
}

[data-theme="light"] .tiktok-input-group {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.tiktok-input-group:focus-within {
  border-color: #00f2fe;
  box-shadow: 0 0 0 4px rgba(0, 242, 254, 0.18);
}

.tiktok-input-icon {
  font-size: 1.2rem;
  margin-right: 0.6rem;
  opacity: 0.85;
}

.tiktok-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary, #fff);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.65rem 0;
  width: 100%;
  min-width: 0;
}

.tiktok-input-field::placeholder {
  color: var(--text-muted, #64748b);
  font-size: 0.9rem;
}

.tiktok-input-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tiktok-btn-paste,
.tiktok-btn-clear {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #fff);
  padding: 0.45rem 0.75rem;
  border-radius: 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

[data-theme="light"] .tiktok-btn-paste,
[data-theme="light"] .tiktok-btn-clear {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #334155;
}

.tiktok-btn-paste:hover {
  background: rgba(0, 242, 254, 0.2);
  border-color: #00f2fe;
  color: #00f2fe;
}

.tiktok-btn-clear:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

.tiktok-btn-submit {
  width: 100%;
  margin-top: 1rem;
  padding: 0.95rem 1.5rem;
  border-radius: 0.95rem;
  border: none;
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 50%, #fe2c55 100%);
  background-size: 200% 100%;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.3);
  transition: all 0.3s ease;
  min-height: 52px;
}

.tiktok-btn-submit:hover:not(:disabled) {
  background-position: right center;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(254, 44, 85, 0.35);
}

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

.tiktok-btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Quick Tips under input */
.tiktok-input-tips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.tiktok-tip-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* ================= 3. LOADING STATE ================= */
.tiktok-state-loading {
  display: none;
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.tiktok-state-loading.active {
  display: block;
}

.tiktok-spinner-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
}

.tiktok-spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid rgba(0, 242, 254, 0.15);
  border-top-color: #00f2fe;
  border-right-color: #fe2c55;
  animation: tiktokSpin 0.9s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

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

.tiktok-loading-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-primary, #fff);
}

.tiktok-loading-sub {
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
}

/* ================= 4. ERROR STATE ================= */
.tiktok-state-error {
  display: none;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  animation: tiktokFadeIn 0.3s ease;
}

.tiktok-state-error.active {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.tiktok-error-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.tiktok-error-content {
  flex: 1;
}

.tiktok-error-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ef4444;
  margin-bottom: 0.25rem;
}

.tiktok-error-message {
  font-size: 0.85rem;
  color: var(--text-primary, #e2e8f0);
  line-height: 1.5;
}

.tiktok-error-retry-btn {
  margin-top: 0.65rem;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 0.35rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tiktok-error-retry-btn:hover {
  background: #ef4444;
  color: #fff;
}

/* ================= 5. SUCCESS RESULT CARD ================= */
.tiktok-state-result {
  display: none;
  animation: tiktokFadeIn 0.4s ease;
}

.tiktok-state-result.active {
  display: block;
}

.tiktok-result-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  .tiktok-result-grid {
    grid-template-columns: 1fr;
  }
}

.tiktok-preview-wrap {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  background: #000;
  aspect-ratio: 9 / 16;
  max-height: 380px;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.tiktok-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tiktok-preview-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  border-radius: 1rem;
}

.tiktok-poster-container {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
}

.tiktok-preview-duration {
  position: absolute;
  bottom: 0.65rem;
  right: 0.65rem;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  backdrop-filter: blur(4px);
  z-index: 2;
}

.tiktok-preview-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  border: 2px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 20px rgba(0, 242, 254, 0.4);
  z-index: 3;
}

.tiktok-preview-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.15);
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.9), rgba(254, 44, 85, 0.9));
  border-color: #fff;
  box-shadow: 0 8px 30px rgba(254, 44, 85, 0.5);
}

.tiktok-preview-play-btn span {
  margin-left: 3px;
}

/* Video Info Column */
.tiktok-meta-col {
  display: flex;
  flex-direction: column;
}

.tiktok-author-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.tiktok-author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #00f2fe;
}

.tiktok-author-info {
  flex: 1;
  min-width: 0;
}

.tiktok-author-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tiktok-author-handle {
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tiktok-video-title {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary, #e2e8f0);
  margin-bottom: 1rem;
  word-break: break-word;
  max-height: 4.5em;
  overflow: hidden;
  position: relative;
}

.tiktok-video-title.expanded {
  max-height: none;
}

/* Stats Row */
.tiktok-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.tiktok-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #cbd5e1);
}

[data-theme="light"] .tiktok-stat-chip {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #475569;
}

/* Download Buttons Grid */
.tiktok-download-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: auto;
}

.tiktok-dl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  border-radius: 0.85rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.25s ease;
  min-height: 48px;
}

.tiktok-dl-btn-nowm {
  background: linear-gradient(135deg, #00f2fe 0%, #0284c7 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.25);
}

.tiktok-dl-btn-nowm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.4);
}

.tiktok-dl-btn-hd {
  background: linear-gradient(135deg, #fe2c55 0%, #e11d48 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(254, 44, 85, 0.25);
}

.tiktok-dl-btn-hd:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(254, 44, 85, 0.4);
}

.tiktok-dl-btn-music {
  background: rgba(147, 51, 234, 0.18);
  border: 1px solid rgba(147, 51, 234, 0.4);
  color: #c084fc;
}

[data-theme="light"] .tiktok-dl-btn-music {
  background: #faf5ff;
  border-color: #d8b4fe;
  color: #9333ea;
}

.tiktok-dl-btn-music:hover {
  background: rgba(147, 51, 234, 0.3);
  transform: translateY(-2px);
}

.tiktok-secondary-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.tiktok-btn-subaction {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #fff);
  padding: 0.55rem 0.85rem;
  border-radius: 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

[data-theme="light"] .tiktok-btn-subaction {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.tiktok-btn-subaction:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ================= 6. HOW-TO GUIDE & FEATURES ================= */
.tiktok-guide-card {
  background: var(--card-bg, rgba(22, 27, 34, 0.8));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-top: 2rem;
}

.tiktok-section-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary, #fff);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tiktok-steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.tiktok-step-item {
  background: var(--bg-secondary, rgba(15, 23, 42, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

[data-theme="light"] .tiktok-step-item {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.tiktok-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00f2fe, #fe2c55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  flex-shrink: 0;
}

.tiktok-step-text h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary, #fff);
}

.tiktok-step-text p {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.45;
  margin: 0;
}

/* Features Grid */
.tiktok-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.tiktok-feature-card {
  background: var(--bg-secondary, rgba(15, 23, 42, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  padding: 1.15rem;
  text-align: center;
}

[data-theme="light"] .tiktok-feature-card {
  background: #ffffff;
  border-color: #e2e8f0;
}

.tiktok-feature-icon {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.tiktok-feature-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin-bottom: 0.25rem;
}

.tiktok-feature-desc {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
  margin: 0;
}

/* Toast */
.tiktok-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  border: 1px solid rgba(0, 242, 254, 0.3);
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.tiktok-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

/* ================= 7. MOBILE OPTIMIZATIONS (320px - 430px) ================= */
@media (max-width: 480px) {
  .tiktok-dl-container {
    padding: 0.75rem 0.5rem 3rem;
  }

  .tiktok-card {
    padding: 1.15rem 0.85rem;
    border-radius: 1rem;
  }

  .tiktok-input-group {
    padding: 0.25rem 0.35rem 0.25rem 0.65rem;
  }

  .tiktok-input-field {
    font-size: 0.88rem;
  }

  .tiktok-btn-paste span {
    display: none;
  }

  .tiktok-btn-submit {
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    min-height: 48px;
  }

  .tiktok-preview-wrap {
    max-height: 320px;
  }

  .tiktok-steps-grid,
  .tiktok-features-grid {
    grid-template-columns: 1fr;
  }
}
