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

:root {
  color-scheme: dark;
  --bg: #07090e;
  --card-bg: rgba(13, 17, 28, 0.45);
  --card-bg-hover: rgba(18, 23, 38, 0.55);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #f3f5f9;
  --text-muted: #8b9bb4;
  --primary: #6366f1;
  --primary-rgb: 99, 102, 241;
  --accent: #10b981;
  --accent-rgb: 16, 185, 129;
  
  --font-base: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;
  
  --shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.5);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  min-height: 100vh;
  font-family: var(--font-base);
  color: var(--text);
  background-color: var(--bg);
  background-image: 
    radial-gradient(circle at 50% -20%, rgba(99, 102, 241, 0.15), transparent 45%),
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05), transparent 30%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.05), transparent 30%);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(640px, 100% - 24px);
  margin: 0 auto;
  padding: 40px 0 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header / Branding */
.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-group h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, #8b9bb4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.tagline {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: -8px;
  margin-bottom: 8px;
}

/* Base Card Style */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 20px;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

/* Input Area */
.search-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: rgba(5, 7, 12, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 8px;
  transition: var(--transition);
}

.search-bar:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.search-bar input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  padding: 12px 14px;
  outline: none;
  width: 100%;
}

.search-bar input::placeholder {
  color: #52637a;
}

.clear-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 1.3rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: var(--transition);
}

.clear-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.primary-btn {
  border: 0;
  background: var(--primary);
  color: white;
  font-family: var(--font-base);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.primary-btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

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

/* Badge System */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.platform-badge {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 99px;
  transition: var(--transition);
}

.platform-badge.active {
  color: white;
  border-color: transparent;
}

.platform-badge[data-platform="instagram"].active {
  background: linear-gradient(135deg, #f09433, #dc2743, #bc1888);
  box-shadow: 0 4px 12px rgba(220, 39, 67, 0.25);
}

.platform-badge[data-platform="youtube"].active {
  background: #ff0000;
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.25);
}

.platform-badge[data-platform="tiktok"].active {
  background: linear-gradient(135deg, #00f2fe, #fe0979);
  box-shadow: 0 4px 12px rgba(0, 242, 254, 0.25);
}

.platform-badge[data-platform="twitter"].active {
  background: #111;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

.platform-badge[data-platform="facebook"].active {
  background: #1877f2;
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.25);
}

/* Status Area & Loader */
.status-area-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}

.progress-bar-wrapper {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-spinner-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.progress-percentage {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: none;
}

.spinner.active {
  display: inline-block;
}

.loading-steps {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.45;
  transition: var(--transition);
}

.loading-step.active {
  color: var(--text);
  opacity: 1;
  font-weight: 500;
}

.loading-step.completed {
  color: var(--accent);
  opacity: 0.9;
}

.loading-step .step-icon {
  font-size: 0.8rem;
}

.loading-step.active .step-icon {
  color: var(--primary);
  animation: pulse 1.5s infinite;
}

/* Result Card */
.result-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-card.hidden {
  display: none;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 2px;
  display: block;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.result-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.source-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 99px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.01);
}

.empty-icon {
  font-size: 1.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  opacity: 0.5;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 320px;
}

/* Preview Component */
.preview-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 16px;
  align-items: center;
}

#thumbnail {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.meta-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.platform-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

#media-title {
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#media-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Downloads Section */
.downloads-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.downloads-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.downloads-group.hidden {
  display: none !important;
}

.formats-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.formats-head h3 {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
}

.formats-head span {
  font-size: 0.74rem;
  color: var(--text-muted);
  opacity: 0.8;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.format-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.format-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(99, 102, 241, 0.35);
}

.format-btn strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
}

.format-btn span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.format-emoji {
  font-size: 0.84rem;
  color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.format-btn.loading {
  pointer-events: none;
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
  opacity: 0.8;
}

.format-btn.loading .format-emoji {
  animation: format-spin 1s linear infinite;
  background: rgba(99, 102, 241, 0.15) !important;
  color: var(--primary) !important;
}

@keyframes format-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* History Accordion */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.01);
}

.accordion-header h2 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
}

.accordion-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.accordion.open .accordion-arrow {
  transform: rotate(90deg);
}

.accordion-content {
  display: none;
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  max-height: 280px;
  overflow-y: auto;
}

.accordion.open .accordion-content {
  display: block;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.history-item strong {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

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

.history-item a {
  font-size: 0.72rem;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
  margin-top: 2px;
  display: inline-block;
}

.history-item a:hover {
  text-decoration: underline;
}

.history-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Custom Scrollbar for Accordion Content */
.accordion-content::-webkit-scrollbar {
  width: 6px;
}

.accordion-content::-webkit-scrollbar-track {
  background: transparent;
}

.accordion-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}

.accordion-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Mobile Styling tweaks */
@media (max-width: 500px) {
  .shell {
    padding: 20px 0 40px;
  }
  
  .card, .accordion-header, .accordion-content {
    padding: 16px 14px;
  }
  
  .loading-steps {
    grid-template-columns: 1fr;
  }
  
  .format-grid {
    grid-template-columns: 1fr;
  }
  
  .preview-row {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}