/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  padding: 30px 20px;
  text-align: center;
  border-bottom: 1px solid #21262d;
}

.logo {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f97316, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
}

.tagline {
  color: #8b949e;
  font-size: 1rem;
  margin-top: 4px;
}

/* ===== Main ===== */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 20px;
}

/* ===== Search ===== */
.add-section {
  margin-bottom: 40px;
}

.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

#searchInput {
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
  border: 2px solid #30363d;
  border-radius: 12px;
  background: #161b22;
  color: #e6edf3;
  outline: none;
  transition: border-color 0.2s;
}

#searchInput:focus {
  border-color: #f97316;
}

#searchInput::placeholder {
  color: #6e7681;
}

/* ===== Search Results Dropdown ===== */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1c2128;
  border: 1px solid #30363d;
  border-radius: 10px;
  margin-top: 6px;
  max-height: 350px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

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

.search-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #21262d;
  transition: background 0.15s;
}

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

.search-item:hover {
  background: #262c36;
}

.search-item img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 12px;
  background: #30363d;
}

.search-item-info {
  flex: 1;
}

.search-item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.search-item-meta {
  color: #8b949e;
  font-size: 0.8rem;
  margin-top: 2px;
}

/* ===== Add Form (Selected Show) ===== */
.add-form {
  max-width: 600px;
  margin: 20px auto 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 20px;
}

.add-form.hidden {
  display: none;
}

.selected-show {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.selected-poster {
  width: 100px;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  background: #30363d;
}

.selected-info {
  flex: 1;
}

.selected-info h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.year {
  color: #8b949e;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

/* ===== Genre Tags ===== */
.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.genre-tag {
  background: #21262d;
  color: #79c0ff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ===== Streaming Badges ===== */
.streaming-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.streaming-badge {
  background: #1a3a1a;
  color: #7ee787;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ===== Recommendation Form ===== */
.rec-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rec-form input {
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #0d1117;
  color: #e6edf3;
  outline: none;
  font-family: inherit;
}

.rec-form input:focus {
  border-color: #f97316;
}

.rec-form input::placeholder {
  color: #6e7681;
}

.btn-primary {
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* ===== Recommendations Section ===== */
.rec-section {
  margin-top: 10px;
}

.section-title {
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: #e6edf3;
}

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

.empty-state {
  color: #6e7681;
  text-align: center;
  padding: 40px;
  grid-column: 1 / -1;
}

/* ===== Recommendation Card ===== */
.rec-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.rec-card:hover {
  transform: translateY(-4px);
  border-color: #f97316;
}

.rec-card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: #30363d;
  display: block;
}

.rec-card-body {
  padding: 12px;
}

.rec-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-card-by {
  color: #f97316;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.rec-card-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.rec-card-genres .genre-tag {
  font-size: 0.68rem;
  padding: 2px 8px;
}

/* ===== Detail Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
}

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

.modal-body {
  padding: 24px;
}

.modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.modal-poster {
  width: 150px;
  height: 225px;
  object-fit: cover;
  border-radius: 10px;
  background: #30363d;
  flex-shrink: 0;
}

.modal-info {
  flex: 1;
}

.modal-info h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.modal-rec {
  margin-top: 14px;
}

.rec-by {
  color: #8b949e;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.rec-by strong {
  color: #f97316;
}

/* ===== Similar Shows ===== */
.similar-section h3 {
  font-size: 1.15rem;
  margin-bottom: 14px;
  color: #e6edf3;
}

.similar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.similar-card {
  cursor: pointer;
  transition: transform 0.2s;
}

.similar-card:hover {
  transform: scale(1.05);
}

.similar-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 8px;
  background: #30363d;
  display: block;
}

.similar-card-title {
  font-size: 0.78rem;
  margin-top: 6px;
  text-align: center;
  color: #c9d1d9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Shortcuts Guide ===== */
.shortcuts-section {
  margin-top: 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.shortcuts-guide {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  overflow: hidden;
}

.shortcuts-summary {
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #8b949e;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shortcuts-summary::-webkit-details-marker {
  display: none;
}

.shortcuts-summary::before {
  content: '\25B6';
  font-size: 0.7rem;
  transition: transform 0.2s;
}

details[open] > .shortcuts-summary::before {
  transform: rotate(90deg);
}

.shortcuts-summary:hover {
  color: #e6edf3;
}

.shortcuts-body {
  padding: 0 20px 20px;
  color: #c9d1d9;
  font-size: 0.9rem;
  line-height: 1.6;
}

.shortcuts-body h3 {
  font-size: 1rem;
  color: #e6edf3;
  margin: 16px 0 8px;
}

.shortcuts-body h3:first-child {
  margin-top: 0;
}

.shortcuts-body p {
  margin-bottom: 8px;
}

.shortcuts-body ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.shortcuts-body li {
  margin-bottom: 6px;
}

.shortcuts-code {
  display: block;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.8rem;
  color: #79c0ff;
  word-break: break-all;
  margin: 6px 0 10px;
}

/* ===== Recommender Profiles ===== */
.profiles-section {
  margin-top: 50px;
}

.profiles-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.profile-card {
  display: flex;
  gap: 20px;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 24px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-body {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #e6edf3;
  margin-bottom: 4px;
}

.profile-stats {
  font-size: 0.78rem;
  color: #8b949e;
  margin-bottom: 12px;
  font-weight: 500;
}

.profile-roast {
  font-size: 0.9rem;
  color: #c9d1d9;
  line-height: 1.7;
}

.profile-roast em {
  color: #f97316;
  font-style: italic;
}

.profiles-subtitle {
  color: #8b949e;
  font-size: 0.9rem;
  margin-top: -12px;
  margin-bottom: 24px;
}

.profile-meta {
  font-size: 0.75rem;
  color: #6e7681;
  margin-top: 12px;
}

.back-link {
  display: inline-block;
  color: #8b949e;
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 20px;
  transition: color 0.2s;
}

.back-link:hover {
  color: #f97316;
}

.profiles-link-banner {
  display: block;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
}

.profiles-link-banner:hover {
  border-color: #f97316;
  transform: translateY(-2px);
}

.profiles-link-banner .section-title {
  margin-bottom: 8px;
}

.profiles-link-banner p {
  color: #8b949e;
  font-size: 0.9rem;
}

.profiles-error {
  text-align: center;
  padding: 24px;
}

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

.profiles-error p {
  color: #8b949e;
  margin-bottom: 12px;
}

.profiles-error .btn-primary {
  padding: 10px 24px;
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .profile-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid #30363d;
  border-radius: 20px;
  background: #161b22;
  color: #8b949e;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-family: inherit;
}

.tab-btn:hover {
  color: #e6edf3;
  border-color: #8b949e;
}

.tab-btn.active {
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  border-color: transparent;
}

.tab-link {
  margin-left: auto;
  text-decoration: none;
}

/* ===== Vote Row ===== */
.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.vote-buttons {
  display: flex;
  gap: 6px;
}

.vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  border: 1px solid #30363d;
  border-radius: 16px;
  background: #0d1117;
  color: #8b949e;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.vote-btn:hover {
  border-color: #8b949e;
  color: #e6edf3;
}

.vote-btn.voted {
  background: #1a3a1a;
  border-color: #7ee787;
  color: #7ee787;
  cursor: default;
}

.modal-vote-row {
  justify-content: flex-start;
  gap: 8px;
  margin-top: 10px;
}

/* ===== Delete Button ===== */
.rec-card-delete {
  background: none;
  border: none;
  color: #6e7681;
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 8px;
  padding: 2px 0;
}

.rec-card-delete:hover {
  color: #f85149;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 20px;
  color: #484f58;
  font-size: 0.85rem;
  border-top: 1px solid #21262d;
}

/* ===== Loading Spinner ===== */
.spinner {
  text-align: center;
  padding: 20px;
  color: #8b949e;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .logo {
    font-size: 1.8rem;
  }

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

  .modal-poster {
    width: 120px;
    height: 180px;
  }

  .selected-show {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .genre-tags,
  .streaming-badges {
    justify-content: center;
  }

  .rec-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
}
