/* ==========================================================================
   Threads Video Downloader - Design System & Stylesheet
   Pure Black & White Theme Inspired by Official Threads Design
   ========================================================================== */

:root {
  --threads-black: #000000;
  --threads-dark-bg: #0a0a0a;
  --threads-card-dark: #141414;
  --threads-border-dark: #262626;
  --threads-text-dark: #f3f5f7;
  --threads-muted-dark: #777777;

  --threads-white: #ffffff;
  --threads-light-bg: #ffffff;
  --threads-card-light: #ffffff;
  --threads-border-light: #e5e5e5;
  --threads-text-light: #000000;
  --threads-muted-light: #737373;

  --threads-pill-hover: #262626;
  --threads-error-bg: #1c1010;
  --threads-error-border: #441c1c;
  --threads-error-text: #ff7b7b;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--threads-black);
  color: var(--threads-text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ==========================================================================
   Header: Minimalist bar with ONLY the authentic Threads logo
   ========================================================================== */
.app-header {
  background-color: var(--threads-black);
  border-bottom: 1px solid var(--threads-border-dark);
  padding: 16px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.threads-brand-logo {
  display: block;
  filter: brightness(0) invert(1); /* Ensures pure white vector icon */
  transition: transform 0.2s ease;
}

.threads-brand-logo:hover {
  transform: scale(1.05);
}

/* ==========================================================================
   Hero Section: Premium Black & White Theme
   ========================================================================== */
.hero-section {
  background-color: var(--threads-black);
  padding: 64px 20px 72px;
  position: relative;
  border-bottom: 1px solid var(--threads-border-dark);
  background-image: radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.04) 0%, transparent 60%);
}

.hero-container {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
}

.main-heading {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
  margin-bottom: 12px;
  line-height: 1.15;
}

.hero-subtext {
  font-size: 1.125rem;
  color: var(--threads-muted-dark);
  margin-bottom: 36px;
  font-weight: 400;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

/* Input Form */
.downloader-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  width: 100%;
}

.input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  background-color: var(--threads-card-dark);
  border: 1px solid var(--threads-border-dark);
  border-radius: var(--radius-full);
  padding: 6px 14px 6px 18px;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.input-wrapper:focus-within {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15), 0 8px 30px rgba(0, 0, 0, 0.6);
}

.link-icon {
  width: 20px;
  height: 20px;
  color: var(--threads-muted-dark);
  flex-shrink: 0;
  margin-right: 12px;
}

.url-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 1.05rem;
  font-family: inherit;
  padding: 10px 0;
}

.url-input::placeholder {
  color: #666666;
}

.clear-btn {
  background: transparent;
  border: none;
  color: #888888;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-right: 4px;
}

.clear-btn svg {
  width: 16px;
  height: 16px;
}

.clear-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}

.paste-btn {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.paste-btn svg {
  width: 14px;
  height: 14px;
}

.paste-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Prominent Download Button */
.download-btn {
  width: 100%;
  max-width: 280px;
  background-color: #ffffff;
  color: #000000;
  border: none;
  border-radius: var(--radius-full);
  padding: 15px 36px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.15);
}

.download-btn:hover {
  background-color: #e5e5e5;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.25);
}

.download-btn:active {
  transform: translateY(0);
}

.download-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #000000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Sample post pill */
.sample-post-wrapper {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.875rem;
}

.sample-label {
  color: var(--threads-muted-dark);
}

.sample-link-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  padding: 2px 4px;
}

.sample-link-btn:hover {
  color: #a8a8a8;
}

/* Error Banner */
.error-banner {
  margin-top: 24px;
  background-color: var(--threads-error-bg);
  border: 1px solid var(--threads-error-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  animation: fadeIn 0.25s ease-out;
}

.error-icon {
  color: var(--threads-error-text);
  flex-shrink: 0;
  padding-top: 2px;
}

.error-icon svg {
  width: 20px;
  height: 20px;
}

.error-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--threads-error-text);
  margin-bottom: 2px;
}

.error-text {
  font-size: 0.875rem;
  color: #d8b4b4;
  line-height: 1.4;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Content Section: Pure White Background Beneath Hero
   ========================================================================== */
.content-section {
  background-color: var(--threads-white);
  color: var(--threads-text-light);
  padding: 56px 20px 80px;
  min-height: 480px;
}

.content-container {
  max-width: 960px;
  margin: 0 auto;
}

/* Result Section & Card */
.result-section {
  margin-bottom: 56px;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.result-card {
  background-color: #ffffff;
  border: 1px solid var(--threads-border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.result-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 28px;
  align-items: start;
}

/* Video Player Preview */
.video-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.video-player-container {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 480px;
  background-color: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000000;
}

.video-meta-badge {
  display: flex;
  gap: 8px;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.badge-resolution {
  background-color: #000000;
  color: #ffffff;
}

.badge-size {
  background-color: #f0f0f0;
  color: #333333;
}

/* Video Info Details */
.video-details-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Author Row */
.author-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--threads-border-light);
}

.author-avatar-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background-color: #f2f2f2;
  border: 1px solid var(--threads-border-light);
  flex-shrink: 0;
}

.author-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888888;
}

.author-avatar-fallback svg {
  width: 24px;
  height: 24px;
}

.author-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.author-handle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-username {
  font-size: 1.1rem;
  font-weight: 700;
  color: #000000;
}

.post-source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666666;
  text-decoration: none;
  padding: 2px 8px;
  background-color: #f5f5f5;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.post-source-link:hover {
  background-color: #e8e8e8;
  color: #000000;
}

.platform-tag {
  font-size: 0.8rem;
  color: var(--threads-muted-light);
}

/* Caption */
.caption-container {
  background-color: #fbfbfb;
  border: 1px solid #f0f0f0;
  border-radius: var(--radius-md);
  padding: 16px;
}

.post-caption {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #222222;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

/* Download Actions */
.download-action-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.primary-download-btn {
  background-color: #000000;
  color: #ffffff;
  text-decoration: none;
  padding: 16px 28px;
  border-radius: var(--radius-full);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.primary-download-btn svg {
  width: 20px;
  height: 20px;
}

.primary-download-btn:hover {
  background-color: #222222;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.secondary-actions {
  display: flex;
  gap: 10px;
}

.secondary-action-btn {
  flex: 1;
  background-color: #f5f5f5;
  color: #111111;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-full);
  padding: 12px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.secondary-action-btn svg {
  width: 16px;
  height: 16px;
}

.secondary-action-btn:hover {
  background-color: #ebebeb;
  border-color: #d0d0d0;
}

/* ==========================================================================
   Information Cards Grid
   ========================================================================== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.info-card {
  background-color: #ffffff;
  border: 1px solid var(--threads-border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.info-card:hover {
  border-color: #cccccc;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.info-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: #000000;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.info-icon svg {
  width: 20px;
  height: 20px;
}

.info-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--threads-text-light);
  margin-bottom: 10px;
}

.info-text {
  font-size: 0.9rem;
  color: var(--threads-muted-light);
  line-height: 1.5;
}

.steps-list {
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--threads-muted-light);
  line-height: 1.6;
}

.steps-list li {
  margin-bottom: 6px;
}

.format-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.format-list code {
  font-size: 0.85rem;
  background-color: #f2f2f2;
  padding: 3px 8px;
  border-radius: 4px;
  color: #000000;
  display: inline-block;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  background-color: var(--threads-white);
  border-top: 1px solid var(--threads-border-light);
  padding: 32px 20px;
  color: var(--threads-muted-light);
  font-size: 0.85rem;
  text-align: center;
}

.footer-container {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.footer-logo img {
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.footer-logo img:hover {
  opacity: 0.8;
}

.footer-disclaimer {
  line-height: 1.5;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 820px) {
  .result-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .video-player-container {
    max-height: 380px;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .main-heading {
    font-size: 2.15rem;
  }
}

@media (max-width: 520px) {
  .hero-section {
    padding: 40px 16px 48px;
  }

  .main-heading {
    font-size: 1.85rem;
  }

  .input-wrapper {
    padding: 4px 10px 4px 14px;
  }

  .paste-btn span {
    display: none;
  }

  .paste-btn {
    padding: 6px;
  }

  .secondary-actions {
    flex-direction: column;
  }

  .content-section {
    padding: 40px 16px 60px;
  }

  .result-card {
    padding: 16px;
  }
}
