/* ===========================
   Global Styles
   =========================== */

:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary-color: #8b5cf6;
  --accent-color: #ec4899;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  --transition-base: all 0.3s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

/* ===========================
   Container
   =========================== */

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

/* ===========================
   Header
   =========================== */

.header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.1;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="none" stroke="white" stroke-width="0.5"/></svg>');
  background-size: 50px 50px;
}

.header-content {
  position: relative;
  z-index: 1;
}

.logo {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.logo-icon {
  display: inline-block;
  margin-right: 0.5rem;
  animation: bounce 2s infinite;
}

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

.tagline {
  font-size: 1.125rem;
  font-weight: 300;
  opacity: 0.95;
}

/* ===========================
   Main Content
   =========================== */

.main {
  flex: 1;
  padding: 2rem;
}

/* ===========================
   Search Section
   =========================== */

.search-section {
  margin-bottom: 2rem;
}

.search-container {
  width: 100%;
  max-width: 2000px;
  margin: 0 auto 1rem;
}

.search-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}

.search-input-group {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
}

.search-input {
  flex: 1;
  padding: 1rem 1.1rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition-base);
  min-width: 0;
}

.search-input:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

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

.search-info-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 1rem;
  background-color: rgba(99, 102, 241, 0.06);
}

.search-description {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.search-btn {
  padding: 1rem 1.6rem;
  min-width: 160px;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}

.search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(79, 70, 229, 0.2);
}

.search-btn:disabled {
  background-color: var(--border-color);
  cursor: not-allowed;
  transform: none;
}

.search-input:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

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

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

.search-btn {
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-md);
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.search-hint {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ===========================
   Loading Spinner
   =========================== */

.loading-spinner {
  text-align: center;
  padding: 2rem;
}

.loading-spinner.hidden {
  display: none;
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-spinner p {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===========================
   Error Message
   =========================== */

.error-message {
  background-color: #fef2f2;
  border: 1px solid var(--error-color);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #991b1b;
  animation: slideDown 0.3s ease-out;
}

.error-message.hidden {
  display: none;
}

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

.error-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.error-close {
  background: none;
  border: none;
  color: #991b1b;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
  padding: 0;
  transition: var(--transition-base);
}

.error-close:hover {
  opacity: 0.7;
}

/* ===========================
   Results Section
   =========================== */

.results-section {
  animation: fadeIn 0.3s ease-out;
}

.results-section.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.results-header {
  margin-bottom: 1.5rem;
}

.results-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.results-info {
  color: var(--text-secondary);
  font-size: 0.975rem;
}

.no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

.no-results.hidden {
  display: none;
}

/* ===========================
   Videos Grid
   =========================== */

.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* ===========================
   Video Card
   =========================== */

.video-card {
  background-color: var(--bg-primary);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: var(--transition-base);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  overflow: hidden;
  background-color: var(--bg-tertiary);
}

.video-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-base);
}

.video-card:hover .video-thumbnail img {
  transform: scale(1.05);
}

.score-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background-color: rgba(16, 185, 129, 0.95);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 10;
}

.video-content {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.video-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-channel {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.video-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  flex: 1;
  align-content: start;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.watch-link {
  display: inline-block;
  margin-top: auto;
  padding: 0.75rem 1rem;
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  transition: var(--transition-base);
  border: none;
  cursor: pointer;
}

.watch-link:hover {
  background-color: var(--primary-dark);
  transform: translateX(2px);
}

.video-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.feedback-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: 0.5rem;
}

.feedback-scale {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

.feedback-scale-btn {
  background: none;
  border: none;
  padding: 0.35rem;
  cursor: pointer;
  font-size: 1.45rem;
  transition: var(--transition-base);
  border-radius: 0.5rem;
}

.feedback-scale-btn:hover {
  transform: translateY(-1px);
}

.feedback-scale-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.feedback-status {
  color: var(--success-color);
  font-size: 0.95rem;
  font-weight: 600;
}

.feedback-status.hidden {
  display: none;
}

/* ===========================
   Empty State
   =========================== */

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

.empty-state-content {
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.empty-state-content h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* ===========================
   Footer
   =========================== */

.footer {
  background-color: var(--bg-tertiary);
  padding: 1.5rem 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-top: 1px solid var(--border-color);
}

.heart {
  display: inline-block;
  animation: heartBeat 1.3s infinite;
}

@keyframes heartBeat {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
  .main {
    padding: 1rem;
  }

  .header {
    padding: 2rem 1rem;
  }

  .logo {
    font-size: 1.75rem;
  }

  .tagline {
    font-size: 1rem;
  }

  .search-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .search-input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
  }

  .search-input {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .search-btn {
    width: 100%;
  }

  .videos-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .video-stats {
    grid-template-columns: 1fr;
  }

  .video-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .feedback-widget {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .watch-link {
    width: 100%;
  }

  .footer {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 1.5rem;
  }

  .tagline {
    font-size: 0.875rem;
  }

  .search-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.95rem 1rem;
  }

  .search-btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
  }

  .results-header h2 {
    font-size: 1.25rem;
  }

  .video-title {
    font-size: 0.95rem;
  }

  .feedback-scale-btn {
    font-size: 1.3rem;
  }

  .video-stats {
    gap: 0.5rem;
  }
}

/* ===========================
   Utility Classes
   =========================== */

.hidden {
  display: none !important;
}

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