/* css/scheduler.css
   Social Scheduler page — composer form + scheduled-post list. Built on
   top of shared.css tokens and account.css's .settings-group/.settings-row
   primitives, so this file only adds what's genuinely new: form fields,
   status badges, and the cancel button.
*/

.scheduler-intro {
  font-size: var(--text-sm);
  color: var(--text-3);
  margin: 0 0 var(--space-5);
  max-width: 46ch;
}

.scheduler-composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

.scheduler-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0; /* lets flex children shrink instead of overflowing the card */
}
/* Label + helper sit tight together; the control follows after a gap. */
.scheduler-field > .scheduler-label + .scheduler-help { margin-top: calc(var(--space-2) * -1 + 2px); }

.scheduler-field-row {
  display: flex;
  gap: var(--space-4);
}
.scheduler-field-row .scheduler-field { flex: 1; }
.scheduler-when { gap: var(--space-3); }
.scheduler-field--date { flex: 1.5 !important; }
.scheduler-field--time { flex: 1 !important; }

.scheduler-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
}

.scheduler-input {
  font: inherit;
  font-size: var(--text-base);
  color: var(--text-1);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  width: 100%;
}
.scheduler-input:focus {
  outline: none;
  border-color: var(--accent-2);
  background: var(--bg-elevated);
}
.scheduler-input--spaced { margin-top: var(--space-2); }

.scheduler-textarea {
  min-height: 96px;
  resize: vertical;
}

.scheduler-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
}
.scheduler-hint--inline { font-weight: 400; margin-left: 4px; }
.scheduler-count { align-self: flex-end; font-variant-numeric: tabular-nums; }

/* Errors are red, not the brand accent — orange reads as "primary
   action", so validation messages were easy to mistake for a link. */
.scheduler-error {
  font-size: var(--text-sm);
  color: var(--danger);
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
}

/* Real buttons — the submit used to be styled as a list row. */
.scheduler-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-1);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.scheduler-btn:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }
.scheduler-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.scheduler-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.scheduler-btn--primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.scheduler-submit { width: 100%; }
.scheduler-btn:disabled { opacity: 0.6; cursor: default; }

/* Blocked / empty states share one pattern with the Inbox + Insights pages. */
.scheduler-state,
.scheduler-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
}
.scheduler-state {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.scheduler-list-empty { padding: var(--space-6) var(--space-4); }
.scheduler-state i,
.scheduler-list-empty i { font-size: 1.75rem; color: var(--text-4); margin-bottom: var(--space-1); }
.scheduler-state-title { font-size: var(--text-base); font-weight: 600; color: var(--text-1); }
.scheduler-state-desc { font-size: var(--text-sm); color: var(--text-3); max-width: 40ch; }
.scheduler-state .scheduler-btn,
.scheduler-list-empty .scheduler-btn { margin-top: var(--space-2); }

.scheduler-post-row {
  align-items: flex-start;
}
.scheduler-post-when { display: block; font-size: var(--text-sm); color: var(--text-3); }
.scheduler-post-preview { display: block; font-size: var(--text-sm); color: var(--text-2); overflow-wrap: anywhere; }
.scheduler-post-error { display: flex; align-items: flex-start; gap: 4px; font-size: var(--text-xs); color: var(--danger); margin-top: 2px; }
.scheduler-media-icon { color: var(--text-3); }

.scheduler-cancel-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: var(--space-2);
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.scheduler-cancel-btn:hover { color: var(--danger); background: var(--danger-subtle); }
.scheduler-cancel-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.scheduler-cancel-btn:disabled { opacity: 0.5; cursor: default; }

.scheduler-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-left: var(--space-2);
  vertical-align: middle;
}
.scheduler-badge--pending    { background: var(--accent-subtle); color: var(--accent); }
.scheduler-badge--publishing { background: var(--accent-subtle); color: var(--accent); }
.scheduler-badge--published  { background: color-mix(in srgb, var(--success) 16%, var(--bg-elevated)); color: var(--success); }
.scheduler-badge--failed     { background: var(--danger-subtle); color: var(--danger); }
.scheduler-badge--canceled   { background: var(--bg-subtle); color: var(--text-3); }
.scheduler-badge--missed     { background: color-mix(in srgb, var(--warning) 16%, var(--bg-elevated)); color: var(--warning); }

/* ── Media upload (drag/drop, preview, progress) ─────────────────────── */

.scheduler-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  cursor: pointer;
  padding: var(--space-3);
  text-align: center;
  transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.scheduler-dropzone:hover { border-color: var(--border-strong); }
.scheduler-dropzone:focus-visible {
  border-color: var(--accent-2);
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.scheduler-dropzone--over {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

#mediaDropzoneEmpty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: var(--text-sm);
}
#mediaDropzoneEmpty i { font-size: 22px; color: var(--text-2); }

.scheduler-media-preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}
.scheduler-media-preview[hidden] { display: none; }
#mediaPreviewImg, #mediaPreviewVideo {
  max-height: 72px;
  max-width: 96px;
  border-radius: 8px;
  object-fit: cover;
  background: #000;
}
.scheduler-media-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-2);
  text-align: left;
  min-width: 0;
  overflow-wrap: anywhere;
}

.scheduler-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.scheduler-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width var(--duration-base) var(--ease);
}

@media (max-width: 480px) {
  .scheduler-composer { padding: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  .scheduler-progress-bar, .scheduler-dropzone { transition: none; }
}

#imageUrlFallback summary {
  cursor: pointer;
  list-style: none;
}
#imageUrlFallback summary::-webkit-details-marker { display: none; }

/* ── Helper text under labels ─────────────────────────────────────────── */
.scheduler-help {
  margin: 0;
  font-size: var(--text-xs);
  line-height: var(--leading-body);
  color: var(--text-3);
  max-width: 60ch;
}
.scheduler-help--spaced { margin-top: var(--space-2); }
.scheduler-when-summary { margin-top: calc(var(--space-2) * -1); }
.scheduler-when-summary:empty { display: none; }

/* ── Date & time pickers ──────────────────────────────────────────────────
   Native date/time inputs ignore width rules on iOS and render centred with
   their own chrome. Reset that, keep the native picker (best on phones), and
   make the whole field a tap target with a small icon as the affordance. */
.scheduler-picker { position: relative; min-width: 0; }
.scheduler-input--picker {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  padding-right: 40px;
  text-align: left;
  line-height: 1.3;
  cursor: pointer;
}
.scheduler-input--picker::-webkit-date-and-time-value { text-align: left; min-height: 1.3em; }
.scheduler-input--picker::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.scheduler-picker-icon {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text-3);
  pointer-events: none;
}
.scheduler-picker:focus-within .scheduler-picker-icon { color: var(--accent); }

/* ── "Use an image link instead" disclosure ───────────────────────────── */
#imageUrlFallback { margin-top: var(--space-1); }
.scheduler-disclosure {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
  border-radius: var(--radius-sm);
}
.scheduler-disclosure:hover span { text-decoration: underline; text-underline-offset: 3px; }
.scheduler-disclosure:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.scheduler-disclosure i { font-size: 15px; }
.scheduler-disclosure-caret { transition: transform var(--duration-fast) var(--ease); }
#imageUrlFallback[open] .scheduler-disclosure-caret { transform: rotate(180deg); }
#imageUrlFallback[hidden] { display: none; }

/* ── Spacing between the composer and the list below it ───────────────── */
.scheduler-list-wrap { margin-top: var(--space-7); }
.scheduler-list-wrap .settings-group-label { margin-top: 0; }
[hidden].scheduler-list-wrap { display: none; }

@media (prefers-reduced-motion: reduce) {
  .scheduler-disclosure-caret { transition: none; }
}

/* ── Inline field errors: plain text under the field, no card ─────────── */
.scheduler-field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  color: var(--danger);
}
.scheduler-field-error i { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.scheduler-field-error[hidden] { display: none; }
.scheduler-input[aria-invalid="true"],
.scheduler-input[aria-invalid="true"]:focus { border-color: var(--danger); }
.scheduler-dropzone[aria-invalid="true"] { border-color: var(--danger); }
.scheduler-field { scroll-margin-top: var(--space-6); }
