/* Musikbanken — design tokens carried over from the old frontend
   (frontend/colors.scss + component styles). */
:root {
  --red: #ff3943;
  --red-light: #ff555d;
  --grey: #616b71;
  --lightgrey: #eceef1;
  --hover: #f5f6f7;
  --black: #333333;
  --green: #00aa79;
  --border-subtle: #e8ebed;
  --placeholder: #8396a0;

  --radius-btn: 10px;
  --radius-row: 13px;
  --radius-card: 20px;

  --header-height: 100px;
  --player-height: 90px;
  --content-max: 620px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Nimbus Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--black);
  background: #fff;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-y: scroll;
}

a { color: var(--red-light); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 {
  font-size: 42px;
  font-weight: 600;
  margin: 0 0 6px;
}

img { max-width: 100%; }

button { font: inherit; color: inherit; }

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: stretch;
  height: var(--header-height);
  border-bottom: 1px solid var(--lightgrey);
}

.header-logo {
  flex: 0 0 325px;
  display: flex;
  align-items: center;
  padding: 0 40px;
}

.header-nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0 22px;
  font-size: 18px;
  color: var(--black);
  border-top: 4px solid transparent;
}

.nav-item:hover { text-decoration: none; background: var(--hover); }
.nav-item.active { border-top-color: var(--red); font-weight: 500; }

.header-user {
  flex: 0 0 325px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 40px;
}

.user-menu summary {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.user-menu summary:hover { background: var(--hover); }

.user-name { font-weight: 600; padding: 8px 16px 0; }
.user-org { color: var(--grey); font-size: 13px; padding: 0 16px 8px; }

/* ---------- Content column ---------- */

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 30px 16px calc(var(--player-height) + 30px);
}

.page-head { margin-bottom: 20px; }
.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.page-description { color: var(--grey); margin: 0; }

/* ---------- Flash ---------- */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-success { background: #e6f7f1; color: var(--green); }
.flash-info { background: var(--hover); color: var(--grey); }
.flash-error { background: #ffecec; color: var(--red); }

/* ---------- Forms & buttons ---------- */

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
textarea,
select {
  font: inherit;
  color: var(--black);
  border: 1px solid var(--lightgrey);
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  background: #fff;
  width: 100%;
}

input::placeholder, textarea::placeholder { color: var(--placeholder); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--grey);
}

.btn {
  display: inline-block;
  border: 1px solid var(--lightgrey);
  background: #fff;
  color: var(--black);
  border-radius: var(--radius-btn);
  padding: 6px 18px;
  height: 42px;
  line-height: 28px;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--hover); text-decoration: none; }

.btn-filled {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn-filled:hover { background: var(--red-light); }

.btn-large { height: 56px; width: 100%; line-height: 42px; font-size: 18px; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

/* ---------- Search ---------- */

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.search-form > img {
  position: absolute;
  left: 14px;
  opacity: 0.5;
}
.search-form input {
  padding-left: 42px;
  height: 48px;
}
.search-clear {
  position: absolute;
  right: 14px;
  display: flex;
  padding: 6px;
}

/* ---------- List controls ---------- */

.list-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.control-forms { display: flex; gap: 12px; flex: 1 1 auto; }
.control { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--grey); }
.control select { width: auto; min-width: 140px; height: 42px; padding: 6px 10px; }

.request-track {
  color: var(--red-light);
  height: 42px;
  display: inline-flex;
  align-items: center;
  font: inherit;
  transition: color 120ms ease;
}
.request-track:hover { color: var(--red); text-decoration: underline; }

/* ---------- Modal (native <dialog>) ---------- */

.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  overflow: visible;
}
.modal::backdrop {
  background: rgba(51, 51, 51, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal[open] { animation: modal-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal[open]::backdrop { animation: backdrop-in 180ms ease; }
.modal-card {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 32px 28px 28px;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--grey);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}
.modal-close:hover { background: var(--hover); color: var(--black); }
.modal-close:active { transform: scale(0.92); }
.modal-close:focus-visible { outline: none; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--red); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.modal-actions .btn { min-width: 120px; }

.modal .request-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0;
  max-width: none;
}
.request-head { display: flex; flex-direction: column; gap: 6px; padding-right: 32px; }
.request-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}
.request-head p {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--grey);
}
.request-form textarea {
  resize: vertical;
  min-height: 112px;
  padding: 12px 14px;
  line-height: 1.45;
}
.btn-block { width: 100%; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (max-width: 520px) {
  .modal-card { padding: 28px 20px 20px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* ---------- Dropdowns (details-based) ---------- */

details.dropdown { position: relative; }
details.dropdown > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
details.dropdown > summary::-webkit-details-marker { display: none; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--lightgrey);
  border-radius: var(--radius-row);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dropdown-right { left: auto; right: 0; }

.dropdown-heading {
  font-size: 13px;
  color: var(--grey);
  padding: 6px 10px 2px;
}
.dropdown-empty { color: var(--grey); font-size: 14px; padding: 8px 10px; }

.dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--black);
}
.dropdown-link:hover { background: var(--hover); text-decoration: none; }
.dropdown-link.danger { color: var(--red); }

.dropdown-menu form { display: contents; }
.dropdown-menu .edit-form,
.dropdown-menu textarea,
.create-playlist .dropdown-menu form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px;
}
.dropdown-menu textarea { padding: 10px 12px; }

.dropdown-sub summary.dropdown-link { list-style: none; }
.dropdown-sub summary.dropdown-link::-webkit-details-marker { display: none; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.check-row input { width: auto; }

.create-playlist summary span { color: var(--red-light); }
.create-playlist .dropdown-menu { right: 0; left: auto; min-width: 280px; }

/* ---------- Track rows ---------- */

.track-list, .row-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 0;
  border-radius: var(--radius-row);
}
.track-row:hover { background: var(--hover); }
.track-row.playing { box-shadow: 0 0 10px var(--lightgrey); }

.track-play {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 12px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

.track-number { color: var(--grey); min-width: 22px; }

.track-duration {
  color: var(--grey);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
}
.track-row.playing .track-duration { display: none; }

.track-text { display: flex; flex-direction: column; min-width: 0; }
.track-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-artist {
  color: var(--grey);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-add { margin-right: 10px; }
.track-add > summary { padding: 8px; border-radius: 50%; }
.track-add > summary:hover { background: var(--lightgrey); }

/* Signal: 4-bar equalizer shown on the playing row. */
.track-signal {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 18px;
  min-width: 44px;
}
.track-row.playing .track-signal { display: inline-flex; }
.track-signal span {
  width: 4px;
  background: var(--red);
  border-radius: 2px;
  animation: signal 1s ease-in-out infinite;
}
.track-signal span:nth-child(1) { animation-delay: 0s; }
.track-signal span:nth-child(2) { animation-delay: 0.25s; }
.track-signal span:nth-child(3) { animation-delay: 0.5s; }
.track-signal span:nth-child(4) { animation-delay: 0.12s; }

@keyframes signal {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

/* ---------- Row lists (playlists, toplists) ---------- */

.row-list li { margin: 0; }

.row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 12px;
  border-radius: var(--radius-row);
  color: var(--black);
}
.row-link:hover { background: var(--hover); text-decoration: none; }

.row-text { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 500; }
.row-sub { color: var(--grey); font-size: 14px; }
.row-chevron { flex: 0 0 auto; }

.badge {
  display: inline-block;
  background: var(--lightgrey);
  color: var(--grey);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-radius: 4px;
  padding: 2px 6px;
  vertical-align: middle;
}

/* ---------- Empty view / load more ---------- */

.empty-view {
  text-align: center;
  color: var(--grey);
  padding: 40px 0;
}
.empty-hint { font-size: 14px; }
.request-form {
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.load-more { text-align: center; padding: 20px 0; }

/* ---------- Player ---------- */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--player-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  border-top: 4px solid var(--lightgrey);
  z-index: 40;
}

.player-progress {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 4px;
  cursor: pointer;
}
.player-progress::before {
  content: "";
  position: absolute;
  inset: -6px 0;
}
.player-progress-fill {
  height: 100%;
  width: 0;
  background: var(--red);
}

.player-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
  padding: 0 80px;
}

.player-track {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.player-track-text { min-width: 0; }
.player-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-artist {
  color: var(--grey);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls { display: flex; align-items: center; gap: 12px; }

.player-btn {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
  color: var(--placeholder);
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.player-btn svg { display: block; }
.player-btn[hidden],
.player-btn [hidden] { display: none !important; }
.player-btn:focus { outline: none; }
.player-btn:focus-visible {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--red);
}

.player-skip {
  width: 40px;
  height: 40px;
}
.player-skip:hover {
  background: var(--hover);
  color: var(--black);
}
.player-skip:active {
  transform: scale(0.92);
  background: var(--lightgrey);
}

.player-toggle {
  width: 52px;
  height: 52px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 4px 12px rgba(255, 57, 67, 0.32);
}
.player-toggle:hover {
  background: var(--red-light);
  box-shadow: 0 6px 16px rgba(255, 57, 67, 0.4);
  transform: translateY(-1px);
}
.player-toggle:active {
  transform: scale(0.94);
  box-shadow: 0 2px 6px rgba(255, 57, 67, 0.3);
}
.player-icon {
  animation: player-icon-in 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* Optically center the play triangle (it is visually left-heavy). */
.player-icon-play { margin-left: 3px; }
@keyframes player-icon-in {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}
.player.is-playing .player-icon-play { display: none; }
@media (prefers-reduced-motion: reduce) {
  .player-btn { transition: none; }
  .player-icon { animation: none; }
}

.player-time {
  flex: 1 1 0;
  text-align: right;
  color: var(--grey);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Auth pages ---------- */

.auth { min-height: 100%; }

.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url("/static/login.jpg") center / cover no-repeat;
  padding: 20px;
}

.auth-card {
  width: 515px;
  max-width: 100%;
  background: #fff;
  border-radius: var(--radius-card);
  padding: 20px 50px 50px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.auth-logo { margin: 20px 0 10px; }

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--grey);
}

.auth-link { font-size: 14px; }

.form-error {
  width: 100%;
  background: #ffecec;
  color: var(--red);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  font-size: 14px;
}
.form-success {
  width: 100%;
  background: #e6f7f1;
  color: var(--green);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  font-size: 14px;
}

.auth .flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {
  h1 { font-size: 38px; }

  .header {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 0 0;
  }
  .header-logo {
    flex: 1 1 auto;
    padding: 0 16px 10px;
  }
  .header-logo img { width: 120px; }
  .header-user {
    flex: 0 0 auto;
    padding: 0 16px 10px;
  }
  .header-nav {
    flex: 1 1 100%;
    order: 3;
    justify-content: stretch;
  }
  .nav-item {
    flex: 1 1 0;
    justify-content: center;
    font-size: 14px;
    padding: 12px 4px;
    border-top: none;
    border-bottom: 4px solid var(--lightgrey);
  }
  .nav-item.active { border-bottom-color: var(--red); }

  .content { padding-top: 20px; }

  .player-inner { padding: 0 20px; gap: 10px; }
  .player-time { display: none; }

  .auth-card { padding: 20px 24px 32px; }
}
