/* =============================================
   Posdit — Shared Styles
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f11;
  color: #e8e8ec;
  min-height: 100vh;
}

/* =============================================
   Landing Page
   ============================================= */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  gap: 2rem;
}

.landing h1 {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
}

.landing h1 span {
  color: #7c6af7; /* accent */
}

.url-form {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 560px;
}

.url-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #2e2e38;
  border-radius: 8px;
  background: #1a1a24;
  color: #e8e8ec;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.url-form input:focus {
  border-color: #7c6af7;
}

.url-form input::placeholder {
  color: #555568;
}

.url-form button {
  padding: 0.75rem 1.4rem;
  background: #7c6af7;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.url-form button:hover {
  background: #6a59e0;
}

.landing-error {
  color: #f07070;
  font-size: 0.875rem;
  min-height: 1.2em;
}

/* =============================================
   Video Page
   ============================================= */

.video-page {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Video Panel (left, 2/3) --- */
.video-panel {
  flex: 2;
  display: flex;
  flex-direction: column;
  background: #000;
  min-width: 0; /* prevent flex overflow */
}

.video-panel header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  background: #111118;
  border-bottom: 1px solid #1e1e2a;
  flex-shrink: 0;
}

.video-panel header a {
  color: #7c6af7;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.video-panel header a:hover {
  text-decoration: underline;
}

/* "+ new video" button and inline form in the video header */
.header-new-video {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.header-new-btn {
  background: none;
  border: 1px solid #2e2e3a;
  color: #666677;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.header-new-btn:hover {
  color: #c8c8dd;
  border-color: #5a5a70;
}

.header-url-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.header-url-form[hidden] { display: none; }

.header-url-form input {
  width: 260px;
  padding: 0.3rem 0.6rem;
  background: #1a1a24;
  border: 1px solid #3a3a50;
  border-radius: 5px;
  color: #e8e8ec;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.header-url-form input:focus { border-color: #7c6af7; }

.header-url-form button[type="submit"] {
  padding: 0.3rem 0.7rem;
  background: #7c6af7;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.header-url-form button[type="submit"]:hover { background: #6a59e0; }

.header-url-form button[type="button"] {
  background: none;
  border: none;
  color: #555568;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  transition: color 0.15s;
}

.header-url-form button[type="button"]:hover { color: #f07070; }

.player-wrap {
  flex: 1;
  position: relative;
  background: #000;
  min-height: 0;
}

/* =============================================
   Custom Control Bar
   ============================================= */

.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: #0d0d12;
  border-top: 1px solid #1a1a26;
  flex-shrink: 0;
  gap: 0.5rem;
}

.ctrl-left,
.ctrl-right {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.ctrl-btn {
  background: none;
  border: none;
  color: #b8b8cc;
  cursor: pointer;
  padding: 0.4rem 0.45rem;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.ctrl-btn:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ctrl-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.ctrl-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* Play icon is filled, not stroked */
#play-icon { fill: currentColor; stroke: none; }

/* Volume group — slider reveals on hover */
.volume-group {
  display: flex;
  align-items: center;
}

.volume-slider {
  width: 0;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
  accent-color: #7c6af7;
  cursor: pointer;
  margin-left: 0;
}

.volume-group:hover .volume-slider,
.volume-group:focus-within .volume-slider {
  width: 64px;
  opacity: 1;
  margin-left: 0.3rem;
}

/* Current / total time */
.ctrl-time {
  font-size: 0.72rem;
  color: #55556a;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  padding-left: 0.4rem;
  white-space: nowrap;
}

/* =============================================
   Seeker / Timeline
   ============================================= */

.seeker-wrap {
  padding: 0.55rem 0.75rem;
  background: #0d0d12;
  border-top: 1px solid #151520;
  flex-shrink: 0;
}

.seeker-track {
  position: relative;
  height: 3px;
  background: #252535;
  border-radius: 2px;
  cursor: pointer;
  transition: height 0.15s;
}

.seeker-track:hover {
  height: 5px;
}

.seeker-fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 0%;
  background: #7c6af7;
  border-radius: 2px;
  pointer-events: none;
}

.seeker-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 11px;
  height: 11px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.seeker-track:hover .seeker-thumb {
  opacity: 1;
}

/* Note markers on the seeker */
.seeker-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Quick note → purple dot */
.marker-note {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: #7c6af7;
  border: 1.5px solid #0d0d12;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.1s;
}

.marker-note:hover {
  transform: translate(-50%, -50%) scale(1.4);
}

/* Clip note → amber bar */
.marker-clip {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(240, 160, 80, 0.55);
  border-radius: 2px;
  pointer-events: none;
}

/* Ensure injected container divs fill the wrapper so the player has a size */
#player-container,
#yt-placeholder {
  width: 100%;
  height: 100%;
}

/* Sits above the player, intercepts all clicks so the video can't be
   clicked to play/pause — use the control bar buttons instead. */
.player-click-blocker {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* iframe fills the wrapper */
.player-wrap iframe,
.player-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* --- Notes Panel (right, 1/3) --- */
.notes-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #13131b;
  border-left: 1px solid #1e1e2a;
  min-width: 280px;
  max-width: 480px;
}

.notes-header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #1e1e2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.notes-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888899;
}

/* Clip recording indicator */
.clip-indicator {
  font-size: 0.72rem;
  font-weight: 600;
  color: #f0a050;
  background: rgba(240, 160, 80, 0.12);
  border: 1px solid rgba(240, 160, 80, 0.3);
  border-radius: 5px;
  padding: 0.2rem 0.55rem;
  animation: clip-pulse 1.2s ease-in-out infinite;
  white-space: nowrap;
}

@keyframes clip-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Small icon buttons in notes header (import, export, ?) */
.notes-header-meta {
  display: flex;
  gap: 0.2rem;
}

.meta-btn {
  background: none;
  border: 1px solid #2e2e3a;
  color: #666677;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  height: 1.8rem;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.meta-btn:hover {
  color: #c8c8dd;
  border-color: #5a5a70;
  background: #1e1e2a;
}

/* Search bar */
.notes-search-wrap {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e1e2a;
  flex-shrink: 0;
}

#notes-search {
  width: 100%;
  padding: 0.4rem 0.65rem;
  background: #1a1a24;
  border: 1px solid #2e2e38;
  border-radius: 6px;
  color: #e8e8ec;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#notes-search:focus {
  border-color: #7c6af7;
}

#notes-search::placeholder {
  color: #44445a;
}

/* "Add note" button */
#add-note-btn {
  background: #7c6af7;
  color: #fff;
  border: none;
}

#add-note-btn:hover {
  background: #6a59e0;
}

/* Scrollable notes list */
.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.notes-list::-webkit-scrollbar {
  width: 5px;
}

.notes-list::-webkit-scrollbar-track {
  background: transparent;
}

.notes-list::-webkit-scrollbar-thumb {
  background: #2e2e40;
  border-radius: 10px;
}

/* Individual note card */
.note-card {
  background: #1a1a26;
  border: 1px solid #25253a;
  border-radius: 8px;
  padding: 0.6rem 0.7rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.note-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer; /* clicking the top row seeks the video */
}

/* Highlighted when video playback is near this note's timestamp —
   bold left bar to signal "playing now" */
.note-card.note-active {
  background: #201c38;
  border-color: #5a4aaa;
  border-left: 4px solid #7c6af7;
  padding-left: calc(0.7rem - 3px); /* compensate for wider left border */
}

/* Range note opened with "[" — amber ring while waiting for "]" */
.note-card.note-recording {
  background: #1e1c16;
  border-color: #f0a050;
  box-shadow: 0 0 0 2px rgba(240, 160, 80, 0.35);
}

/* Timestamp — now an <input> styled to look like the old badge.
   Click the input to edit the time; click elsewhere on the row to seek. */
.note-timestamp {
  font-size: 0.75rem;
  font-weight: 600;
  color: #7c6af7;
  background: rgba(124, 106, 247, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: none;
  outline: none;
  width: 4.5rem;
  text-align: center;
  cursor: pointer;    /* single-click seeks; double-click to edit */
  font-family: inherit;
  transition: background 0.15s;
}

/* editing state (JS removes readOnly attribute) */
.note-timestamp:not([readonly]) {
  cursor: text;
}

.note-timestamp:hover {
  background: rgba(124, 106, 247, 0.25);
}

.note-timestamp:focus {
  background: rgba(124, 106, 247, 0.3);
}

/* Delete note button */
.note-delete {
  background: none;
  border: none;
  color: #44445a;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.1rem;
  transition: color 0.15s;
}

.note-delete:hover {
  color: #f07070;
}

/* Note textarea */
.note-card textarea {
  background: transparent;
  border: none;
  color: #d8d8e8;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;       /* JS handles resizing; hide the drag handle */
  overflow: hidden;   /* prevents internal scrollbar while JS resizes */
  outline: none;
  line-height: 1.5;
  width: 100%;
  min-height: 42px;  /* ~2 lines — collapses for short notes */
}

.note-card textarea::placeholder {
  color: #3a3a52;
}

/* Empty state */
.notes-empty {
  text-align: center;
  color: #44445a;
  font-size: 0.85rem;
  padding: 2rem 1rem;
  line-height: 1.6;
}

/* file:// warning banner */
#file-warning {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #7c3b00;
  color: #ffd580;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  z-index: 100;
}

/* =============================================
   Video Library (landing page)
   ============================================= */

.video-library {
  width: 100%;
  max-width: 560px;
}

.video-library h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555568;
  margin-bottom: 0.5rem;
}

.video-library ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.video-library li a {
  display: block;
  padding: 0.5rem 0.75rem;
  background: #1a1a24;
  border: 1px solid #2e2e38;
  border-radius: 6px;
  color: #9988ff;
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s, background 0.15s;
}

.video-library li a:hover {
  border-color: #7c6af7;
  background: #1e1a30;
}

/* =============================================
   Notes footer — sticky button row at the bottom
   ============================================= */

.notes-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #1e1e2a;
  flex-shrink: 0;
}

.notes-footer button {
  flex: 1;
  padding: 0.6rem 0;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#copy-notes-btn {
  background: transparent;
  color: #7c6af7;
  border: 1px solid #7c6af7;
}

#copy-notes-btn:hover {
  background: rgba(124, 106, 247, 0.15);
}

/* =============================================
   Note card — timestamps group (start + end)
   ============================================= */

.note-timestamps {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.note-time-sep {
  font-size: 0.7rem;
  color: #555568;
  pointer-events: none;
}

/* End-time input — same look as start-time */
.note-end-time {
  width: 4.5rem;
}

/* "+end" button — muted, appears on hover of the card */
.note-add-end {
  background: none;
  border: 1px solid #2e2e3a;
  color: #44445a;
  font-size: 0.68rem;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  cursor: pointer;
  font-family: inherit;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.note-card:hover .note-add-end,
.note-card:focus-within .note-add-end {
  opacity: 1;
}

.note-add-end:hover {
  color: #7c6af7;
  border-color: #7c6af7;
}

/* "×" button that clears the end timestamp */
.note-clear-end {
  background: none;
  border: none;
  color: #44445a;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0 0.1rem;
  line-height: 1;
  transition: color 0.15s;
}

.note-clear-end:hover {
  color: #f07070;
}

/* =============================================
   Empty state hint line
   ============================================= */

.notes-hint {
  display: block;
  font-size: 0.75rem;
  color: #33334a;
  margin-top: 0.4rem;
  letter-spacing: 0.01em;
}

/* =============================================
   Shortcuts overlay
   ============================================= */

.shortcuts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.shortcuts-overlay[hidden] {
  display: none;
}

.shortcuts-box {
  background: #1a1a26;
  border: 1px solid #2e2e3e;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  min-width: 300px;
  position: relative;
}

.shortcuts-box h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888899;
  margin-bottom: 1rem;
}

.shortcuts-close {
  position: absolute;
  top: 0.85rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: #555568;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}

.shortcuts-close:hover {
  color: #e8e8ec;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.2rem 0.45rem;
  background: #111118;
  border: 1px solid #3a3a50;
  border-bottom-width: 2px;
  border-radius: 5px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 600;
  color: #c8c8e0;
  letter-spacing: 0.02em;
}

.shortcut-row span {
  font-size: 0.85rem;
  color: #aaaabc;
}

.shortcuts-note {
  margin-top: 1.1rem;
  font-size: 0.75rem;
  color: #44445a;
}

/* =============================================
   Library item — rename button
   ============================================= */

.library-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.library-item a {
  flex: 1;
  min-width: 0;
}

.library-rename-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #33334a;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  font-family: inherit;
}

.library-item:hover .library-rename-btn {
  opacity: 1;
}

.library-rename-btn:hover {
  color: #7c6af7;
}

.library-rename-input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  background: #1a1a24;
  border: 1px solid #7c6af7;
  border-radius: 6px;
  color: #e8e8ec;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
}

/* =============================================
   Responsive — stack panels below 768px
   ============================================= */

@media (max-width: 768px) {
  .video-page {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  .video-panel {
    flex: none;
  }

  .player-wrap {
    aspect-ratio: 16 / 9;
    position: relative;
    height: auto;
  }

  .player-wrap iframe,
  .player-wrap video {
    position: absolute;
  }

  .notes-panel {
    flex: none;
    max-width: 100%;
    min-width: unset;
    height: 50vh;
    border-left: none;
    border-top: 1px solid #1e1e2a;
  }
}
