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

:root {
  --primary: #ff0000;
  --primary-dark: #cc0000;
  --primary-light: #ff4444;
  --bg-dark: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-input: #272727;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --border-color: #333333;
  --success: #00c853;
  --error: #ff5252;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 40px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: 700;
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--primary);
}

/* Main Content */
.main {
  flex: 1;
}

.search-section {
  text-align: center;
  margin-bottom: 40px;
}

.search-section h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 30px;
}

/* Search Box */
.search-box {
  display: flex;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.search-box input {
  flex: 1;
  padding: 16px 20px;
  font-size: 1rem;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.1);
}

.search-box input::placeholder {
  color: var(--text-secondary);
}

.btn-primary {
  padding: 16px 28px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
}

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

.btn-primary.loading .btn-text {
  display: none;
}

.btn-primary.loading .btn-loader {
  display: block;
}

.btn-loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
  max-width: 600px;
  margin: 16px auto 0;
  padding: 12px 16px;
  background: rgba(255, 82, 82, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.9rem;
  display: none;
}

.error-message.show {
  display: block;
}

/* Video Info */
.video-info {
  animation: fadeIn 0.4s ease;
}

.video-info.hidden {
  display: none;
}

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

.video-card {
  display: flex;
  gap: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.thumbnail-container {
  position: relative;
  flex-shrink: 0;
  width: 280px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.thumbnail-container img {
  width: 100%;
  height: auto;
  display: block;
}

.duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.video-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.video-details h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.author {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.views {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Download Section */
.download-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.format-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 500;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn svg {
  width: 22px;
  height: 22px;
}

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

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

/* Formats List */
.formats-list {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.format-header {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-input);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.format-item {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  padding: 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s ease;
}

.format-item:last-child {
  border-bottom: none;
}

.format-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.quality-label {
  font-weight: 600;
  font-size: 1rem;
}

.quality-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  margin-left: 8px;
}

.format-type {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.btn-download {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-download:hover {
  background: var(--primary);
  color: white;
}

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

/* Footer */
.footer {
  margin-top: 40px;
  padding: 24px 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.footer p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.footer code {
  display: block;
  margin: 8px auto;
  padding: 10px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  color: var(--primary-light);
  max-width: 500px;
}

/* Responsive */
@media (max-width: 768px) {
  .search-section h1 {
    font-size: 1.5rem;
  }
  
  .search-box {
    flex-direction: column;
  }
  
  .video-card {
    flex-direction: column;
  }
  
  .thumbnail-container {
    width: 100%;
  }
  
  .format-tabs {
    flex-direction: column;
  }
  
  .format-header,
  .format-item {
    grid-template-columns: 1fr auto;
  }
  
  .format-header span:nth-child(2),
  .format-type {
    display: none;
  }
}

/* Embed Styles (for iframe) */
body.embed-mode {
  background: transparent;
}

body.embed-mode .container {
  padding: 10px;
}

body.embed-mode .header,
body.embed-mode .footer {
  display: none;
}

body.embed-mode .search-section h1 {
  font-size: 1.25rem;
}

body.embed-mode .search-section {
  margin-bottom: 20px;
}

body.embed-mode .subtitle {
  display: none;
}
