/* ==========================================================================
   BOB Reels — dashboard reel editor
   Phone-shaped cards per category, tabs, live link check, drag to reorder,
   sticky save bar. Uses the colour tokens defined in stats/index.php.
   ========================================================================== */

.ed { margin-top: 12px; padding-bottom: 96px; }
.ed__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.ed__head h2 { margin: 0; font: 800 22px var(--h); }
.ed__head p { margin: 4px 0 0; color: var(--mut); font-size: 13px; max-width: 62ch; }

/* Category tabs */
.ed__tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.ed__tabs::-webkit-scrollbar { display: none; }
.ed__tab {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--mut); font: 600 14px var(--h); cursor: pointer;
  transition: color .2s, border-color .2s;
}
.ed__tab:hover { color: var(--tx); }
.ed__tab[aria-selected="true"] { color: var(--tx); border-bottom-color: var(--acc-hi); }
.ed__tab b { min-width: 22px; padding: 2px 7px; border-radius: 99px; background: var(--s2); color: var(--mut); font: 600 12px var(--num); text-align: center; }
.ed__tab[aria-selected="true"] b { background: rgba(196, 49, 86, .2); color: var(--tx); }

/* Card grid */
.ed__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 16px; }
.ed__panel[hidden] { display: none; }

.rc {
  position: relative; display: flex; flex-direction: column; background: var(--s1);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  transition: transform .25s ease, border-color .25s, box-shadow .25s, opacity .25s;
}
.rc:hover { border-color: rgba(255, 255, 255, .16); box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .9); }
.rc.is-dragging { opacity: .45; transform: scale(.97); }
.rc.is-over { border-color: var(--acc-hi); }
.rc.is-del { opacity: .38; }
.rc.is-del .rc__media { filter: grayscale(1); }
.rc.is-new { animation: rcIn .35s ease both; }
@keyframes rcIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* Phone-shaped preview */
.rc__media {
  position: relative; aspect-ratio: 9 / 16; max-height: 360px; background: var(--s2) center / cover no-repeat;
  display: grid; place-items: center;
}
.rc__media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.55), transparent 35%, transparent 70%, rgba(0,0,0,.45)); pointer-events: none; }
.rc__empty { color: var(--mut); font-size: 12px; text-align: center; padding: 10px; }
.rc__media.has-img .rc__empty { display: none; }
.rc__notch { position: absolute; top: 8px; left: 50%; translate: -50% 0; width: 30%; height: 4px; border-radius: 9px; background: rgba(0,0,0,.6); z-index: 1; }

.rc__badge {
  position: absolute; z-index: 2; top: 18px; inset-inline-start: 10px; padding: 4px 9px; border-radius: 99px;
  font: 700 11px var(--num); letter-spacing: .04em; background: rgba(0,0,0,.6); color: var(--tx); backdrop-filter: blur(6px);
}
.rc__badge[data-kind="ig"] { background: linear-gradient(45deg, #f09433cc, #dc2743cc, #bc1888cc); }
.rc__badge[data-kind="mp4"] { background: rgba(196, 49, 86, .85); }
.rc__badge[data-kind=""] { display: none; }

.rc__drag {
  position: absolute; z-index: 2; top: 14px; inset-inline-end: 8px; width: 34px; height: 34px; border-radius: 10px; border: 0;
  display: grid; place-items: center; background: rgba(0,0,0,.5); color: var(--tx); cursor: grab; backdrop-filter: blur(6px);
}
.rc__drag:active { cursor: grabbing; }
.rc__drag svg, .rc__tool svg, .rc__mv svg, .ed__add svg, .ed__save svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.rc__tools { position: absolute; z-index: 2; inset-inline: 8px; bottom: 8px; display: flex; gap: 6px; }
.rc__tool {
  position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 8px;
  border-radius: 10px; background: rgba(0,0,0,.55); color: var(--tx); font: 600 12px var(--h); cursor: pointer; backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12); transition: background .2s, border-color .2s;
}
.rc__tool:hover { background: rgba(0,0,0,.75); border-color: var(--acc-hi); }
.rc__tool.is-set { border-color: var(--acc-hi); background: rgba(128, 0, 32, .55); }
.rc__tool input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Fields */
.rc__body { display: grid; gap: 8px; padding: 12px; }
.rc__link { position: relative; }
.rc input[type=url], .rc input[type=text] {
  width: 100%; background: var(--bg); border: 1px solid #2b2723; border-radius: 10px; color: var(--tx);
  padding: 10px 12px; font: 14px var(--b); transition: border-color .2s, box-shadow .2s;
}
.rc input[type=url] { padding-inline-end: 34px; font-size: 13px; }
.rc input:focus { outline: none; border-color: var(--acc-hi); box-shadow: 0 0 0 3px rgba(196, 49, 86, .18); }
.rc__state { position: absolute; inset-inline-end: 10px; top: 50%; translate: 0 -50%; font: 700 14px var(--num); }
.rc__link.is-ok .rc__state { color: #5ec98a; }
.rc__link.is-bad input { border-color: #b4424f; }
.rc__link.is-bad .rc__state { color: #ff6b7d; }
.rc__msg { font-size: 12px; color: #ff8a97; min-height: 0; margin: -2px 2px 0; }
.rc__msg:empty { display: none; }
.rc__row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }

.rc__actions { display: flex; align-items: center; gap: 6px; padding-top: 2px; }
.rc__mv { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: none; color: var(--mut); display: grid; place-items: center; cursor: pointer; }
.rc__mv:hover { color: var(--tx); border-color: var(--mut); }
html[dir="rtl"] .rc__mv svg { transform: scaleX(-1); }
.rc__del {
  margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px;
  color: var(--mut); font-size: 13px; cursor: pointer; border: 1px solid transparent; transition: color .2s, border-color .2s;
}
.rc__del:hover { color: #ff8a97; border-color: rgba(255, 107, 125, .3); }
.rc__del input { accent-color: #b4424f; }
.rc.is-del .rc__del { color: #ff8a97; }

/* "Add reel" tile */
.ed__add {
  min-height: 260px; border: 1.5px dashed rgba(255,255,255,.18); border-radius: 16px; background: transparent; color: var(--mut);
  display: grid; place-content: center; justify-items: center; gap: 10px; font: 600 14px var(--h); cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.ed__add span { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--s2); }
.ed__add svg { width: 22px; height: 22px; }
.ed__add:hover { color: var(--tx); border-color: var(--acc-hi); background: rgba(128, 0, 32, .08); }

/* Sticky save bar */
.ed__bar {
  position: fixed; z-index: 50; inset-inline: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(14, 13, 12, .9); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
.ed__bar-in { width: 100%; max-width: 1180px; display: flex; align-items: center; gap: 14px; }
.ed__status { flex: 1; color: var(--mut); font-size: 14px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ed__status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5ec98a; flex: none; }
.ed__bar.is-dirty .ed__status { color: var(--tx); }
.ed__bar.is-dirty .ed__status::before { background: var(--ch); box-shadow: 0 0 10px var(--ch); }
.ed__save {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border: 0; border-radius: 12px;
  background: var(--acc); color: var(--tx); font: 700 15px var(--h); cursor: pointer; transition: background .2s, transform .2s;
}
.ed__save:hover { background: #9C0A2E; transform: translateY(-1px); }
.ed__save[disabled] { opacity: .7; cursor: wait; }
.ed__save .spin { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: edSpin .8s linear infinite; }
.ed__save[disabled] .spin { display: inline-block; }
@keyframes edSpin { to { transform: rotate(360deg); } }

/* Saved toast (the server's notice) */
.notice.is-toast {
  position: fixed; z-index: 60; top: 18px; left: 50%; translate: -50% 0; max-width: min(560px, calc(100% - 32px));
  border-radius: 12px; border-inline-start: 0; background: #1f2a22; border: 1px solid #2f5a3d; color: #d8f5e1;
  box-shadow: 0 20px 50px -20px #000; animation: toastIn .4s ease both, toastOut .5s ease 5s forwards;
}
@keyframes toastIn { from { opacity: 0; translate: -50% -12px; } }
@keyframes toastOut { to { opacity: 0; translate: -50% -12px; visibility: hidden; } }

@media (max-width: 560px) {
  .ed__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .rc__row { grid-template-columns: 1fr; }
  .rc__tool span { display: none; }
  .ed__save { padding: 12px 18px; }
}
@media (prefers-reduced-motion: reduce) { .rc, .rc.is-new, .notice.is-toast { animation: none !important; transition: none !important; } }
