/* Dashboard styles. Clean, calm, works on a phone. */

:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --teal: #1d6f7a;
  --accent: #f2a541;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #687385;
  --line: #e2e6ec;
  --green: #1f9d55;
  --amber: #d98e04;
  --red: #c83a3a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--teal); }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 58px;
  background: var(--navy);
  color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-mark { background: var(--accent); color: var(--navy); font-weight: 800; padding: 2px 7px; border-radius: 6px; font-size: 13px; }
#nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#nav a { color: rgba(255, 255, 255, 0.78); text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
#nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
#nav a.active { color: #fff; background: rgba(255, 255, 255, 0.16); }
.me { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255, 255, 255, 0.8); white-space: nowrap; }
.me form { margin: 0; }
button.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

main#app { max-width: 1200px; margin: 0 auto; padding: 28px 24px 80px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* Buttons and form controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: #185f69; }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--muted); font-size: 16px; line-height: 1; }
.icon-btn:hover { background: #eef1f4; color: var(--text); }

input[type=text], input[type=email], input[type=url], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29, 111, 122, 0.35); border-color: var(--teal); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 5px; }
label.field small { display: block; color: var(--muted); margin-top: 4px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd5dd; border-radius: 22px; transition: 0.15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:disabled + span { cursor: default; opacity: 0.6; }

/* Cards and grids */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0; font-size: 17px; }
.card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px; background: #eef1f4; color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Screen status */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; margin: 10px 0 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b9c0ca; flex: none; }
.dot.showing { background: var(--green); box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.18); }
.dot.in-use { background: var(--amber); }
.dot.offline { background: var(--red); }
.now { font-size: 13px; color: var(--muted); min-height: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-card .playlist-pick { margin-top: 12px; }
.screen-card .playlist-pick span { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }

/* Playlist list */
.playlist-card { cursor: pointer; transition: border-color 0.15s; text-decoration: none; color: inherit; display: block; }
.playlist-card:hover { border-color: var(--teal); }

/* Playlist editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 24px; align-items: start; }
.editor .preview { position: sticky; top: 80px; }
.preview-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #000; display: block; box-shadow: var(--shadow); }
.title-input { font-size: 22px; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 4px 8px; margin-left: -8px; border-radius: 8px; width: 100%; max-width: 520px; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { background: #fff; }
.add-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }

.slide-list { display: flex; flex-direction: column; gap: 8px; }
.slide-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.slide-row.disabled { opacity: 0.55; }
.slide-row.sortable-ghost { opacity: 0.35; }
.handle { cursor: grab; color: #a9b1bc; font-size: 18px; padding: 4px; user-select: none; touch-action: none; }
.thumb { width: 96px; height: 54px; border-radius: 6px; background: #e9edf2; flex: none; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb.text { background: linear-gradient(135deg, var(--navy), var(--teal)); }
.thumb.web { background: #dfe7f0; color: var(--navy); font-size: 22px; }
.slide-info { flex: 1; min-width: 0; }
.slide-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slide-meta { font-size: 12px; color: var(--muted); }
.duration { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.duration input { width: 64px; padding: 5px 7px; text-align: right; }

/* Media library */
.dropzone {
  border: 2px dashed #c6ced8;
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  margin-bottom: 20px;
}
.dropzone.over { border-color: var(--teal); background: #eef7f8; }
.media-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative; }
.media-item .pic { aspect-ratio: 16 / 9; background: #e9edf2; display: block; width: 100%; object-fit: cover; }
.media-item .meta { padding: 8px 10px; font-size: 12px; }
.media-item .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .badge { position: absolute; top: 6px; left: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.media-item .del { position: absolute; top: 4px; right: 4px; background: rgba(255, 255, 255, 0.92); }
.media-item.pickable { cursor: pointer; }
.media-item.selected { outline: 3px solid var(--teal); }
.progress { height: 6px; background: #e3e7ed; border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; background: var(--teal); width: 0; transition: width 0.2s; }

/* Tables */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { background: #f7f8fa; font-size: 13px; color: var(--muted); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
table.list select { width: auto; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; padding: 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal.wide { max-width: 900px; }
.modal h2 { margin-bottom: 6px; }
.modal .intro { color: var(--muted); margin: 0 0 16px; }
.modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.code-input { font-size: 32px !important; letter-spacing: 0.15em; text-align: center; font-weight: 700; text-transform: uppercase; }

/* Toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--red); }

.alert { background: #fdecec; color: #8a1f1f; border: 1px solid #f5c2c2; padding: 10px 12px; border-radius: 9px; margin: 12px 0; text-align: left; }

/* Sign-in page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, var(--teal) 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); }
.login-card .brand-mark { font-size: 16px; padding: 4px 10px; }
.login-card h1 { margin: 14px 0 4px; font-size: 26px; }
.btn-google { width: 100%; margin-top: 20px; padding: 12px; font-size: 15px; }
.btn-google.disabled { opacity: 0.5; pointer-events: none; }
.dev-login { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 8px; }

/* Phones */
@media (max-width: 860px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  table.list { display: block; overflow-x: auto; }
  .editor .preview { position: static; order: -1; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand { font-size: 0; }
  .brand .brand-mark { font-size: 13px; }
  .me span { display: none; }
  main#app { padding: 18px 12px 80px; }
  .thumb { width: 48px; height: 27px; }
  .slide-row { padding: 8px 6px; }
  .slide-row .icon-btn { padding: 4px; }
  .handle { padding: 2px; }
  .slide-row { gap: 8px; }
  .duration input { width: 46px; padding: 4px 5px; }
}
