/**
 * MediaStation Flask App - Custom CSS Styles
 * Complements Tailwind CSS with custom components and animations
 */

/* ========================================================================== */
/* LOADING SPINNER ANIMATION */
/* ========================================================================== */

.loading-spinner {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.loading-spinner > div {
  width: 12px;
  height: 12px;
  background: #3b82f6;
  border-radius: 50%;
  animation: loading-bounce 1.4s infinite ease-in-out both;
}

.loading-spinner > div:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-spinner > div:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loading-bounce {
  0%, 80%, 100% {
    opacity: 0.5;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================================================== */
/* ERROR ALERTS */
/* ========================================================================== */

.error-alert {
  padding: 1rem;
  background-color: #fee2e2;
  border-left: 4px solid #dc2626;
  color: #7f1d1d;
  border-radius: 0.375rem;
  margin: 1rem 0;
}

.error-alert strong {
  font-weight: 600;
}

/* ========================================================================== */
/* SUCCESS TOAST NOTIFICATIONS */
/* ========================================================================== */

.success-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 1rem 1.5rem;
  background-color: #dcfce7;
  border-left: 4px solid #16a34a;
  color: #166534;
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  animation: slide-in-up 0.3s ease-out, slide-out-down 0.3s ease-in 2.7s forwards;
  z-index: 9999;
  max-width: 300px;
}

@keyframes slide-in-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-out-down {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* ========================================================================== */
/* EMPTY STATE */
/* ========================================================================== */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6b7280;
  font-size: 1.125rem;
}

/* ========================================================================== */
/* MOVIE & SHOW CARDS */
/* ========================================================================== */

.movie-card,
.show-card {
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  background: white;
}

.movie-card:hover,
.show-card:hover {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  transform: translateY(-4px);
}

.movie-poster,
.show-poster {
  position: relative;
  overflow: hidden;
  background-color: #f3f4f6;
  aspect-ratio: 2 / 3;
}

.movie-poster img,
.show-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.movie-card:hover .movie-poster img,
.show-card:hover .show-poster img {
  transform: scale(1.05);
}

.no-poster {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-weight: 500;
  font-size: 0.875rem;
}

.movie-info,
.show-info {
  padding: 1rem;
}

.movie-title,
.show-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movie-year,
.movie-overview,
.show-status,
.show-next {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.show-status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background-color: #f3f4f6;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.show-status.continuing {
  background-color: #dbeafe;
  color: #1e40af;
}

.show-status.ended {
  background-color: #fee2e2;
  color: #7f1d1d;
}

.show-status.upcoming {
  background-color: #fef3c7;
  color: #92400e;
}

.movie-actions,
.show-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ========================================================================== */
/* BUTTONS */
/* ========================================================================== */

.btn-small {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background-color: #2563eb;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.btn-success {
  background-color: #10b981;
  color: white;
}

.btn-success:hover {
  background-color: #059669;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.btn-warning {
  background-color: #f59e0b;
  color: white;
}

.btn-warning:hover {
  background-color: #d97706;
  box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.2);
}

.btn-danger {
  background-color: #ef4444;
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
  box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.btn-info {
  background-color: #06b6d4;
  color: white;
}

.btn-info:hover {
  background-color: #0891b2;
  box-shadow: 0 4px 6px -1px rgba(6, 182, 212, 0.2);
}

/* ========================================================================== */
/* DOWNLOAD/TORRENT ROW */
/* ========================================================================== */

.torrent-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1.5rem;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  background: white;
  align-items: center;
  margin-bottom: 0.75rem;
  transition: all 0.2s ease;
}

.torrent-row:hover {
  background-color: #f9fafb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.torrent-info {
  min-width: 0;
}

.torrent-name {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 500;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.torrent-details {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: #6b7280;
}

.status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background-color: #e5e7eb;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: capitalize;
}

.status.downloading {
  background-color: #dbeafe;
  color: #1e40af;
}

.status.seeding {
  background-color: #dcfce7;
  color: #166534;
}

.status.paused {
  background-color: #fef3c7;
  color: #92400e;
}

.status.metaDL {
  background-color: #f3e8ff;
  color: #6b21a8;
}

/* ========================================================================== */
/* PROGRESS BAR */
/* ========================================================================== */

.torrent-progress {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  min-width: 150px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 9999px;
  transition: width 0.3s ease;
  animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
  0% {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  }
  50% {
    background: linear-gradient(90deg, #8b5cf6, #3b82f6);
  }
  100% {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  }
}

.progress-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  min-width: 40px;
  text-align: center;
}

/* ========================================================================== */
/* TORRENT ACTIONS */
/* ========================================================================== */

.torrent-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ========================================================================== */
/* SEARCH RESULTS */
/* ========================================================================== */

.search-result {
  padding: 1.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  background: white;
  transition: all 0.2s ease;
}

.search-result:hover {
  background-color: #f9fafb;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.result-info {
  margin-bottom: 1rem;
}

.result-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
}

.result-indexer {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.result-details {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.result-date {
  margin: 0.5rem 0 0 0;
  font-size: 0.875rem;
  color: #9ca3af;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: #f3f4f6;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #374151;
  text-transform: capitalize;
}

.result-actions {
  display: flex;
  gap: 0.75rem;
}

/* ========================================================================== */
/* ROKU REMOTE CONTROLS */
/* ========================================================================== */

.roku-remote {
  max-width: 400px;
  margin: 2rem auto;
  padding: 2rem;
  background: linear-gradient(135deg, #1f2937, #111827);
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.roku-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  background-color: #374151;
}

.roku-btn:hover {
  background-color: #4b5563;
  transform: scale(1.05);
}

.roku-btn:active {
  transform: scale(0.95);
}

.roku-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 200px;
  margin: 1.5rem auto;
}

.roku-dpad-btn {
  aspect-ratio: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  background-color: #374151;
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.25rem;
  transition: all 0.2s ease;
}

.roku-dpad-btn:hover {
  background-color: #4b5563;
  transform: scale(1.1);
}

.roku-dpad-btn:active {
  transform: scale(0.95);
}

.roku-dpad-spacer {
  grid-column: 2;
}

/* ========================================================================== */
/* CUSTOM SCROLLBAR */
/* ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f3f4f6;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ========================================================================== */
/* RESPONSIVE DESIGN */
/* ========================================================================== */

@media (max-width: 768px) {
  .torrent-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .torrent-progress {
    flex-direction: row;
    min-width: auto;
  }

  .torrent-actions {
    justify-content: flex-start;
  }

  .success-toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }

  .roku-remote {
    max-width: 100%;
    margin: 1rem;
    padding: 1.5rem;
  }
}

/* ========================================================================== */
/* PRINT STYLES */
/* ========================================================================== */

@media print {
  .torrent-actions,
  .movie-actions,
  .show-actions,
  .result-actions {
    display: none;
  }

  .loading-spinner,
  .success-toast,
  .error-alert {
    display: none;
  }
}

/* ========================================================================== */
/* DARK MODE SUPPORT (for future implementation) */
/* ========================================================================== */

@media (prefers-color-scheme: dark) {
  /* Can be extended for dark mode support in future */
}

/* ========================================================================== */
/* ACCESSIBILITY IMPROVEMENTS */
/* ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
.btn-small:focus-visible,
.roku-btn:focus-visible,
.roku-dpad-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
