/* ============================================================
   VIDEORAMA v2 — app.css [Agent C]
   Dark theme, purple accent. All layout per DESIGN-CONTRACT.
   Class vocabulary for the other agents (documented for D/E/F):
   - Timeline clips:      .clip (+ .selected .dragging), children:
                          .film (filmstrip bg), .wave (waveform strip),
                          .name (label), .handle.l / .handle.r (trim)
   - Helpers:             .dragging  .snap-guide  .ghost-outline  .dragGhost
   - Transition badge:    .tBadge (+ .active when non-cut, + .selected)
   - Ruler:               .tick (+ .major), .tickLabel, .marker (cyan flag)
   - Inspector:           .sec > h4, .row > label + control + .val,
                          .btnRow, .empty (empty state), .hintText
   - Export modal:        .expBody (presets area), .presetGrid, .presetBtn,
                          .expRow
   ============================================================ */

:root {
  --bg: #101014;
  --panel: #17171d;
  --panel2: #1d1d25;
  --line: #2a2a35;
  --text: #e8e8f0;
  --dim: #8b8b9a;
  --accent: #7c5cff;
  --accent2: #b09aff;
  --danger: #ff5c7a;
  --play: #ff4757;
  --mark: #35d6ff;
  --clip: #2b2450;
  --clipline: #4a3f8a;
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
input, textarea { user-select: text; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-rows: 44px 1fr 300px; height: 100vh; }
.spacer { flex: 1; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }
.hidden { display: none !important; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2e2e3a; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3d3d4c; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- buttons ---------- */
button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color .12s, background .12s, opacity .12s;
}
button:hover { border-color: var(--accent); }
button:active { transform: translateY(0.5px); }
button:disabled { opacity: .4; cursor: default; transform: none; }
button:disabled:hover { border-color: var(--line); }
button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent2); border-color: var(--accent2); }
button.danger:hover { border-color: var(--danger); color: #ffd9e0; }
button.icon { width: 30px; padding: 6px 0; text-align: center; }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { border-color: var(--line); color: var(--text); }
button.sm { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }

kbd {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 10px;
  color: var(--dim);
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  -webkit-app-region: drag;
}
.topbar button, .topbar span { -webkit-app-region: no-drag; }
.logo { font-weight: 800; letter-spacing: 2px; color: var(--accent2); margin-right: 10px; font-size: 14px; }
.logo span { color: var(--text); }
#projName {
  color: var(--dim);
  font-size: 12px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- middle ---------- */
.middle { display: grid; grid-template-columns: 300px 1fr 300px; min-height: 0; }

/* ---------- media bin ---------- */
.bin {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.bin h3 {
  padding: 10px 12px 6px;
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}
#assets {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-content: start;
}
#assets:empty::after {
  content: 'Δεν υπάρχει υλικό ακόμη.\AΠροσθέστε βίντεο, ήχο ή εικόνες\Aαπό τη ζώνη παρακάτω.';
  white-space: pre-line;
  grid-column: 1 / -1;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.7;
  padding: 34px 8px;
}
.asset {
  position: relative;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: border-color .12s, box-shadow .12s;
}
.asset:hover { border-color: var(--accent); }
.asset:active { cursor: grabbing; }
.asset.selected { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent), 0 0 10px rgba(124, 92, 255, .35); }
.asset .th {
  width: 100%;
  height: 72px;
  background: #000 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--dim);
}
.asset .nm {
  padding: 5px 7px 2px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset .du { padding: 0 7px 6px; font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums; }
.asset .kind {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(16, 16, 20, .78);
  border-radius: 5px;
  font-size: 10px;
  padding: 1px 5px;
  color: var(--accent2);
  pointer-events: none;
}
#dropzone {
  margin: 8px;
  padding: 14px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
#dropzone:hover { border-color: var(--accent); color: var(--accent2); }
#dropzone.over { border-color: var(--accent); color: var(--accent2); background: rgba(124, 92, 255, .08); }

/* τα #binSearch/#binList τα δημιουργεί το mediabin.js μέσα στη στήλη .bin */
.bin #binSearch { margin: 0 8px 8px; width: calc(100% - 16px); }
.bin #binList { padding: 0 8px 8px; }

/* floating ghost card while dragging an asset (created by mediabin/timeline) */
.dragGhost {
  position: fixed;
  z-index: 3000;
  pointer-events: none;
  opacity: .85;
  transform: translate(-50%, -50%) scale(.9);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .65));
}

/* ---------- stage ---------- */
.stageWrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #000; }
#stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
}
#stageBox {
  position: relative;
  height: 100%;
  width: auto;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 0 1px #1f1f28;
}
#videoA, #videoB, #stillImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#stillImg { display: none; }
#vignetteLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, .82) 100%);
  opacity: 0;
  z-index: 3;
}
#grainLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
}
#overlayLayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
#lutChip {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 9px;
  background: rgba(124, 92, 255, .22);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 11px;
  color: var(--accent2);
  display: none;
  z-index: 10;
  pointer-events: none;
}

/* ---------- transport ---------- */
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 46px;
  flex: none;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#btnPlay { width: 42px; font-size: 14px; padding: 6px 0; text-align: center; }
#timeLabel {
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
  font-size: 13px;
  min-width: 138px;
}

/* ---------- inspector ---------- */
#inspector {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px;
  min-height: 0;
}
#inspector h3 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 12px;
  letter-spacing: .4px;
}
.sec { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: none; }
.sec h4 {
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
  font-weight: 700;
}
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; min-height: 24px; }
.row label { flex: 0 0 88px; color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .val {
  min-width: 46px;
  text-align: right;
  color: var(--accent2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.btnRow { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 2px; }
.empty {
  color: var(--dim);
  text-align: center;
  padding: 28px 10px;
  font-size: 12.5px;
  line-height: 1.7;
}
.hintText { color: var(--dim); font-size: 11.5px; line-height: 1.65; }
.chip {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  color: var(--accent2);
  font-size: 11px;
  background: rgba(124, 92, 255, .12);
}

/* ---------- form controls ---------- */
select,
input[type="text"],
input[type="number"] {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12.5px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}
input[type="color"] {
  width: 34px;
  height: 24px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
  padding: 1px;
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -4.5px;
  box-shadow: 0 0 6px rgba(124, 92, 255, .55);
  transition: background .12s;
}
input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent2); }
input[type="range"]:focus { outline: none; }

/* ---------- timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#tlTools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  height: 32px;
  flex: none;
  border-bottom: 1px solid var(--line);
}
.tlTitle {
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}
.hint {
  color: var(--dim);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: auto;
}
.tlBody { flex: 1; display: flex; min-height: 0; }

#tlGutter { flex: 0 0 64px; border-right: 1px solid var(--line); background: var(--panel); }
.timeline.noGutter #tlGutter { display: none; }
.gutCell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 10.5px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  letter-spacing: .4px;
}
.gutRuler { height: 26px; }
.gutOverlay { height: 44px; }
.gutVideo { height: 86px; }
.gutMusic { height: 44px; }

#tlScroll { flex: 1; overflow-x: auto; overflow-y: hidden; position: relative; background: var(--bg); }
/* +10px για το οριζόντιο scrollbar (το timeline.js κάνει το #tlInner scroller
   με overflow:auto) — αλλιώς το scrollbar τρώει τα κάτω 10px της Μουσικής */
#tlInner { position: relative; height: calc(200px + 10px); min-width: 100%; }

#ruler {
  height: 26px;
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  cursor: ew-resize;
  overflow: hidden;
}
.tick { position: absolute; bottom: 0; width: 1px; height: 7px; background: var(--line); pointer-events: none; }
.tick.major { height: 12px; background: var(--dim); }
.tickLabel {
  position: absolute;
  bottom: 11px;
  font-size: 9px;
  color: var(--dim);
  transform: translateX(3px);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* markers: cyan flags on the ruler */
.marker { position: absolute; top: 0; width: 2px; height: 100%; background: var(--mark); cursor: pointer; z-index: 35; }
.marker::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  border-top: 8px solid var(--mark);
  border-right: 8px solid transparent;
}
.marker:hover { filter: brightness(1.35); }

.track { position: relative; border-bottom: 1px solid var(--line); background: #121218; }
#trackOverlay { height: 44px; }
#trackVideo { height: 86px; background: #14141c; }
#trackMusic { height: 44px; }
#trackVideo:empty::before {
  content: 'Σύρετε υλικό εδώ από τη συλλογή για να ξεκινήσετε';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 12px;
  pointer-events: none;
}

/* ---------- clips ---------- */
.clip {
  position: absolute;
  background-color: var(--clip);
  background-repeat: repeat-x;
  background-size: auto 100%;
  border: 1px solid var(--clipline);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: box-shadow .1s, border-color .1s;
}
#trackOverlay .clip { top: 5px; height: 34px; background-color: #4a3670; border-color: #7a5fae; }
#trackVideo .clip { top: 5px; height: 76px; }
#trackMusic .clip { top: 5px; height: 34px; background-color: #20263b; border-color: #3b4a72; }
.clip:hover { border-color: var(--accent); }
.clip.selected {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 14px rgba(124, 92, 255, .55);
  z-index: 20;
}
.clip.dragging, .dragging { opacity: .55; z-index: 60; cursor: grabbing; }

.clip .film {
  position: absolute;
  inset: 0;
  background-repeat: repeat-x;
  background-size: auto 100%;
  pointer-events: none;
}
.clip .name {
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  font-size: 10.5px;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}
#trackOverlay .clip .name { top: 50%; transform: translateY(-50%); text-align: center; color: var(--accent2); }
.clip .wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 20px;
  background-repeat: repeat-x;
  background-size: auto 100%;
  opacity: .7;
  pointer-events: none;
  z-index: 2;
}
#trackMusic .clip .wave { top: 0; height: 100%; opacity: .85; }

/* trim handles: 18px hit zone, 6px visual bar */
.clip .handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  cursor: ew-resize;
  z-index: 5;
}
.clip .handle.l { left: 0; }
.clip .handle.r { right: 0; }
.clip .handle::after {
  content: '';
  position: absolute;
  top: 18%;
  bottom: 18%;
  width: 6px;
  border-radius: 3px;
  background: var(--accent2);
  opacity: 0;
  transition: opacity .1s;
}
.clip .handle.l::after { left: 2px; }
.clip .handle.r::after { right: 2px; }
.clip:hover .handle::after { opacity: .55; }
.clip.selected .handle::after { opacity: .9; }

/* ghost outline of pre-trim extent (element created by timeline.js) */
.ghost-outline {
  position: absolute;
  top: 5px;
  height: 76px;
  border: 1.5px dashed rgba(176, 154, 255, .75);
  border-radius: 8px;
  background: rgba(124, 92, 255, .07);
  pointer-events: none;
  z-index: 18;
}

/* snap guide line (element created by timeline.js inside #tlInner) */
.snap-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--accent2);
  box-shadow: 0 0 6px var(--accent2);
  pointer-events: none;
  z-index: 90;
}

/* transition badge ⧫ at main-track junctions */
.tBadge {
  position: absolute;
  top: 50%;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  background: var(--panel2);
  border: 1.5px solid var(--dim);
  border-radius: 4px;
  transform: rotate(45deg);
  cursor: pointer;
  z-index: 45;
  font-size: 0;
  line-height: 0;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.tBadge:hover { border-color: var(--accent2); }
.tBadge.active {
  background: var(--accent);
  border-color: var(--accent2);
  box-shadow: 0 0 10px rgba(124, 92, 255, .7);
}
.tBadge.selected { outline: 2px solid var(--accent2); outline-offset: 1px; }

/* playhead: red, full height, triangle head */
#playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--play);
  z-index: 100;
  pointer-events: none;
}
#playhead::before {
  content: '';
  position: absolute;
  top: 0;
  left: -5px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--play);
}

/* ---------- export modal ---------- */
#expModal {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 12, .66);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#expModal.open { display: flex; }
.modalCard {
  width: 540px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.modalTitle { font-size: 15px; font-weight: 700; color: var(--accent2); margin-bottom: 12px; }
.expBody { margin-bottom: 12px; }
.presetGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.presetBtn { text-align: left; padding: 9px 12px; line-height: 1.4; }
.presetBtn small { display: block; color: var(--dim); font-size: 10.5px; }
.presetBtn.selected { border-color: var(--accent); background: rgba(124, 92, 255, .14); }
.expRow { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.expRow label { flex: 0 0 88px; color: var(--dim); font-size: 12px; }
.expProgress { margin: 10px 0 4px; }
#expStage { font-size: 12px; color: var(--dim); margin-bottom: 7px; min-height: 16px; }
.barTrack { height: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
#expBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
  transition: width .25s ease;
}
.modalFoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 30000; /* πάνω από το #expModal (20000) — αλλιώς τα toasts κρύβονται */
  max-width: 70vw;
  text-align: center;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .6);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: var(--danger); color: #ffd9e0; }
#toast.ok { border-color: #3ddc97; }
