/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --c-dark:    #3b3f45;
  --c-text:    #2d2d2d;
  --c-muted:   #8a8a8a;
  --c-bg:      #f4f4f0;
  --c-surface: #fafaf8;
  --c-border:  #ddd;
  --c-white:   #fff;
  --radius:    8px;
  --shadow:    0 2px 16px rgba(0, 0, 0, 0.08);
  --max-w:     1060px;
  --pad:       2rem 2.5rem;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

/* ── Loading overlay ────────────────────────────────────────── */
#loadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 244, 240, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 999;
}

#loadingOverlay[hidden] { display: none !important; }

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #ddd;
  border-top-color: var(--c-dark);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--c-muted);
  font-weight: 500;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page ───────────────────────────────────────────────────── */
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  gap: 2rem;
}

/* ── Shared card shell ──────────────────────────────────────── */
.container,
.movie-detail {
  width: 100%;
  max-width: var(--max-w);
  background: var(--c-white);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* ════════════════════════════════════════════════════════════ */
/*  REGISTRATION                                               */
/* ════════════════════════════════════════════════════════════ */

.container { overflow: hidden; }

header {
  background: var(--c-dark);
  color: #f0ede8;
  padding: var(--pad);
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

header p {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: #b0acaa;
}

form {
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

/* Fields */
.field-group {
  display: flex;
  gap: 0.45rem;
  justify-content: space-between;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field > label,
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b6b6b;
  display: block;
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--c-border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

input::placeholder { color: #bbb; }

input:focus,
select:focus {
  outline: none;
  border-color: #7a8a99;
  box-shadow: 0 0 0 3px rgba(122, 138, 153, 0.15);
  background: var(--c-white);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b6b6b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

/* Radio */
.radio-group {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  padding: 0.6rem 0;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--c-dark);
  width: 16px;
  height: 16px;
}

/* Buttons */
.btn {
  padding: 0.65rem 1.1rem;
  background: var(--c-dark);
  color: #f0ede8;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.18s;
}

.btn:hover         { background: #2d3035; }
.btn:active        { background: #22262a; }
.btn:disabled      { background: #7a8a99; cursor: default; }

button[type="submit"].btn,
.btn--full {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  flex-shrink: unset;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--c-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0 0 0 0.75rem;
  flex-shrink: 0;
  transition: color 0.18s;
}

.btn-ghost:hover { color: var(--c-dark); }

/* Email step */
.email-row {
  display: flex;
  gap: 0.6rem;
}

.email-row input[type="email"] {
  flex: 1;
  min-width: 0;
}

.email-confirmed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.email-confirmed span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* User plain-text view */
.user-view {
  display: grid;
  grid-template-columns: 2fr repeat(5, 1fr);
  gap: 0.7rem 1rem;
}

/* Success */
.success-msg {
  margin: 0 2.5rem 2rem;
  padding: 0.75rem 1rem;
  background: #edf5ee;
  border-left: 4px solid #5a9467;
  border-radius: 4px;
  color: #3a6b44;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ════════════════════════════════════════════════════════════ */
/*  USER STATS                                                 */
/* ════════════════════════════════════════════════════════════ */

.user-stats-section {
  width: 100%;
  max-width: var(--max-w);
  background: var(--c-white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.8rem 2.5rem;
}

.stats-body {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-top: 1.4rem;
}

.stats-col-left {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  flex-shrink: 0;
  width: 260px;
}

.stats-col-right {
  flex: 1;
  min-width: 0;
}

.stats-summary {
  display: flex;
  gap: 0.8rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--c-bg);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  flex: 1;
  gap: 0.2rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--c-dark);
  line-height: 1;
}

.stat-global {
  font-size: 0.68rem;
  color: var(--c-muted);
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--c-border);
  width: 100%;
  text-align: center;
}

.stat-global strong {
  color: var(--c-dark);
}

.stats-genres {
  width: 100%;
  padding-top: 1rem;
  border-top: 1px solid #f0ede8;
}

.stats-genres:first-child { padding-top: 0; border-top: none; }

.genre-avg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  font-size: 0.82rem;
}

.genre-avg-item { white-space: nowrap; }

.genre-count {
  font-size: 0.72rem;
  color: var(--c-muted);
}

.genre-sep {
  color: var(--c-border);
  font-size: 0.75rem;
}

.stats-histogram { width: 100%; }

.hist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.28rem;
}

.hist-label {
  font-size: 0.72rem;
  color: var(--c-muted);
  width: 2rem;
  text-align: right;
  flex-shrink: 0;
}

.hist-track {
  flex: 1;
  height: 10px;
  background: #efefec;
  border-radius: 4px;
  overflow: hidden;
}

.hist-bar {
  height: 100%;
  background: var(--c-dark);
  border-radius: 4px;
  transition: width 0.3s ease;
  min-width: 2px;
}

.hist-count {
  font-size: 0.68rem;
  color: var(--c-muted);
  width: 2rem;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════ */
/*  USER RATINGS TABLE                                         */
/* ════════════════════════════════════════════════════════════ */

.user-ratings-section {
  width: 100%;
  max-width: var(--max-w);
  background: var(--c-white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 2rem 2.5rem 2.5rem;
}

.ratings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ratings-table thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-muted);
  padding: 0 0.75rem 0.6rem;
  border-bottom: 1.5px solid var(--c-border);
}

.ratings-table tbody tr {
  border-bottom: 1px solid #f0ede8;
  transition: background 0.12s;
}

.ratings-table tbody tr:hover { background: var(--c-bg); cursor: pointer; }

.ratings-table tbody td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
}

.chip-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.rating-cell {
  font-weight: 700;
  color: var(--c-dark);
  white-space: nowrap;
}

.ratings-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.2rem;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--c-muted);
}

.btn--sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
}

/* ════════════════════════════════════════════════════════════ */
/*  BUTTON VARIANTS                                            */
/* ════════════════════════════════════════════════════════════ */

.btn--outline {
  background: none;
  border: 1.5px solid var(--c-dark);
  color: var(--c-dark);
}
.btn--outline:hover { background: var(--c-bg); }

.btn--accent            { background: #5a9467; }
.btn--accent:hover      { background: #4a7f57; }
.btn--accent:active     { background: #3a6b44; }
.btn--accent:disabled   { background: #7a8a99; }

/* ════════════════════════════════════════════════════════════ */
/*  MAIN TABS                                                  */
/* ════════════════════════════════════════════════════════════ */

.main-tabs {
  width: 100%;
  max-width: var(--max-w);
  background: var(--c-white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tab-bar {
  display: flex;
  background: var(--c-bg);
  border-bottom: 1.5px solid var(--c-border);
}

.tab-btn {
  padding: 0.85rem 1.6rem;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tab-btn:hover { color: var(--c-dark); }

.tab-btn.active {
  color: var(--c-dark);
  border-bottom-color: var(--c-dark);
  background: var(--c-white);
}

/* ── Tab panel sections (no standalone card) ──────────────── */

.tab-section {
  padding: 1.8rem 2.5rem;
  border-bottom: 1.5px solid #f0ede8;
}

.tab-section:last-child { border-bottom: none; }

/* Override the standalone card that .user-stats-section etc. apply */
.tab-panel .user-stats-section,
.tab-panel .user-ratings-section {
  width: auto;
  max-width: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.tab-panel .movie-detail {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border-top: 1.5px solid #f0ede8;
}

/* ── New Ratings tab ──────────────────────────────────────── */

.save-ratings-bar {
  padding: 0.8rem 2.5rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: flex-start;
}

.save-ratings-bar .btn--accent { align-self: flex-end; }

.save-ratings-msg {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

.save-ratings-msg--success {
  background: #edf5ee;
  border-left: 4px solid #5a9467;
  color: #3a6b44;
}

.save-ratings-msg--warn {
  background: #fefce8;
  border-left: 4px solid #ca8a04;
  color: #854d0e;
}

.save-ratings-msg--error {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  color: #991b1b;
}

/* ── Recommender tab ──────────────────────────────────────── */

.recommender-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.recommender-controls {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.recommender-field {
  min-width: 220px;
  max-width: 320px;
  flex: 1;
}

.rec-results {
  font-size: 0.9rem;
  color: var(--c-muted);
}

.rec-loading, .rec-empty {
  padding: 1.5rem 0;
  color: var(--c-muted);
}

.rec-rank-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: var(--c-dark);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.movie-card { position: relative; }

.rec-score {
  font-size: 0.72rem;
  color: var(--c-muted);
  margin-top: 0.2rem;
}

/* ════════════════════════════════════════════════════════════ */
/*  MOVIES GRID                                                */
/* ════════════════════════════════════════════════════════════ */

.movies-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--c-dark);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-toggle {
  margin-left: auto;
  background: none;
  border: 1.5px solid var(--c-border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.section-toggle:hover { border-color: var(--c-dark); color: var(--c-dark); }

.movie-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad);
  padding-bottom: 0;
}

.movie-detail-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  padding: var(--pad);
  padding-top: 1.2rem;
}

.movies-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.1rem;
}

.movie-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--c-surface);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s, box-shadow 0.15s;
}

.movie-card:hover  { transform: translateY(-3px); box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.movie-card.active { box-shadow: 0 0 0 2.5px var(--c-dark), 0 4px 14px rgba(0,0,0,0.15); }

.movie-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: #e0ddd8;
}

.movie-info {
  padding: 0.6rem 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.movie-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  cursor: pointer;
}

.movie-title:hover { text-decoration: underline; color: var(--c-dark); }

.movie-year {
  font-size: 0.72rem;
  color: var(--c-muted);
}

/* Stars */
.star-rating {
  display: flex;
  gap: 1px;
  margin-top: auto;
  padding-top: 0.4rem;
}

.star-wrap {
  position: relative;
  display: inline-block;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}

.star-bg { display: block; color: #d8d5cf; }

.star-fg {
  position: absolute;
  top: 0; left: 0;
  display: block;
  color: #f5a623;
  overflow: hidden;
  white-space: nowrap;
  width: 0%;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════ */
/*  MOVIE DETAIL                                               */
/* ════════════════════════════════════════════════════════════ */

.movie-detail {
  padding: 0;
}

.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex-shrink: 0;
  width: 200px;
}

.detail-poster {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  object-fit: cover;
  display: block;
}

.detail-ratings {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.detail-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  font-size: 0.88rem;
}

.detail-title {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
}

.rating-badge {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--c-bg);
  border: 1.5px solid #e8e5e0;
  border-radius: 7px;
  padding: 0.4rem 0.7rem;
  width: 100%;
}

.rating-badge.rb-ml   { border-color: #f06624; background: #f7eee3; }
.rating-badge.rb-imdb { border-color: #e8c30b; background: #fffbea; }
.rating-badge.rb-rt   { border-color: #fa320a; background: #fff1ee; }
.rating-badge.rb-mc   { border-color: #6cc000; background: #f4ffea; }

.rb-source {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  white-space: nowrap;
}

.rb-score {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.rb-votes {
  font-size: 0.6rem;
  color: #aaa;
}

/* Metadata grid */
.detail-meta {
  display: flex;
  gap: 2.5rem;
}

.detail-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-muted);
}


/* People (directors / writers) */
.detail-people {
  display: flex;
  gap: 2.5rem;
  padding-top: 0.8rem;
  border-top: 1px solid #ebebeb;
}

.people-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.person-line { line-height: 1.65; }

.person-line-name { font-weight: 600; }

/* Genres & Tags */
.detail-genres-tags {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-top: 0.8rem;
  border-top: 1px solid #ebebeb;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.chip {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
}

.chip--genre {
  background: #eef1f5;
  color: #3b3f45;
}

.chip--tag {
  background: var(--c-bg);
  color: var(--c-muted);
  border: 1px solid #e0ddd8;
}

/* ════════════════════════════════════════════════════════════ */
/*  USER SIMILARITY TAB                                        */
/* ════════════════════════════════════════════════════════════ */

.sim-selector-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 2.5rem;
  border-bottom: 1.5px solid #f0ede8;
  flex-wrap: wrap;
}

.sim-badge {
  display: inline-flex;
  align-items: center;
  background: #eef1f5;
  color: var(--c-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  white-space: nowrap;
}

.sim-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.sim-col {
  border-right: 1.5px solid #f0ede8;
  min-width: 0;
}

.sim-col:last-child { border-right: none; }

.sim-col-heading {
  padding: 1rem 2.5rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  border-bottom: 2px solid var(--c-dark);
}

.sim-col .stats-body {
  flex-direction: column;
  gap: 1.2rem;
}

.sim-col .stats-col-left {
  width: 100%;
}

.sim-col .stats-summary {
  flex-wrap: wrap;
}

/* Sinopse */
.detail-plot {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.8rem;
  border-top: 1px solid #ebebeb;
}

.detail-plot p {
  color: #3a3a3a;
  line-height: 1.65;
}
