:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --bg-3: #111827;
  --bg-hover: #1f2937;
  --border: #1f2937;
  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #01b4e4; /* TMDB blue */
  --accent-2: #60a5fa;
  --imdb: #f3ce13;
  --danger: #fca5a5;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Topbar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #000;
  border-radius: 6px;
  font-weight: 800;
}

.search-form {
  flex: 1;
  display: flex;
  gap: 8px;
  max-width: 720px;
}
.search-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-3);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.search-form input:focus {
  border-color: var(--accent-2);
}
.search-form input::placeholder {
  color: var(--text-dim);
}

.btn {
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover {
  filter: brightness(1.1);
}
.btn:active {
  filter: brightness(0.95);
}

.nav-link {
  color: var(--text-muted);
  font-size: 13px;
}

/* Main ---------------------------------------------------------------- */

#main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.status {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.status.error {
  color: var(--danger);
}
.status.loading::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none;
}

/* Results grid -------------------------------------------------------- */

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-3);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  border: 1px solid transparent;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border-color: var(--bg-hover);
}

.card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--bg-2);
  background-image: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  object-fit: cover;
  display: block;
}
.card-poster.no-poster {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
}

.card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: auto;
}

.card-ratings {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.rating.tmdb {
  background: var(--accent);
  color: #000;
}
.rating.imdb {
  background: var(--imdb);
  color: #000;
}

/* Detail dialog ------------------------------------------------------- */

.detail {
  border: 0;
  padding: 0;
  background: var(--bg-3);
  color: var(--text);
  border-radius: var(--radius);
  max-width: 900px;
  width: 92%;
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.detail::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.detail .close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  z-index: 2;
}
.detail .close:hover {
  background: var(--bg-hover);
}

.detail-body {
  display: flex;
  gap: 24px;
  padding: 24px;
}
.detail-poster {
  width: 220px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
}
.detail-poster img {
  width: 100%;
  display: block;
}
.detail-info {
  flex: 1;
  min-width: 0;
}
.detail-info h2 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #f9fafb;
}
.detail-info .alt-title {
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
  margin-bottom: 12px;
}
.detail-info .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-muted);
}

.detail-info .links {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}
.link-pill {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.link-pill.tmdb {
  background: var(--accent);
  color: #000;
}
.link-pill.imdb {
  background: var(--imdb);
  color: #000;
}
.link-pill:hover {
  text-decoration: none;
  filter: brightness(1.1);
}

.detail-info .tagline {
  font-style: italic;
  color: var(--text-muted);
  margin: 12px 0;
}
.detail-info .overview {
  color: var(--text);
  line-height: 1.6;
  margin: 12px 0;
}
.detail-info .money {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
}

#providers-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
#providers-section h3 {
  font-size: 14px;
  margin: 0 0 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.providers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-hover);
  border-radius: 6px;
  font-size: 12px;
}
.provider img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap;
  }
  .nav-link {
    display: none;
  }
  .detail-body {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }
  .detail-poster {
    width: 140px;
    margin: 0 auto;
  }
}

/* Footer -------------------------------------------------------------- */

.footer {
  text-align: center;
  padding: 16px;
  color: var(--text-dim);
  font-size: 12px;
}
