/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-success-border: #86efac;
    --color-error: #dc2626;
    --color-error-light: #fee2e2;
    --color-error-border: #fca5a5;
    --color-muted: #6b7280;
    --color-muted-light: #f3f4f6;
    --color-muted-border: #e5e7eb;
    --color-warning-light: #fefce8;
    --color-warning-border: #fde047;
    --color-text: #111827;
    --color-text-light: #4b5563;
    --color-border: #d1d5db;
    --color-bg: #ffffff;
    --color-bg-page: #f9fafb;

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;

    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);

    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg-page);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

h1, h2, h3, h4 {
    margin: 0 0 var(--spacing-md);
    line-height: 1.3;
    color: var(--color-text);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

p {
    margin: 0 0 var(--spacing-md);
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* ============================================================
   Site Header
   ============================================================ */
.site-header {
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-lg) 0;
    margin-bottom: var(--spacing-2xl);
    box-shadow: var(--shadow-sm);
}

.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* ============================================================
   Forms
   ============================================================ */
.upload-form {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text);
    font-size: var(--font-size-sm);
}

.required {
    color: var(--color-error);
    margin-left: var(--spacing-xs);
}

.optional {
    font-weight: 400;
    color: var(--color-muted);
    font-size: 0.8125rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-block;
    padding: 0.625rem var(--spacing-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.5;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    text-decoration: none;
    color: #ffffff;
}

.btn-secondary {
    background-color: var(--color-muted-light);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-muted-border);
    text-decoration: none;
    color: var(--color-text);
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-lg);
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.alert-error {
    background-color: var(--color-error-light);
    border-color: var(--color-error-border);
    color: #7f1d1d;
}

.alert p {
    margin: 0;
    flex: 1;
}

/* ============================================================
   Progress / Status
   ============================================================ */
.progress-page {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}

.progress-page .help-text {
    color: var(--color-muted);
    margin-bottom: var(--spacing-xl);
}

.status-done {
    color: var(--color-success);
    font-weight: 600;
    font-size: var(--font-size-lg);
}

/* Queue state */
.queue-state {
    margin: var(--spacing-md) 0;
}

.queue-position {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.queue-eta {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    margin-top: var(--spacing-sm);
}

/* Steps */
.step-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--spacing-lg);
    text-align: left;
}

.step-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-muted-border);
}

.step-item:last-child {
    border-bottom: none;
}

.step-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
}

.step-done .step-icon {
    background-color: var(--color-success);
    color: #ffffff;
}

.step-running .step-icon {
    background-color: var(--color-primary);
    color: #ffffff;
}

.step-pending .step-icon {
    background-color: var(--color-muted-light);
    border: 2px solid var(--color-muted-border);
}

.step-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step-name {
    font-weight: 500;
    color: var(--color-text);
}

.step-pending .step-name {
    color: var(--color-muted);
}

.step-time {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
}

/* CSS Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progress Bar */
.progress-bar-wrapper {
    height: 6px;
    background-color: var(--color-muted-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.progress-bar {
    height: 100%;
    background-color: var(--color-primary);
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 0;
}

/* Moving diagonal stripes while a step is running, so the bar looks alive
   even when its width doesn't change for minutes (long transcription). */
.progress-bar--active {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.28) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.28) 50%,
        rgba(255, 255, 255, 0.28) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

.step-counter {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    margin: 0;
}

.elapsed-timer {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    margin-bottom: var(--spacing-xl);
}

.elapsed-timer #elapsed {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--color-text);
}

/* ============================================================
   Results Page
   ============================================================ */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.results-header h2 {
    margin: 0;
}

/* ============================================================
   Accordion
   ============================================================ */
.accordion {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-2xl);
}

.accordion-item {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* Items with content: expandable details/summary */
details.accordion-item--has-content {
    border: 1px solid var(--color-success-border);
}

details.accordion-item--has-content > .accordion-summary--filled {
    background-color: var(--color-success-light);
    cursor: pointer;
}

details.accordion-item--has-content > .accordion-summary--filled:hover {
    background-color: #bbf7d0;
}

details[open] > .accordion-summary--filled .accordion-arrow {
    transform: rotate(180deg);
}

/* Empty items: not expandable */
.accordion-item--empty {
    border: 1px solid var(--color-warning-border);
}

.accordion-summary--empty {
    background-color: var(--color-warning-light);
    cursor: default;
}

/* Shared summary/header styles */
.accordion-summary,
summary.accordion-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    user-select: none;
    list-style: none;
}

summary.accordion-summary::-webkit-details-marker {
    display: none;
}

.category-label {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--color-text);
}

.accordion-arrow {
    font-size: 0.75rem;
    color: var(--color-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.not-discussed {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    font-style: italic;
}

.accordion-body {
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--color-bg);
    border-top: 1px solid var(--color-success-border);
    font-size: var(--font-size-base);
    line-height: 1.7;
    color: var(--color-text-light);
}

.accordion-body p {
    margin: 0 0 0.75rem 0;
}

.accordion-body p:last-child {
    margin-bottom: 0;
}

.detail-message {
    color: var(--color-primary);
    font-size: var(--font-size-base);
    font-weight: 500;
    text-align: center;
    margin-top: 0.75rem;
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.besproken-date {
    font-style: italic;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: var(--font-size-small);
    margin-bottom: 0.25rem !important;
}

/* ============================================================
   Upload Progress
   ============================================================ */
.upload-status {
    margin-top: var(--spacing-lg);
    text-align: center;
}

.upload-status-text {
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

.upload-percent {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    margin: var(--spacing-xs) 0 0;
}

.server-spinner-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.spinner-dark {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2.5px solid var(--color-muted-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

/* ============================================================
   Utility
   ============================================================ */
.upload-page h2 {
    margin-bottom: var(--spacing-lg);
}

/* =========================================================================
   Wireframe v3 — variables
   ========================================================================= */
:root {
  --wfv3-ink: #1a1a1a;
  --wfv3-ink-soft: #5a5a5a;
  --wfv3-ink-fade: #9a9a9a;
  --wfv3-paper: #fafaf7;
  --wfv3-line: #d8d6cf;
  --wfv3-accent: #c96442;
  --wfv3-accent-soft: #f7e6dc;
  --wfv3-blue: #2a5fd9;
  --wfv3-blue-soft: #e0ebff;
  --wfv3-green: #2a9d3f;
  --wfv3-green-soft: #d9f2dd;
  --wfv3-yellow-soft: #fff4c4;
  --wfv3-gray-soft: #ececec;
  --wfv3-serif: Georgia, "Times New Roman", serif;
}

/* =========================================================================
   Upload page (v3)
   ========================================================================= */
.upload-v3 .page-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
}
.upload-v3 .page-head h2 { font-size: 22px; font-weight: 700; margin: 0; }
.upload-v3 .step { margin-bottom: 18px; }
.upload-v3 .step-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--wfv3-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.upload-v3 .step-label .opt {
  color: var(--wfv3-ink-fade);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.upload-v3 .upload-box {
  border: 1px solid var(--wfv3-line);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-v3 .upload-box.attached-audio { background: var(--wfv3-green-soft); border-color: #95d39e; }
.upload-v3 .upload-box.attached-docx { background: var(--wfv3-blue-soft); border-color: #9bb5e8; }
.upload-v3 .file-icon {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: var(--wfv3-green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.upload-v3 .file-icon.docx {
  width: 32px; height: 40px;
  background: #fff; color: var(--wfv3-blue);
  border: 1.5px solid var(--wfv3-blue); border-radius: 4px;
  font-size: 10px; font-weight: 700;
}
.upload-v3 .file-meta { flex: 1; min-width: 0; }
.upload-v3 .file-meta .name { font-size: 13px; font-weight: 600; }
.upload-v3 .file-meta .sub { font-size: 11px; color: var(--wfv3-ink-soft); }
.upload-v3 .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
.upload-v3 .field { display: flex; flex-direction: column; gap: 6px; }
.upload-v3 .field--wide { grid-column: 1 / -1; }
.upload-v3 .field .lbl { font-size: 12px; font-weight: 700; color: var(--wfv3-ink); margin: 0; }
.upload-v3 .text-input {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.upload-v3 .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.upload-v3 .chip {
  padding: 5px 11px;
  border: 1px solid var(--wfv3-line);
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  color: var(--wfv3-ink);
}
.upload-v3 .chip.active {
  background: var(--wfv3-ink);
  color: #fff;
  border-color: var(--wfv3-ink);
}
.upload-v3 .cta-row {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px;
}

/* =========================================================================
   Results page — render-failure banner (accordion styles live above, shared
   with develop's client-approved design)
   ========================================================================= */
.render-error-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #78350f;
}
.render-error-banner strong { font-size: 13px; }

/* Task 8: site-header logo + nav */
.site-header .header-row {
    display: flex; align-items: center; gap: 18px;
    padding: 10px 0;
}
.site-header .logo {
    font-weight: 700; font-size: 18px; letter-spacing: -0.4px;
}
.site-header .nav { display: flex; gap: 4px; }
.site-header .nav a {
    padding: 6px 12px; font-size: 13px;
    color: var(--wfv3-ink-soft);
    text-decoration: none; border-radius: 4px;
}
.site-header .nav a.active {
    color: var(--wfv3-ink);
    font-weight: 600; background: var(--wfv3-gray-soft);
}

/* Task 5: results-page catch-all "overige onderwerpen" card — reuses the
   accordion-item/accordion-body shell above, styled as a neutral note since
   it is informational (not a warning, not report content). */
.accordion-item--info {
    border: 1px solid var(--color-muted-border);
    margin-top: var(--spacing-xs);
}
.accordion-summary--info {
    background-color: var(--color-muted-light);
    cursor: default;
}
.extra-topics-note {
    color: var(--color-muted);
    font-style: italic;
    font-size: var(--font-size-sm);
}

/* --- Floating feedback box (results page only) --- */
.feedback-float {
    position: fixed;
    right: var(--spacing-md);
    bottom: var(--spacing-md);
    z-index: 50;
    max-width: 220px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg);
    border: 1px solid var(--color-muted-border);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.feedback-float__prompt {
    margin: 0 0 4px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
}
.feedback-float__link {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
}
.feedback-float__link:hover {
    text-decoration: underline;
}

/* --- Embedded external status page (/systeemstatus) --- */
.status-page-embed {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.status-page-embed .help-text {
    color: var(--color-muted);
    font-size: var(--font-size-sm);
    margin: 0;
}
.status-embed-frame {
    margin-top: var(--spacing-md);
    border: 1px solid var(--color-muted-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-bg);
}
.status-embed-frame iframe {
    display: block;
    width: 100%;
    height: 78vh;
    border: 0;
}

/* ============================================================
   Editable besproken sections (RESULTS_EDIT_MODE=on)
   ============================================================ */
.besproken-body {
    width: 100%;
    min-height: 180px;
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    line-height: 1.6;
    /* A contenteditable div, not a textarea — the date above it has to fall in
       the same selection flow. So: wrap and keep the mediator's own blank
       lines, which a block element would otherwise collapse. */
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.besproken-body:focus {
    outline: 2px solid var(--color-success);
    border-color: var(--color-success);
}

.besproken-hint {
    margin: var(--spacing-xs) 0 0;
    font-size: var(--font-size-sm);
    color: var(--color-muted);
}

/* Copy-all control (static/results-copy.js reveals it; the template ships it
   hidden so a blocked script leaves no dead button behind). */
.results-copy-all {
    margin: 0 0 var(--spacing-sm);
}

.besproken-saved__marker {
    font-size: var(--font-size-sm);
    color: var(--color-success);
}

/* A save that did not reach the server. Red, and it stays until the retry
   succeeds — the mediator must not press Genereer thinking this text is
   stored. Set by static/results-edit.js. */
.besproken-saved__failure {
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

.besproken-retry {
    margin-left: var(--spacing-sm);
    padding: 2px var(--spacing-sm);
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--color-error);
    background: none;
    border: 1px solid var(--color-error);
    border-radius: 4px;
    cursor: pointer;
}

/* The collapsed-section badge. Hidden until results-edit.js flags the
   section, so a failure the mediator scrolled past is still visible on the
   summary line. */
.save-failed-badge {
    display: none;
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

details.accordion-item--save-failed > .accordion-summary .save-failed-badge {
    display: inline;
}

/* [hidden] must win over the flex/contents display rules around it. */
#document-save-failure[hidden] {
    display: none;
}

.document-status {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: flex-end;
}

/* The out-of-band half of the header. display:contents makes the wrapper
   itself invisible to layout, so splitting the notices away from the Genereer
   button (which must never be swapped — see fragments/document_status.html)
   leaves the column flow, the gaps, and the right alignment exactly as they
   were, and an empty notices region adds no stray gap. */
.document-status__notices {
    display: contents;
}

.document-status__stale {
    margin: 0;
    font-size: var(--font-size-sm);
    color: #8a6d1f;
}

.document-status__error {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-error);
    /* The status region is right-aligned; cap the line length so the Dutch
       failure copy wraps into a readable block instead of one long line. */
    text-align: right;
    max-width: 44ch;
}

.results-intro {
    margin: 0 0 var(--spacing-lg);
    color: var(--color-text-light);
}

.expiry-note {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--color-muted);
}
