/**
 * NHFM Demo
 * NHS Blue: #005eb8, Dark Blue: #003087, Green: #007f3b, Red: #da291c
 */

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

:root {
    --nhs-blue: #005eb8;
    --nhs-dark-blue: #003087;
    --nhs-light-blue: #41b6e6;
    --nhs-green: #007f3b;
    --nhs-red: #da291c;
    --nhs-yellow: #ffb81c;
    --nhs-grey: #425563;
    --nhs-pale-grey: #e8edee;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: #231f20;
    background: var(--nhs-pale-grey);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
.app-header {
    background: var(--nhs-blue);
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nhs-logo {
    background: #fff;
    color: var(--nhs-blue);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.875rem;
}

.header-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-play {
    background: var(--nhs-green);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-play:hover { background: #006633; }
.btn-play:disabled { background: #768692; cursor: not-allowed; }

.btn-play .play-icon {
    width: 0;
    height: 0;
    border-left: 10px solid #fff;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.btn-play .pause-icon {
    width: 12px;
    height: 12px;
    display: flex;
    gap: 3px;
}

.btn-play .pause-icon::before,
.btn-play .pause-icon::after {
    content: '';
    width: 4px;
    height: 12px;
    background: #fff;
}

.btn-play.playing {
    background: #da291c;
}

.btn-play.playing:hover {
    background: #b71c1c;
}

.btn-play.paused {
    background: var(--nhs-green);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 123, 77, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(0, 123, 77, 0); }
}

.btn-reset {
    background: transparent;
    border: 2px solid #fff;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset:hover { background: #fff; color: var(--nhs-blue); }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Progress Sidebar */
.progress-sidebar {
    width: 260px;
    background: var(--nhs-dark-blue);
    color: #fff;
    padding: 24px;
    overflow-y: auto;
}

.progress-sidebar h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 24px;
    opacity: 0.7;
}

.phase-list { list-style: none; }

.phase-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    opacity: 0.4;
    transition: all 0.3s;
}

.phase-item.active { opacity: 1; }
.phase-item.completed { opacity: 0.7; }

.phase-indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.phase-item.active .phase-indicator {
    background: var(--nhs-light-blue);
    border-color: var(--nhs-light-blue);
    color: var(--nhs-dark-blue);
}

.phase-item.completed .phase-indicator {
    background: var(--nhs-green);
    border-color: var(--nhs-green);
}

.phase-content h3 { font-size: 0.938rem; margin-bottom: 2px; }
.phase-content p { font-size: 0.75rem; opacity: 0.7; }

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.phase-container {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.phase-container.active { display: flex; }

.phase-header {
    padding: 20px 24px;
    background: var(--nhs-pale-grey);
    border-bottom: 1px solid #ddd;
}

.phase-header h2 {
    font-size: 1.25rem;
    color: var(--nhs-dark-blue);
    margin-bottom: 4px;
}

.phase-header p {
    color: var(--nhs-grey);
    font-size: 0.875rem;
}

.clinician-badge {
    display: inline-block;
    background: var(--nhs-dark-blue);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.phase-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

/* Fade overlay for Phase 1 patient list */
#phase-1 .phase-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.9) 60%, #fff);
    pointer-events: none;
}

/* Phase 1: Patient List */
.patient-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 700px;
    position: relative;
}

.patient-row {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background: var(--nhs-pale-grey);
    border-radius: 6px;
    border-left: 4px solid transparent;
    transition: all 0.3s;
}

.patient-row.scanning {
    border-left-color: var(--nhs-yellow);
    background: #fff8e6;
}

.patient-row.scanned { border-left-color: var(--nhs-green); }

.patient-row.flagged {
    border-left-color: var(--nhs-red);
    background: #fef2f2;
}

.patient-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #768692;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.813rem;
    margin-right: 14px;
}

.patient-info { flex: 1; min-width: 0; }
.patient-info h4 { font-size: 0.938rem; font-weight: 600; }
.patient-info p { font-size: 0.813rem; color: var(--nhs-grey); }

.patient-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.patient-meta {
    font-size: 0.75rem;
    color: #768692;
    font-weight: 400;
    white-space: nowrap;
}

.patient-summary {
    margin-bottom: 2px;
}

.patient-conditions {
    font-size: 0.7rem;
    color: #8b9ba5;
    font-style: italic;
    margin-top: 2px;
}

.scan-result {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--nhs-grey);
}

.scan-result.alert {
    color: var(--nhs-red);
    font-weight: 600;
}

.action-required {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--nhs-blue);
    font-weight: 500;
    font-style: italic;
}

.patient-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.patient-status.pending { background: #e8edee; color: #768692; }
.patient-status.scanning { background: var(--nhs-yellow); color: #000; }
.patient-status.ok { background: #d4edda; color: var(--nhs-green); }
.patient-status.flagged { background: var(--nhs-red); color: #fff; }

/* Ghost patients for infinite scroll illusion */
.patient-row.ghost-patient {
    opacity: 0.6;
}

.patient-row.ghost-patient:nth-child(n+27) {
    opacity: 0.45;
}

.patient-row.ghost-patient:nth-child(n+29) {
    opacity: 0.3;
}

.patient-row.ghost-patient:nth-child(n+31) {
    opacity: 0.15;
}

.patient-row.ghost-patient:last-child {
    opacity: 0.08;
}


/* Phase 2: Chat */
.warning-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: #856404;
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 650px;
}

.chat-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.45s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.patient { flex-direction: row-reverse; }

.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.688rem;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-message.assistant .chat-avatar { background: var(--nhs-blue); color: #fff; }
.chat-message.patient .chat-avatar { background: #768692; color: #fff; }

.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.938rem;
}

.chat-message.assistant .chat-bubble {
    background: var(--nhs-pale-grey);
    border-bottom-left-radius: 4px;
}

.chat-message.patient .chat-bubble {
    background: var(--nhs-light-blue);
    border-bottom-right-radius: 4px;
}

.chat-message.outcome .chat-bubble {
    background: linear-gradient(135deg, #e8f4ea 0%, var(--nhs-pale-grey) 100%);
    border-left: 3px solid #007f3b;
}

.chat-message.response .chat-bubble {
    background: var(--nhs-light-blue);
    border-bottom-right-radius: 4px;
}

/* Chat action buttons */
.chat-response-buttons {
    display: flex;
    gap: 8px;
    padding: 8px 44px;
    animation: fadeIn 0.45s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.chat-action-btn {
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.chat-action-btn.primary {
    background: #fff;
    color: var(--nhs-blue);
    border: 2px solid var(--nhs-blue);
}

.chat-action-btn.primary:hover {
    background: var(--nhs-pale-grey);
}

.chat-action-btn.secondary {
    background: #fff;
    color: var(--nhs-blue);
    border: 1px solid var(--nhs-blue);
}

.chat-action-btn.secondary:hover {
    background: var(--nhs-pale-grey);
}

.chat-action-btn.clicked {
    transform: scale(0.95);
    background: var(--nhs-blue);
    color: #fff;
}

.chat-action-btn.primary.selected {
    background: var(--nhs-blue);
    color: #fff;
    border-color: var(--nhs-blue);
    cursor: default;
    pointer-events: none;
}

.chat-action-btn.secondary.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--nhs-pale-grey);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #768692;
    border-radius: 50%;
    animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* iPhone Overlay */
.iphone-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.iphone-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
}

.iphone-mockup {
    width: 320px;
    height: 650px;
    background: #1a1a1a;
    border-radius: 45px;
    padding: 12px;
    box-shadow:
        0 0 0 3px #1a1a1a,
        0 0 0 6px #333,
        0 20px 40px rgba(0,0,0,0.3);
    position: relative;
    transform: scale(0);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.iphone-mockup.visible {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

.iphone-screen {
    background: #fff;
    border-radius: 35px;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.iphone-notch {
    height: 30px;
    background: #1a1a1a;
    border-radius: 0 0 20px 20px;
    width: 120px;
    margin: 0 auto;
    position: relative;
}

.iphone-notch::before {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: #333;
    border-radius: 50%;
    top: 10px;
    right: 25px;
}

.nhs-app-bar {
    background: var(--nhs-blue);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nhs-app-bar .nhs-logo-small {
    background: #fff;
    color: var(--nhs-blue);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.625rem;
    font-weight: 700;
}

.nhs-app-bar span {
    font-size: 0.875rem;
    font-weight: 500;
}

.iphone-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f5f5f5;
}

.iphone-chat-area .chat-container {
    max-width: 100%;
    gap: 10px;
}

.iphone-chat-area .chat-message {
    gap: 8px;
}

.iphone-chat-area .chat-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.563rem;
}

.iphone-chat-area .chat-bubble {
    font-size: 0.813rem;
    padding: 10px 12px;
    max-width: 85%;
}

.iphone-chat-area .typing-indicator {
    padding: 10px 12px;
}

.iphone-chat-area .typing-indicator span {
    width: 6px;
    height: 6px;
}

.iphone-chat-area .chat-response-buttons {
    padding: 6px 36px;
    flex-wrap: wrap;
}

.iphone-chat-area .chat-action-btn {
    padding: 8px 12px;
    font-size: 0.75rem;
    border-radius: 16px;
}

.iphone-warning {
    background: #fff3cd;
    padding: 8px 12px;
    font-size: 0.688rem;
    color: #856404;
    border-bottom: 1px solid #ffc107;
}

.iphone-home-indicator {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.iphone-home-indicator::before {
    content: "";
    width: 100px;
    height: 4px;
    background: #1a1a1a;
    border-radius: 2px;
}

/* Phase 3: Clinician Review */
.clinician-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
}

/* Patient Summary */
.patient-summary {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 18px;
}

.patient-summary h3 {
    font-size: 1rem;
    color: var(--nhs-dark-blue);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--nhs-blue);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.summary-item label {
    display: block;
    font-size: 0.688rem;
    color: #768692;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.summary-item span { font-weight: 500; font-size: 0.875rem; }
.summary-item.full-width { grid-column: 1 / -1; }

.summary-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.summary-list li {
    background: var(--nhs-pale-grey);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.summary-list li.flagged {
    background: #fef2f2;
    color: var(--nhs-red);
    border: 1px solid var(--nhs-red);
}

.labs-table {
    width: 100%;
    font-size: 0.75rem;
    margin-top: 6px;
    border-collapse: collapse;
}

.labs-table th, .labs-table td {
    text-align: left;
    padding: 5px 8px;
}

.labs-table th { background: var(--nhs-pale-grey); color: var(--nhs-grey); }
.labs-table .flag-low, .labs-table .flag-high { color: var(--nhs-red); font-weight: 600; }

/* Review Sections */
.review-section {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
}

.issue-section {
    border: 2px solid var(--nhs-red);
    background: linear-gradient(135deg, #fff 0%, #fef8f8 100%);
}

.actions-section {
    border: 2px solid var(--nhs-blue);
    background: linear-gradient(135deg, #fff 0%, #f5f9fc 100%);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8edee;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.issue-section .section-header h3 {
    color: var(--nhs-red);
}

.actions-section .section-header h3 {
    color: var(--nhs-blue);
}

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

.section-icon.issue-icon {
    background: var(--nhs-red);
    color: #fff;
}

.section-icon.actions-icon {
    background: var(--nhs-blue);
    color: #fff;
    font-size: 1rem;
}

.actions-count {
    margin-left: auto;
    background: var(--nhs-pale-grey);
    color: var(--nhs-grey);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.actions-count.all-approved {
    background: #d4edda;
    color: var(--nhs-green);
}

/* Issue Card */
.issue-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
}

.issue-card h3 {
    font-size: 0.938rem;
    color: var(--nhs-dark-blue);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.issue-card h3::before {
    display: none;
}

.issue-description {
    font-size: 0.875rem;
    color: var(--nhs-grey);
    margin-bottom: 14px;
}

.evidence-list {
    list-style: none;
    margin-bottom: 16px;
}

.evidence-list li {
    font-size: 0.813rem;
    color: var(--nhs-grey);
    padding: 4px 0 4px 18px;
    position: relative;
}

.evidence-list li::before {
    content: "•";
    position: absolute;
    left: 4px;
    color: var(--nhs-blue);
}

.evidence-source {
    font-size: 0.7rem;
    color: var(--nhs-light-blue);
    font-style: italic;
    margin-left: 4px;
}

.decision-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.decision-buttons button {
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-agree {
    background: var(--nhs-green);
    color: #fff;
}

.btn-agree:hover { background: #006633; }

.btn-reject-decision {
    background: var(--nhs-red);
    color: #fff;
}

.btn-reject-decision:hover { background: #b82318; }

.btn-modify {
    background: var(--nhs-yellow);
    color: #000;
}

.btn-modify:hover { background: #e6a619; }

.decision-status {
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.decision-status.agreed { background: var(--nhs-green); color: #fff; }
.decision-status.rejected { background: var(--nhs-red); color: #fff; }
.decision-status.modified { background: var(--nhs-yellow); color: #000; }

.reject-reason, .modify-input {
    margin-top: 12px;
    display: none;
}

.reject-reason.visible, .modify-input.visible { display: block; }

.reject-reason textarea, .modify-input textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: var(--font);
    font-size: 0.875rem;
    resize: none;
}

/* Modify Input Area (for action modifications) */
.modify-input-area {
    margin-top: 12px;
    padding: 14px;
    background: #fffef0;
    border: 1px solid var(--nhs-yellow);
    border-radius: 6px;
}

.modify-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--nhs-grey);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.modify-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--nhs-yellow);
    border-radius: 4px;
    font-family: var(--font);
    font-size: 0.875rem;
    resize: none;
    background: #fff;
}

.modify-textarea:focus {
    outline: none;
    border-color: var(--nhs-blue);
    box-shadow: 0 0 0 3px rgba(0, 94, 184, 0.15);
}

.modify-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.btn-cancel-modify {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #ddd;
    background: #fff;
    color: var(--nhs-grey);
    transition: all 0.2s;
}

.btn-cancel-modify:hover {
    background: var(--nhs-pale-grey);
}

.action-card.modifying {
    border-color: var(--nhs-yellow);
    border-left-color: var(--nhs-yellow);
    background: #fffef8;
}

/* Action Cards List */
.action-cards-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Action Cards */
.action-card {
    background: #fff;
    border: 1px solid #d0dde5;
    border-radius: 6px;
    padding: 16px;
    transition: all 0.3s;
    border-left: 4px solid var(--nhs-blue);
}

.action-card.approved {
    border-color: var(--nhs-green);
    border-left-color: var(--nhs-green);
    background: #f0fff4;
}

.action-card.rejected {
    border-color: var(--nhs-red);
    border-left-color: var(--nhs-red);
    background: #fef2f2;
    opacity: 0.6;
}

.action-card.modified {
    border-color: var(--nhs-green);
    border-left-color: var(--nhs-yellow);
    background: #fffef0;
}

.action-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.action-header h4 {
    font-size: 0.938rem;
    color: var(--nhs-dark-blue);
}

.impact-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.688rem;
    font-weight: 600;
    text-transform: uppercase;
}

.impact-badge.high { background: #fef2f2; color: var(--nhs-red); }
.impact-badge.medium { background: #fffbeb; color: #b45309; }

.action-rationale {
    font-size: 0.813rem;
    color: var(--nhs-grey);
    margin-bottom: 10px;
}

.message-preview {
    background: var(--nhs-pale-grey);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.813rem;
    margin-bottom: 14px;
    border-left: 3px solid var(--nhs-blue);
}

.message-preview-label {
    font-size: 0.688rem;
    color: #768692;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* Phase 4: Audit */
.audit-timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 700px;
    margin: 0 auto;
}

.audit-event {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 6px;
    border-left: 4px solid #768692;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.audit-event.new {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.audit-event.nhfm { border-left-color: var(--nhs-blue); }
.audit-event.clinician { border-left-color: var(--nhs-dark-blue); }
.audit-event.patient { border-left-color: var(--nhs-green); }

.audit-actor {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.audit-actor.nhfm { background: var(--nhs-blue); color: #fff; }
.audit-actor.clinician { background: var(--nhs-dark-blue); color: #fff; }
.audit-actor.patient { background: #d4edda; color: var(--nhs-green); }

.audit-text {
    flex: 1;
    font-size: 0.875rem;
    color: #212b32;
}

.audit-timestamp {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #768692;
    font-family: monospace;
}

/* Simulated Mouse Cursor */
.sim-cursor {
    position: fixed;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    opacity: 0;
}

.sim-cursor.visible { opacity: 1; }

.sim-cursor::before {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid var(--nhs-dark-blue);
    border-top: 5px solid transparent;
    border-bottom: 14px solid transparent;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.3));
}

.sim-cursor.clicking::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 94, 184, 0.3);
    animation: clickRipple 0.4s ease-out;
}

@keyframes clickRipple {
    from { transform: scale(0); opacity: 1; }
    to { transform: scale(1.5); opacity: 0; }
}

/* Status Bar */
.status-bar {
    padding: 12px 24px;
    background: var(--nhs-pale-grey);
    border-top: 1px solid #ddd;
    font-size: 0.875rem;
    color: var(--nhs-grey);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-bar .phase-indicator-text {
    font-weight: 500;
    color: var(--nhs-dark-blue);
}

/* Timeline Scrubber (in header) - Fine-grained 20 steps */
.timeline-container {
    display: flex;
    flex-direction: column;
    margin-right: 24px;
    gap: 4px;
}

.timeline-phases {
    display: flex;
    gap: 12px;
}

.timeline-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.phase-label {
    font-size: 0.625rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.phase-markers {
    display: flex;
    gap: 3px;
}

.timeline-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 0.25s ease;
}

.timeline-marker:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.3);
}

.timeline-marker.active {
    background: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.timeline-marker.completed {
    background: #007f3b;
}

.timeline-track {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
    margin-top: 2px;
}

.timeline-progress {
    height: 100%;
    background: #fff;
    border-radius: 1px;
    width: 0%;
    transition: width 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ========== Commentary Bubbles ========== */
.commentary-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.813rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.commentary-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.commentary-toggle.active {
    background: rgba(255, 255, 255, 0.95);
    color: var(--nhs-blue);
}

.commentary-toggle-icon {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.commentary-toggle-icon::before {
    content: "i";
    font-size: 0.625rem;
    font-weight: 700;
    font-style: italic;
}

/* Commentary Bubble */
.commentary-bubble {
    position: fixed;
    width: 320px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 48, 135, 0.25);
    border: 2px solid var(--nhs-blue);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.35s cubic-bezier(0.25, 0.1, 0.25, 1),
                visibility 0.35s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Fixed position on the right side */
.commentary-bubble.fixed-right {
    right: 30px;
    top: 120px;
}

.commentary-bubble.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.commentary-bubble-header {
    background: var(--nhs-blue);
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.commentary-bubble-header::before {
    content: "i";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #fff;
    color: var(--nhs-blue);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    font-style: italic;
    flex-shrink: 0;
}

.commentary-bubble-title {
    font-size: 0.938rem;
    font-weight: 600;
}

.commentary-bubble-body {
    padding: 14px 16px;
}

.commentary-bubble-text {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--nhs-grey);
    margin-bottom: 14px;
}

.commentary-next-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: var(--nhs-blue);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.commentary-next-btn:hover {
    background: var(--nhs-dark-blue);
}

/* Responsive adjustments for commentary */
@media (max-width: 1100px) {
    .commentary-bubble {
        width: 280px;
        right: 20px;
    }
}

@media (max-width: 900px) {
    .commentary-toggle span:last-child {
        display: none;
    }

    .commentary-bubble {
        width: 260px;
        right: 15px;
    }
}

/* Responsive */
@media (max-width: 1100px) {
    .timeline-phases { gap: 8px; }
    .phase-markers { gap: 2px; }
    .timeline-marker { width: 8px; height: 8px; }
    .phase-label { font-size: 0.563rem; }
}

@media (max-width: 900px) {
    .progress-sidebar { width: 200px; }
    .summary-grid { grid-template-columns: 1fr; }
    .timeline-container { display: none; }
}

/* Tablet */
@media (max-width: 768px) {
    .progress-sidebar { display: none; }

    .app-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .app-header h1 {
        font-size: 1.125rem;
        width: 100%;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .phase-body {
        padding: 16px;
    }

    .clinician-content {
        max-width: 100%;
    }

    .patient-list {
        max-width: 100%;
    }

    /* iPhone mockup smaller on tablet */
    .iphone-mockup {
        width: 280px;
        height: 560px;
    }
}

/* Mobile / iPhone */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .app-header {
        padding: 10px 12px;
    }

    .app-header h1 {
        font-size: 1rem;
        gap: 8px;
    }

    .nhs-logo {
        font-size: 0.75rem;
        padding: 3px 6px;
    }

    .header-controls {
        gap: 8px;
    }

    .btn-play {
        padding: 8px 14px;
        font-size: 0.875rem;
    }

    .btn-reset {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .commentary-toggle {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .phase-header {
        padding: 14px 16px;
    }

    .phase-header h2 {
        font-size: 1.1rem;
    }

    .phase-body {
        padding: 12px;
    }

    /* Patient rows */
    .patient-row {
        padding: 10px 12px;
    }

    .patient-avatar {
        width: 34px;
        height: 34px;
        font-size: 0.7rem;
        margin-right: 10px;
    }

    .patient-info h4 {
        font-size: 0.875rem;
    }

    .patient-meta {
        font-size: 0.688rem;
    }

    /* Review sections */
    .review-section {
        padding: 14px;
    }

    .section-header {
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .section-header h3 {
        font-size: 0.938rem;
    }

    .section-icon {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    /* Action cards */
    .action-card {
        padding: 12px;
    }

    .action-header h4 {
        font-size: 0.875rem;
    }

    .decision-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .decision-buttons button {
        width: 100%;
        padding: 12px;
    }

    /* iPhone mockup - much smaller or use native view */
    .iphone-mockup {
        width: 260px;
        height: 520px;
        border-radius: 35px;
        padding: 8px;
    }

    .iphone-screen {
        border-radius: 28px;
    }

    .iphone-chat-area .chat-bubble {
        font-size: 0.75rem;
        padding: 8px 10px;
    }

    /* Audit timeline */
    .audit-timeline {
        max-width: 100%;
    }

    .audit-event {
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .audit-actor {
        font-size: 0.688rem;
        padding: 2px 8px;
    }

    .audit-text {
        font-size: 0.813rem;
        flex-basis: 100%;
        order: 3;
        margin-top: 4px;
    }

    .audit-timestamp {
        font-size: 0.688rem;
        margin-left: auto;
    }

    /* Commentary bubble - full width on mobile */
    .commentary-bubble {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        max-height: 50vh;
        overflow-y: auto;
    }

    .commentary-bubble.fixed-right {
        right: 12px;
        left: 12px;
        top: auto;
        bottom: 12px;
    }

    .commentary-bubble-body {
        padding: 12px;
    }

    .commentary-bubble-text {
        font-size: 0.813rem;
        margin-bottom: 12px;
    }

    .commentary-next-btn {
        padding: 12px;
    }

    /* Status bar */
    .status-bar {
        padding: 10px 12px;
        font-size: 0.813rem;
    }

    /* Labs table scroll */
    .summary-item.full-width {
        overflow-x: auto;
    }

    .labs-table {
        min-width: 300px;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .app-header h1 {
        font-size: 0.938rem;
    }

    .iphone-mockup {
        width: 240px;
        height: 480px;
    }
}
