/* PlayStream - spelaren */
:root {
  --bg: #12151c;
  --panel: #1b202a;
  --panel2: #232a36;
  --text: #e8ecf2;
  --muted: #8b95a7;
  --accent: #2fbf71;
  --accent2: #1f8f53;
  --warn: #e0a030;
  --danger: #e04848;
  --sel: #2b4a7a;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overscroll-behavior: none;
}

#ps-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  #ps-app {
    grid-template-columns: 420px 1fr;
    grid-template-areas:
      "top top"
      "select list"
      "player list";
  }
  .ps-top { grid-area: top; }
  .ps-select { grid-area: select; }
  .ps-player { grid-area: player; }
  .ps-listpanel { grid-area: list; }
}

.ps-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.ps-brand { font-weight: 700; letter-spacing: .5px; color: var(--accent); }
.ps-clock {
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 10px;
}
.ps-clock-sep { font-size: .35em; color: var(--muted); margin-right: 18px; }
.ps-status { color: var(--muted); font-size: 14px; width: 100%; }

.ps-panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px;
}

.ps-select { display: grid; gap: 12px; }
.ps-field { display: grid; gap: 6px; }
.ps-field > span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

select {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #333c4b;
  border-radius: 8px;
  font-size: 18px;
  padding: 10px;
}

.ps-stepper { display: flex; align-items: center; gap: 6px; }
.ps-value {
  min-width: 70px; text-align: center;
  font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.ps-narrow { min-width: 44px; }

.ps-btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #333c4b;
  border-radius: 10px;
  font-size: 18px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ps-btn:hover { border-color: #4a566b; }
.ps-btn:active { transform: translateY(1px); background: #2c3443; }
.ps-small { min-width: 52px; }
.ps-wide { width: 100%; }
.ps-primary { background: var(--accent2); border-color: var(--accent); font-weight: 600; }
.ps-primary:hover { background: var(--accent); }

.ps-now {
  font-size: 20px; font-weight: 600; min-height: 1.4em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ps-prog {
  height: 22px; background: var(--panel2); border-radius: 11px;
  overflow: hidden; margin-top: 10px; cursor: pointer;
}
.ps-prog-bar { height: 100%; width: 0%; background: var(--accent); transition: width .25s linear; }
.ps-prog-bar.warn { background: linear-gradient(90deg, var(--accent), var(--danger)); }
.ps-prog-bar.end  { background: var(--danger); }
.ps-times {
  display: flex; justify-content: space-between;
  font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 6px;
}
#timeLeft { font-weight: 700; }

.ps-controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.ps-ctrl { font-size: 22px; padding: 16px 0; }
.ps-play { background: var(--accent2); border-color: var(--accent); font-weight: 700; }
.ps-play.playing { background: var(--warn); border-color: var(--warn); color: #1a1a1a; }

.ps-volume { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }
.ps-volume input { flex: 1; }

.ps-listpanel { display: flex; flex-direction: column; min-height: 300px; }
.ps-listhead { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.ps-list {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto; max-height: 70vh;
}
.ps-list li {
  display: grid; grid-template-columns: 30px 40px 1fr auto;
  gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  border-bottom: 1px solid #222835;
}
.ps-list li:hover { background: var(--panel2); }
.ps-list li.sel { background: var(--sel); }
.ps-list li.playing { background: var(--accent2); }
.ps-list .s { color: var(--accent); font-weight: 700; text-align: center; white-space: nowrap; }
.ps-list li.playing .s { color: #fff; }
.ps-list .t { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.ps-list li.playing .t, .ps-list li.sel .t { color: var(--text); }
.ps-list .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-list .a { color: var(--muted); }
.ps-list li.playing .a, .ps-list li.sel .a { color: #cfd6e2; }
.ps-list .nr { color: var(--muted); font-size: 13px; }

.ps-code { color: var(--muted); font-size: 15px; }
.ps-code b {
  color: var(--text); font-size: 22px; letter-spacing: 3px;
  background: var(--panel2); padding: 4px 10px; border-radius: 8px; margin-left: 6px;
}

.ps-code.linked b { background: var(--accent2); }
.ps-toast {
  position: fixed; left: 50%; top: 24px; transform: translate(-50%, -150%);
  background: var(--accent2); color: #fff; border: 1px solid var(--accent);
  font-size: 22px; font-weight: 700; padding: 16px 28px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  transition: transform .35s ease; z-index: 1000; pointer-events: none;
}
.ps-toast.show { transform: translate(-50%, 0); }

.ps-code { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ps-rstate { font-size: 14px; color: var(--muted); }
.ps-code.linked .ps-rstate { color: var(--accent); font-weight: 600; }
.ps-swap { font-size: 14px; padding: 6px 10px; }

.ps-hidden { display: none !important; }
.ps-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(10, 12, 18, .94);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.ps-overlay-box { text-align: center; display: grid; gap: 14px; padding: 24px; }
.ps-big-brand { font-size: 40px; }
.ps-ov-label { color: var(--muted); text-transform: uppercase; letter-spacing: 2px; }
.ps-ov-code { font-size: clamp(64px, 16vw, 140px); font-weight: 800; letter-spacing: 12px; font-variant-numeric: tabular-nums; }
.ps-ov-btn { font-size: 26px; padding: 20px 32px; }
.ps-ov-hint { color: var(--muted); font-size: 15px; line-height: 1.5; }

.ps-approve { z-index: 950; cursor: default; }
.ps-ov-icon { font-size: 64px; }
.ps-ov-title { font-size: 30px; font-weight: 700; }
.ps-ov-buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.ps-deny { font-size: 26px; padding: 20px 32px; background: #5a2323; border-color: var(--danger); }

/* Startsida: två val */
.ps-choice { z-index: 960; cursor: default; }
.ps-listmode { z-index: 955; cursor: default; }
.ps-choice-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 10px; max-width: 760px; }
.ps-choice-btn { display: grid; gap: 8px; padding: 28px 22px; text-align: center; }
.ps-choice-icon { font-size: 44px; }
.ps-choice-title { font-size: 28px; font-weight: 700; }
.ps-choice-sub { font-size: 15px; color: #cfd6e2; font-weight: 400; }

/* ---------- Listläget ---------- */
.ps-listmode {
  position: fixed; inset: 0; z-index: 955; overflow-y: auto;
  background: var(--bg); padding: 12px 16px 24px; box-sizing: border-box;
}
.lb-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; max-width: 1300px; margin: 0 auto 12px; }
.lb-title { font-size: 26px; font-weight: 700; }
.lb-free { color: var(--accent); font-size: 14px; }
.lb-grid { display: grid; grid-template-columns: 1fr; gap: 12px; max-width: 1300px; margin: 0 auto; }
@media (min-width: 1000px) { .lb-grid { grid-template-columns: 1fr 1fr; } }
.lb-col { display: flex; flex-direction: column; gap: 10px; min-height: 60vh; }
.lb-search { display: grid; gap: 8px; }
.lb-tempo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lb-listhead { display: flex; gap: 8px; }
.lb-listhead .lb-input { flex: 1; min-width: 0; }
.lb-input {
  background: var(--panel2); color: var(--text); border: 1px solid #333c4b;
  border-radius: 8px; font-size: 17px; padding: 10px; box-sizing: border-box; width: 100%;
}
.lb-sub { color: var(--muted); font-size: 14px; min-height: 1.2em; }
.lb-msg { color: var(--warn); margin-left: 8px; }
.lb-rows { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 62vh; }
.lb-rows li {
  display: grid; grid-template-columns: auto 34px 36px 1fr auto; gap: 8px; align-items: center;
  padding: 6px 4px; border-bottom: 1px solid #222835;
}
#lbList li { grid-template-columns: 28px auto 34px 36px 1fr auto; }
.lb-rows li.lb-playing { background: #1f3a2a; }
.lb-t { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.lb-s { color: var(--accent); font-weight: 700; text-align: center; white-space: nowrap; }
.lb-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-a { color: var(--muted); }
.lb-nr { color: var(--muted); font-size: 13px; text-align: right; }
.lb-ic { font-size: 15px; padding: 6px 10px; min-width: 38px; }
.lb-add { background: var(--accent2); border-color: var(--accent); font-weight: 700; }
.lb-del { background: #4a2020; border-color: #7a3030; }
.lb-move { display: flex; gap: 4px; }

/* ---------- Listläget: lägg alla, sortera, dra och släpp ---------- */
.lb-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lb-bar .lb-sub { flex: 1; }
.lb-bar .ps-btn { font-size: 15px; padding: 7px 12px; }
.lb-rows li[draggable="true"] { cursor: grab; }
.lb-rows li.lb-dragging { opacity: .4; }
.lb-rows li.lb-drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.lb-rows li.lb-drop-after  { box-shadow: inset 0 -3px 0 var(--accent); }
#lbList { min-height: 180px; }
#lbList.lb-drop-end { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 8px; }
#lbList li.lb-empty {
  display: block; color: var(--muted); text-align: center; line-height: 1.6;
  padding: 36px 12px; border: 2px dashed #333c4b; border-radius: 10px;
}

/* Logga (skivspelaren) framför namnet */
.ps-brand { display: inline-flex; align-items: center; gap: .35em; }
.ps-logo { height: 1.3em; width: 1.3em; flex: none; vertical-align: middle; }
.ps-big-brand .ps-logo { height: 1.5em; width: 1.5em; }
.lb-logo { height: 34px; width: 34px; }

/* Dator: båda listorna fyller ut fönstrets höjd */
@media (min-width: 1000px) {
  .lb-col { height: calc(100vh - 110px); min-height: 420px; }
  .lb-rows { flex: 1 1 0; min-height: 0; max-height: none; }
}

/* Admin: rätta stil och tempo */
.ps-admin {
  position: absolute; right: 16px; bottom: 16px; background: none; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer; opacity: .6;
}
.ps-admin:hover { opacity: 1; }
.ps-edit { font-size: 14px; padding: 3px 8px; margin-right: 8px; min-width: 0; }
.ps-edit-ov { z-index: 980; cursor: default; }
.ps-editbox { background: var(--panel); border-radius: 14px; padding: 24px 28px; min-width: min(420px, 92vw); }
.ps-ed-song { font-size: 18px; font-weight: 600; }
.ps-edgrid { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; text-align: left; }
.ps-edgrid label { color: var(--muted); }
.ps-edgrid select, .ps-edgrid input {
  background: var(--panel2); color: var(--text); border: 1px solid #333c4b;
  border-radius: 8px; font-size: 17px; padding: 8px 10px;
}
.ps-ed-msg { color: var(--warn); min-height: 1.2em; }
/* Beat i rättningsrutan */
.ps-ed-beat { display: grid; gap: 8px; }
.ps-ed-tap {
  background: var(--panel2); border: 1px solid #333c4b; border-radius: 10px;
  padding: 22px 12px; font-size: 22px; font-weight: 700; cursor: pointer; user-select: none;
  outline: none;
}
.ps-ed-tap:focus { border-color: var(--accent); }
.ps-ed-tap.counting { background: var(--accent2); color: #fff; }
.ps-ed-hist { color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.2em; }
/* Admin-inloggning */
.ps-login-in {
  background: var(--panel2); color: var(--text); border: 1px solid #333c4b;
  border-radius: 8px; font-size: 18px; padding: 10px 12px;
}
.ps-login-in[readonly] { color: var(--muted); font-size: 14px; }
/* Inloggning och användarraden på startsidan */
.ps-login { z-index: 990; cursor: default; }
.ps-login .ps-editbox { min-width: min(380px, 92vw); }
.ps-codebox { display: grid; gap: 8px; }
.ps-userline { color: var(--muted); font-size: 15px; margin-top: 6px; }
.ps-linkbtn { background: none; border: none; color: var(--accent); font-size: 15px; cursor: pointer; padding: 0; text-decoration: underline; }
.ps-choice-btn.ps-off { opacity: .35; cursor: not-allowed; }

/* ---------- Adminsidan ---------- */
.ps-admin-btn { margin-top: 14px; }
.ad-tabs { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.ad-tab.on { background: var(--accent2); border-color: var(--accent); }
.ad-body { max-width: 1300px; margin: 0 auto; display: grid; gap: 14px; padding-bottom: 40px; }
.ad-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ad-bar h2 { margin: 0; font-size: 22px; }
.ad-month { min-width: 180px; text-align: center; text-transform: capitalize; }
.ad-msg { color: var(--accent); flex: 1; }
.ad-msg.bad { color: var(--warn); }
.ad-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.ad-card { background: var(--panel); border-radius: 12px; padding: 14px 16px; color: var(--muted); }
.ad-big { font-size: 28px; font-weight: 700; color: var(--text); }
.ad-scroll { overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.ad-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid #333c4b; white-space: nowrap; }
.ad-table td { padding: 8px; border-bottom: 1px solid #222835; vertical-align: top; }
.ad-table .r { text-align: right; white-space: nowrap; }
.ad-row { cursor: pointer; }
.ad-row:hover { background: var(--panel2); }
.ad-sum td { font-weight: 700; border-top: 2px solid #333c4b; }
.ad-sub { color: var(--muted); font-size: 13px; }
.ad-hint { color: var(--muted); font-size: 14px; }
.ad-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #333c4b; color: var(--text); }
.ad-tag.ok { background: var(--accent2); }
.ad-tag.off { background: #7a3030; }
.ad-live { color: var(--accent); font-weight: 700; }
.ad-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.ad-sec { display: grid; gap: 10px; align-content: start; }
.ad-sec h3 { margin: 6px 0 0; font-size: 17px; }
.ad-wide { grid-column: 1 / -1; }
.ad-f { display: grid; gap: 4px; }
.ad-f span { color: var(--muted); font-size: 13px; }
.ad-f input, .ad-f textarea, .ad-pw input {
  background: var(--panel2); color: var(--text); border: 1px solid #333c4b; border-radius: 8px;
  font-size: 16px; padding: 8px 10px; font-family: inherit; min-width: 0;
}
.ad-chk { display: flex; gap: 8px; align-items: center; }
.ad-pw { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ad-pw span { color: var(--muted); min-width: 52px; }
.ad-pw b { min-width: 70px; }
.ad-pw input[type=password] { flex: 1; min-width: 160px; }
.ad-pw input[type=number] { width: 70px; }
.ad-code { font-size: 28px; font-weight: 800; letter-spacing: 3px; font-variant-numeric: tabular-nums; user-select: all; }
.ad-chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
.ad-day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.ad-col { width: 100%; background: var(--accent2); border-radius: 3px 3px 0 0; min-height: 1px; }
.ad-day span { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Registrering av ny kund */
.ps-regbox { max-width: 760px; max-height: 92vh; overflow-y: auto; }
.ps-regfields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; text-align: left; }
.ps-regwide { grid-column: 1 / -1; }
@media (max-width: 620px) { .ps-regfields { grid-template-columns: 1fr; } }
#lgRegister { margin-top: 4px; }
.ad-tag.warn { background: var(--warn); color: #1a1a1a; }
.ad-pending { border: 2px solid var(--warn); }
.ps-userline .ps-linkbtn { margin-left: 10px; }
/* Kontroll av fälten */
.ps-err { color: var(--warn); font-size: 12px; min-height: 1em; text-align: left; }
.ps-err.ok { color: var(--accent); }
input.ps-bad { border-color: var(--warn) !important; }
.ps-showrow { color: var(--muted); font-size: 14px; justify-content: flex-start; }
.ps-adminlink { color: var(--muted); font-size: 12px; opacity: .6; justify-self: end; text-decoration: none; }
.ps-ov-hint a { color: var(--accent); }
