/* MediScribe AI v2 — Styles (Clinical Calm) */

:root {
    --bg: #ffffff;
    --surface: #fafafa;
    --surface-2: #f4f4f5;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --text-muted: #71717a;
    /* --accent is overridden by inline <style> in index.html from ACCENT_COLOR env var */
    --accent: #0f766e;
    --accent-soft: color-mix(in srgb, var(--accent) 8%, white);
    --accent-strong: color-mix(in srgb, var(--accent) 88%, black);
    --record: #b45309;
    --record-soft: #fffbeb;
    --record-border: #fde68a;
    --danger: #991b1b;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --radius: 10px;
    --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

.text-secondary-custom { color: var(--text-muted) !important; }

/* ---- Layout ---- */

.container-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
}

@media (min-width: 768px) {
    .container-main { max-width: 760px; padding: 3rem 1.5rem 5rem; }
}

/* ---- Logo ---- */

.customer-logo-section {
    text-align: center;
    margin: 1rem 0 2.5rem;
}

.customer-logo {
    max-height: 88px;
    max-width: 320px;
    object-fit: contain;
}

/* ---- Beta alert ---- */

.beta-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    margin-bottom: 2rem;
}

.beta-alert .beta-icon {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.beta-alert .beta-body { flex: 1; }

.beta-alert .beta-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
}

.beta-alert .beta-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Override Bootstrap's .btn-close (which uses an SVG background) so our
   Font Awesome icon child shows instead. */
.btn-close {
    background: none !important;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s ease;
    width: auto;
    height: auto;
    box-sizing: content-box;
}

.btn-close:hover {
    opacity: 1;
    color: var(--text);
}

.btn-close:focus { box-shadow: none; }

/* ---- Card primitive ---- */

.card-neutral {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.card-title .ico {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ---- Template Selection ---- */

.template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 600px) {
    .template-grid { grid-template-columns: 1fr 1fr; }
}

.template-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-card:hover {
    border-color: var(--border-strong);
}

.template-card.selected {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.template-card .template-icon {
    font-size: 1.125rem;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 0;
}

.template-card.selected .template-icon {
    background: var(--bg);
    color: var(--accent);
    border-color: var(--accent);
}

.template-card .template-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.template-card .template-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.template-card .template-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ---- Modal (Bootstrap modal restyled) ---- */

.modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}

.modal-header {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title .ico { color: var(--text-muted); }

.modal-body { padding: 1.5rem; }

.modal-intro {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-intro h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.modal-intro p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.modal-instructions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.625rem;
}

@media (min-width: 600px) {
    .modal-instructions { grid-template-columns: 1fr 1fr; }
    .modal-instructions .full-row { grid-column: 1 / -1; }
}

.instruction-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.instruction-card .num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.125rem;
}

.instruction-card .ic-body { flex: 1; }

.instruction-card h6 {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    color: var(--text);
}

.instruction-card p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.tip-card {
    margin-top: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.tip-card strong { color: var(--text); font-weight: 600; }

.tip-card .ico { color: var(--text-muted); margin-top: 0.2rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    border: 1px solid transparent;
    font-family: inherit;
    line-height: 1.2;
}

.btn-primary-neutral {
    background: var(--text);
    color: var(--bg);
}

.btn-primary-neutral:hover { background: #000; color: var(--bg); }

.btn-secondary-neutral {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary-neutral:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

/* ---- Voice Interface ---- */

.voice-interface {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.voice-interface .vi-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.voice-interface .vi-sub {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.template-instructions {
    margin-bottom: 1.5rem;
    text-align: center;
}

.template-instructions:empty { display: none; }

.step-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
}

.step-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
    padding: 0.375rem 0.75rem 0.375rem 0.4375rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    transition: border-color 0.15s ease;
}

.step-chip:hover { border-color: var(--border-strong); }

.step-chip .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.template-hint-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.record-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg);
    border: 1.5px solid var(--text);
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0.75rem auto 1rem;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.record-button:hover { background: var(--surface); }

.record-button.recording {
    background: var(--record);
    border-color: var(--record);
    color: white;
    animation: pulse-soft 2s ease-in-out infinite;
}

@keyframes pulse-soft {
    0%, 100% { box-shadow: 0 0 0 0 rgba(180, 83, 9, 0.25); }
    50% { box-shadow: 0 0 0 8px rgba(180, 83, 9, 0); }
}

/* ---- Waveform ---- */

.waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
    margin: 0.5rem 0 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.waveform.active { opacity: 1; }

.wave-bar {
    width: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    height: 6px;
    animation: wave-soft 1.2s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.15s; }
.wave-bar:nth-child(5) { animation-delay: 0s; }
.wave-bar:nth-child(6) { display: none; }
.wave-bar:nth-child(7) { display: none; }

@keyframes wave-soft {
    0%, 100% { height: 6px; }
    50% { height: 18px; }
}

/* ---- Recording Status ---- */

.recording-status {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin: 0.5rem auto 0;
    display: inline-block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.recording-status.recording {
    background: var(--record-soft);
    border-color: var(--record-border);
    color: var(--record);
}

.recording-status .recording-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--record);
    display: inline-block;
    margin-right: 0.5rem;
    vertical-align: middle;
    animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ---- Progress ---- */

.progress-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin: 1.25rem 0;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    height: 1px;
    background: var(--border);
    z-index: 1;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    z-index: 2;
    gap: 0.5rem;
}

.step-circle {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.step-circle .step-num {
    transition: opacity 0.2s ease;
}

.step-circle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Current (active but not yet completed) step gets a slow pulse */
.step-circle.active:not(.completed)::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: step-pulse 1.6s ease-out infinite;
    pointer-events: none;
}

@keyframes step-pulse {
    0%   { transform: scale(0.85); opacity: 0.55; }
    70%  { transform: scale(1.15); opacity: 0;    }
    100% { transform: scale(1.15); opacity: 0;    }
}

/* Completed steps show a checkmark instead of the number */
.step-circle.completed .step-num { opacity: 0; }

.step-circle.completed::before {
    content: "✓";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

.step-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 500;
    transition: color 0.2s ease;
}

.step-item.active .step-text { color: var(--text); }

.progress-bar-track {
    position: relative;
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    position: relative;
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
    overflow: hidden;
}

/* Subtle moving sheen across the filled portion for extra "alive" feedback */
.progress-bar-fill::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0)   0%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(255, 255, 255, 0)   100%
    );
    animation: progress-sheen 2.2s linear infinite;
}

@keyframes progress-sheen {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%);  }
}

@media (prefers-reduced-motion: reduce) {
    .progress-bar-fill::after { animation: none; display: none; }
    .step-circle.active:not(.completed)::after { animation: none; display: none; }
}

.progress-status {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

/* ---- Results ---- */

.result-text-box {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    font-family: inherit;
}

/* Field list (Avvikelse 5-field result) */
.field-list {
    display: flex;
    flex-direction: column;
}

.field-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

.field-row:first-child { padding-top: 0; }
.field-row:last-child { padding-bottom: 0; border-bottom: none; }

.field-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding-top: 0.125rem;
}

.field-value {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.55;
    white-space: pre-wrap;
}

@media (max-width: 599px) {
    .field-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

.result-footer-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
}

/* ---- Timer / Error ---- */

.timer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: var(--text);
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
    align-self: stretch;
}

.timer-card .ico { color: var(--text-muted); margin-top: 0.2rem; }

.timer-card strong { font-weight: 600; }

.timer-card .timer-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.timer-card.warning {
    background: var(--record-soft);
    border-color: var(--record-border);
}

.timer-card.warning strong { color: var(--record); }

.error-card {
    background: var(--danger-soft);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.error-card .ico {
    color: var(--danger);
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.error-card .err-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.error-card .err-msg {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* ---- Footer ---- */

.footer-section {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
}

.footer-section .powered {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
}

.footer-section .brand {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.25rem 0 0;
}

.footer-section .brand .beta-tag {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.0625rem 0.375rem;
    margin-left: 0.375rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
