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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header */
header {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  white-space: nowrap;
}

.search-form {
  display: flex;
  flex: 1;
  min-width: 200px;
  max-width: 500px;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #30363d;
  border-radius: 6px 0 0 6px;
  background: #0d1117;
  color: #e6edf3;
  font-size: 1rem;
}

.search-input:focus {
  outline: none;
  border-color: #58a6ff;
}

.search-btn {
  padding: 0.75rem 1.25rem;
  background: #238636;
  color: white;
  border: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
}

.search-btn:hover {
  background: #2ea043;
}

/* Main content */
main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

.page-title {
  margin-bottom: 2rem;
  font-size: 1.75rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: #58a6ff;
}

.back-link:hover {
  text-decoration: underline;
}

/* Movie grid */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
}

.movie-card {
  background: #161b22;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.movie-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.movie-poster {
  position: relative;
  aspect-ratio: 2/3;
  background: #21262d;
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-poster {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #8b949e;
  font-size: 0.875rem;
}

.no-poster.large {
  height: 400px;
  font-size: 1.25rem;
}

.movie-rating {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
}

.movie-info {
  padding: 0.75rem;
}

.movie-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.movie-year {
  font-size: 0.85rem;
  color: #8b949e;
}

.movie-character {
  font-size: 0.8rem;
  color: #58a6ff;
  margin-top: 0.25rem;
  font-style: italic;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}

.page-btn {
  padding: 0.75rem 1.5rem;
  background: #21262d;
  border-radius: 6px;
  color: #58a6ff;
  font-weight: 500;
}

.page-btn:hover {
  background: #30363d;
}

.page-info {
  color: #8b949e;
}

/* Movie detail page */
.movie-detail {
  display: flex;
  gap: 2rem;
  margin-bottom: 3rem;
}

.movie-detail-poster {
  flex-shrink: 0;
  width: 300px;
}

.movie-detail-poster img {
  width: 100%;
  border-radius: 8px;
}

.movie-detail-info {
  flex: 1;
}

.movie-detail-info h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.tagline {
  color: #8b949e;
  font-style: italic;
  margin-bottom: 1rem;
}

.movie-meta {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.movie-meta span {
  color: #8b949e;
}

.movie-meta .rating {
  color: #f0c14b;
}

.genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.genre-tag {
  background: #21262d;
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
}

.movie-detail-info h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
}

.overview {
  line-height: 1.7;
  color: #c9d1d9;
}

/* Cast section */
.cast-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.cast-card {
  background: #161b22;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s;
}

.cast-card:hover {
  transform: translateY(-2px);
}

.cast-photo {
  aspect-ratio: 2/3;
  background: #21262d;
}

.cast-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3rem;
  color: #30363d;
}

.no-photo.large {
  height: 300px;
  font-size: 5rem;
}

.cast-info {
  padding: 0.75rem;
}

.actor-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.character-name {
  font-size: 0.8rem;
  color: #8b949e;
}

/* Actor detail page */
.actor-detail {
  display: flex;
  gap: 2rem;
  margin-bottom: 3rem;
}

.actor-detail-photo {
  flex-shrink: 0;
  width: 250px;
}

.actor-detail-photo img {
  width: 100%;
  border-radius: 8px;
}

.actor-detail-info {
  flex: 1;
}

.actor-detail-info h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.actor-meta p {
  margin-bottom: 0.5rem;
  color: #8b949e;
}

.actor-meta strong {
  color: #e6edf3;
}

.biography {
  line-height: 1.7;
  color: #c9d1d9;
  max-height: 300px;
  overflow-y: auto;
}

.filmography-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Production companies */
.production-companies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.company-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #21262d;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.company-link:hover {
  background: #30363d;
}

.company-logo {
  height: 24px;
  width: auto;
  max-width: 60px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.company-link span {
  color: #58a6ff;
  font-size: 0.9rem;
}

/* Company detail page */
.company-detail {
  margin-bottom: 2rem;
}

.company-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1.5rem;
  background: #161b22;
  border-radius: 8px;
}

.company-detail-logo {
  max-width: 150px;
  max-height: 80px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.company-info h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.company-meta {
  color: #8b949e;
  margin-bottom: 0.25rem;
}

.company-meta strong {
  color: #e6edf3;
}

/* Error page */
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-page h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-page p {
  color: #8b949e;
  margin-bottom: 2rem;
}

/* No results */
.no-results {
  text-align: center;
  color: #8b949e;
  padding: 4rem 1rem;
}

/* Footer */
footer {
  background: #161b22;
  border-top: 1px solid #30363d;
  padding: 1.5rem;
  text-align: center;
  color: #8b949e;
}

/* Responsive design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .logo {
    text-align: center;
  }

  .search-form {
    max-width: none;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .movie-detail {
    flex-direction: column;
  }

  .movie-detail-poster {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
  }

  .movie-detail-info h1 {
    font-size: 1.5rem;
  }

  .actor-detail {
    flex-direction: column;
  }

  .actor-detail-photo {
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
  }

  .actor-detail-info h1 {
    font-size: 1.5rem;
    text-align: center;
  }

  .actor-meta {
    text-align: center;
  }

  .company-header {
    flex-direction: column;
    text-align: center;
  }

  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }

  .cast-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

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

  .movie-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .cast-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .movie-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .pagination {
    flex-direction: column;
  }
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(13, 17, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #30363d;
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: #8b949e;
  font-size: 1rem;
}

/* Movie action buttons */
.movie-actions {
  margin: 1.5rem 0;
}

.btn {
  display: inline-block;
  padding: 0.875rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-watch {
  background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(35, 134, 54, 0.4);
}

.btn-watch:hover {
  background: linear-gradient(135deg, #2ea043 0%, #3fb950 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(35, 134, 54, 0.5);
}

.btn-request {
  background: linear-gradient(135deg, #1f6feb 0%, #388bfd 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(31, 111, 235, 0.4);
}

.btn-request:hover:not(:disabled) {
  background: linear-gradient(135deg, #388bfd 0%, #58a6ff 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(31, 111, 235, 0.5);
}

.btn-request:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  background: #21262d;
  color: #8b949e;
  box-shadow: none;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #238636;
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1001;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Watch page styles */
.watch-page {
  max-width: 1200px;
  margin: 0 auto;
}

.watch-container {
  margin-top: 1rem;
}

.watch-title {
  margin-bottom: 1rem;
  font-size: 1.75rem;
}

.video-player {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.watch-info {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: #161b22;
  border-radius: 12px;
  border: 1px solid #30363d;
}

.watch-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.watch-info .genres {
  margin-bottom: 1rem;
}

.watch-info .overview {
  color: #c9d1d9;
  line-height: 1.6;
}

/* Unavailable movie styles */
.movie-card.unavailable .movie-poster img {
  opacity: 0.4;
  filter: grayscale(50%);
}

.movie-card.unavailable .movie-poster .no-poster {
  opacity: 0.4;
}

.unavailable-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #f85149;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  z-index: 2;
}

/* Request movie prompt */
.request-movie-prompt {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #161b22;
  border-radius: 12px;
  border: 1px solid #30363d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.request-movie-prompt span {
  color: #c9d1d9;
  font-size: 1.1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #161b22;
  border-radius: 12px;
  border: 1px solid #30363d;
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #c9d1d9;
}

.modal h2 {
  margin-bottom: 0.5rem;
  color: #c9d1d9;
}

.modal > p {
  color: #8b949e;
  margin-bottom: 1.5rem;
}

/* Success view */
.request-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 0;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: #238636;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  margin-bottom: 1.5rem;
}

.request-success h3 {
  color: #c9d1d9;
  margin-bottom: 0.5rem;
}

.request-success p {
  color: #8b949e;
  margin-bottom: 1.5rem;
}

.request-movie-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: #c9d1d9;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  color: #c9d1d9;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #388bfd;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #6e7681;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.request-movie-form .btn {
  align-self: flex-start;
  margin-top: 0.5rem;
}
