/* Phase 7 — media attachments, voice calls, session operations and webhook
   admin. TENTH stylesheet, loaded after responsive.css in both base.html
   and login.html (see base.html's load-order comment) so it can override
   by cascade without touching the eight files that must stay byte-for-byte
   identical to the old minimal.css. Tokens only — every colour below is a
   :root variable already declared in base.css, with a [data-theme="dark"]
   counterpart wherever the light value is not already theme-neutral. */

/* ---------- CSS-only tabs (radio + label, no JS) --------------------------
   Used by send.html (Text/Media) and calls.html (TTS/Play). The two radio
   inputs are hidden and act as the tab state; sibling combinators show the
   matching panel and highlight the matching label. Works with JS disabled,
   which is why it is radio+label rather than an htmx/JS-driven show/hide —
   see CLAUDE.md's "no-JS path stays the default" rule. */
.send-tab-input { position: absolute; opacity: 0; pointer-events: none; }

.send-tab-list { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid rgba(145, 158, 171, 0.2); }

.send-tab-label {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
}

.send-tab-label:hover { color: var(--text-primary); }

.send-tab-panel { display: none; }

#send-tab-text:checked ~ .send-tab-list label[for="send-tab-text"],
#send-tab-media:checked ~ .send-tab-list label[for="send-tab-media"],
#call-tab-tts:checked ~ .send-tab-list label[for="call-tab-tts"],
#call-tab-play:checked ~ .send-tab-list label[for="call-tab-play"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

#send-tab-text:checked ~ [data-send-panel="text"],
#send-tab-media:checked ~ [data-send-panel="media"],
#call-tab-tts:checked ~ [data-send-panel="tts"],
#call-tab-play:checked ~ [data-send-panel="play"] {
  display: block;
}

/* ---------- media upload (send.html's Media tab) --------------------------- */
/* Per-kind size-limit summary above the Kind select (send.html) — "Image
   5.0 MB · Video 16.0 MB · …". .is-active is toggled by media-upload.js's
   syncKind to follow the Kind select, so the operator can see at a glance
   which number the client-side pre-check is using. Tokens only: --primary/
   --primary-lighter/--text-secondary already carry a [data-theme="dark"]
   counterpart in base.css, so no separate dark-mode block is needed here. */
.media-limits {
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.media-limit {
  padding: 2px 6px;
  border-radius: 4px;
  transition: background-color 120ms ease, color 120ms ease;
}

.media-limit.is-active {
  color: var(--primary-dark);
  background: var(--primary-lighter);
  font-weight: 700;
}

[data-theme="dark"] .media-limit.is-active { color: var(--primary-darker); }

.media-dropzone { margin-bottom: 20px; }

.media-file-chip {
  display: inline-block;
  margin: 4px 0 0;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(145, 158, 171, 0.12);
}

.media-size-error { margin: 8px 0 0; }

.media-progress {
  margin-top: 10px;
  height: 6px;
  border-radius: 3px;
  background: rgba(145, 158, 171, 0.2);
  overflow: hidden;
}

.media-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 120ms ease;
}

/* Plain checkbox field — send.html's "voice note" toggle. Distinct from
   .textfield (which is built around input[type=text|tel|...]/select). */
.checkfield {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-primary);
}

.checkfield input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- call status pills (calls.html / call_rows.html) --------------- */
.badge-placing    { color: var(--warning-dark); background: rgba(255, 171, 0, 0.16); }
.badge-placed     { color: var(--success-dark); background: rgba(34, 197, 94, 0.16); }
.badge-terminated { color: var(--grey-600);     background: rgba(145, 158, 171, 0.16); }

[data-theme="dark"] .badge-placing    { color: var(--warning-light); }
[data-theme="dark"] .badge-placed     { color: var(--success-light); }
[data-theme="dark"] .badge-terminated { color: var(--grey-400); }

/* ---------- session operations panel (session_ops_panel.html) ------------- */
.ops-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px dashed rgba(145, 158, 171, 0.2);
}

.ops-row:last-child { border-bottom: none; padding-bottom: 0; }

.ops-row-label p { margin: 4px 0 0; }

.ops-row-actions { flex-shrink: 0; }

/* ---------- webhook / DLQ tables (sessions/webhooks.html) ------------------ */
.webhook-rows .badge + .badge { margin-left: 4px; }

/* ---------- image / PDF affordances (media-upload.js) ----------------------
   Drop target, preview (image thumbnail or file-type badge) and the remove
   button. Motion is transform/opacity/border-color only and short (150ms,
   ease-out: it answers a user action); the whole block is switched off under
   prefers-reduced-motion. Colours are tokens; the badge tints have explicit
   [data-theme="dark"] counterparts because the error/primary lighter tokens
   are not redefined for dark. [hidden] is re-asserted for the elements whose
   display is set below, which would otherwise beat the attribute. */
.media-dropzone {
  padding: 12px;
  border: 1px dashed rgba(145, 158, 171, 0.4);
  border-radius: 12px;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.media-dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-lighter);
}

.media-dropzone .textfield { margin-bottom: 8px; }

.media-drop-hint { margin: 0; font-size: 13px; color: var(--text-secondary); }

.media-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.media-preview[hidden],
.media-preview-img[hidden],
.media-badge[hidden],
.media-drop-hint[hidden],
.media-kind-notice[hidden],
[data-media-caption][hidden],
[data-media-ptt][hidden] { display: none; }

.media-preview-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(145, 158, 171, 0.3);
  background: rgba(145, 158, 171, 0.12);
}

.media-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 72px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  background: var(--primary-lighter);
}

.media-badge[data-file-type="pdf"] { color: var(--error-dark); background: var(--error-lighter); }

[data-theme="dark"] .media-badge { color: var(--primary-darker); }
[data-theme="dark"] .media-badge[data-file-type="pdf"] {
  color: var(--error-light);
  background: rgba(255, 86, 48, 0.16);
}

.media-preview .media-file-chip { margin: 0; overflow-wrap: anywhere; }

.media-clear { height: 36px; padding: 0 12px; font-size: 13px; }

.media-kind-notice { margin: 8px 0 0; font-size: 13px; color: var(--text-secondary); }

@media (prefers-reduced-motion: no-preference) {
  .media-preview:not([hidden]) { animation: media-preview-in 150ms ease-out; }
  .media-clear:active { transform: scale(0.97); }
}

@keyframes media-preview-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
