/* ── MRM Staff Frontend Styles ─────────────────────────────────────── */

/* Staff header: practice selector + nav tabs */
.co-mrm-staff-header { margin-bottom: 20px; }
.co-mrm-practice-selector { margin-bottom: 12px; }
.co-mrm-practice-selector label { font-weight: 600; margin-right: 6px; }
.co-mrm-practice-selector select { font-size: 14px; padding: 4px 8px; }

.co-mrm-staff-nav { display: flex; gap: 0; border-bottom: 2px solid #ddd; margin-bottom: 16px; }
.co-mrm-nav-tab {
    padding: 8px 16px;
    text-decoration: none;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.co-mrm-nav-tab:hover { color: #1A3A5C; border-bottom-color: #aaa; }
.co-mrm-nav-active { color: #1A3A5C; border-bottom-color: #1A3A5C; font-weight: 600; }

/* Frontend wrapper — override WP admin styles for frontend context */
.co-mrm-frontend { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.co-mrm-frontend .wrap { margin: 0; padding: 0; }
.co-mrm-frontend h1 { font-size: 22px; margin: 0 0 16px; }
.co-mrm-frontend h2 { font-size: 18px; margin: 16px 0 8px; }

/* Tables — replicate WP admin table styles for frontend */
.co-mrm-frontend .widefat { width: 100%; border-collapse: collapse; border: 1px solid #ddd; border-radius: 4px; }
.co-mrm-frontend .widefat th { background: #f5f5f5; font-weight: 600; font-size: 12px; text-transform: uppercase; color: #555; padding: 8px 10px; text-align: left; border-bottom: 1px solid #ddd; }
.co-mrm-frontend .widefat td { padding: 8px 10px; border-bottom: 1px solid #eee; font-size: 13px; vertical-align: middle; }
.co-mrm-frontend .widefat.striped tr:nth-child(even) td { background: #fafafa; }
.co-mrm-frontend .widefat tr:hover td { background: #f7f9fc; }

/* Form tables */
.co-mrm-frontend .form-table { width: 100%; }
.co-mrm-frontend .form-table th { font-weight: 600; padding: 10px 10px 10px 0; vertical-align: top; width: 200px; font-size: 13px; }
.co-mrm-frontend .form-table td { padding: 10px 0; }
.co-mrm-frontend .form-table input[type="text"],
.co-mrm-frontend .form-table input[type="email"],
.co-mrm-frontend .form-table input[type="number"],
.co-mrm-frontend .form-table input[type="date"],
.co-mrm-frontend .form-table input[type="url"],
.co-mrm-frontend .form-table select,
.co-mrm-frontend .form-table textarea { font-size: 13px; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; }
.co-mrm-frontend .regular-text { width: 300px; max-width: 100%; }
.co-mrm-frontend .large-text { width: 100%; max-width: 600px; }

/* Buttons */
.co-mrm-frontend .button { display: inline-block; padding: 6px 14px; font-size: 13px; border: 1px solid #ccc; border-radius: 4px; background: #f7f7f7; color: #333; cursor: pointer; text-decoration: none; }
.co-mrm-frontend .button:hover { background: #eee; }
.co-mrm-frontend .button-primary { background: #1A3A5C; color: #fff; border-color: #1A3A5C; }
.co-mrm-frontend .button-primary:hover { background: #0f2a44; }
.co-mrm-frontend .button-small { padding: 3px 8px; font-size: 12px; }

/* Bucket tabs (queue + dashboard pages)
   Inline style="border-bottom:3px solid <bucket-color>" is rendered on each
   bucket tab so the colored underline persists in both states. The active
   tab is distinguished by background fill + bold text (the inline border
   then appears as a colored 3px stripe across the bottom of the fill). */
.co-mrm-frontend .co-mrm-buckets { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid #d0d4d8; }
.co-mrm-frontend .co-bucket { padding: 8px 16px; text-decoration: none; color: #555; font-size: 13px; border-bottom: 3px solid transparent; border-radius: 4px 4px 0 0; margin-bottom: -1px; transition: background-color .12s, color .12s; }
.co-mrm-frontend .co-bucket:hover { color: #1A3A5C; background: #eef2f6; }
.co-mrm-frontend .co-bucket-active,
.co-mrm-frontend .co-bucket-active:hover {
    color: #fff;
    background: #1A3A5C;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

/* Notices */
.co-mrm-notice { padding: 12px 16px; border-radius: 4px; background: #f0f0f0; margin-bottom: 12px; }
.co-mrm-error { background: #fce4e4; color: #a00; }
.co-mrm-frontend .notice { padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; }
.co-mrm-frontend .notice-success { background: #ecfdf5; color: #065f46; border-left: 4px solid #10b981; }
.co-mrm-frontend .notice-error { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; }

/* Description text */
.co-mrm-frontend .description { color: #666; font-size: 12px; }

/* Checkbox alignment */
.co-mrm-frontend input[type="checkbox"] { margin-right: 4px; }

/* Request detail page — collapsible cards */
.co-mrm-collapsible {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 12px;
    padding: 0;
}
.co-mrm-collapsible > summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 14px;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1A3A5C;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 4px;
}
.co-mrm-collapsible > summary::-webkit-details-marker { display: none; }
.co-mrm-collapsible > summary::marker { content: ""; }
.co-mrm-collapsible > summary::before {
    content: "▶";
    font-size: 10px;
    color: #888;
    transition: transform .15s ease;
    display: inline-block;
    width: 10px;
}
.co-mrm-collapsible[open] > summary::before { transform: rotate(90deg); }
.co-mrm-collapsible[open] > summary { border-bottom: 1px solid #eee; border-radius: 4px 4px 0 0; }
.co-mrm-collapsible > summary:hover { background: #f7f9fc; }
.co-mrm-collapsible-body { padding: 12px 14px 14px; }
.co-mrm-collapsible-body > :first-child { margin-top: 0; }
.co-mrm-collapsible-body > :last-child  { margin-bottom: 0; }

/* Always-visible "basic details" card */
.co-mrm-card-primary {
    background: #fff;
    border: 1px solid #c8d6e5;
    border-left: 4px solid #1A3A5C;
    border-radius: 4px;
    padding: 14px 16px;
    margin-bottom: 16px;
}
.co-mrm-card-primary > h2 {
    margin: 0 0 10px;
    font-size: 16px;
    color: #1A3A5C;
}

/* ── Detail page — billing-style header + cards (2026-05-10) ───────── */
.co-mrm-admin {
    --co-mrm-primary:     #2563eb;
    --co-mrm-primary-dark:#1d4ed8;
    --co-mrm-success:     #16a34a;
    --co-mrm-warning:     #d97706;
    --co-mrm-danger:      #dc2626;
    --co-mrm-bg:          #f9fafb;
    --co-mrm-card-bg:     #ffffff;
    --co-mrm-border:      #e5e7eb;
    --co-mrm-text:        #111827;
    --co-mrm-text-muted:  #6b7280;
    --co-mrm-radius:      8px;
    --co-mrm-shadow:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--co-mrm-text);
}

/* Header — patient name dominant, request UID + meta as a sub-line */
.co-mrm-detail-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 18px;
    padding: 0;
}
.co-mrm-detail-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--co-mrm-text);
    line-height: 1.2;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
}
.co-mrm-detail-dob {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--co-mrm-text-muted);
}
.co-mrm-detail-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--co-mrm-text-muted);
}
.co-mrm-detail-uid {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    color: #374151;
    background: #f3f4f6;
    border-radius: 3px;
    padding: 1px 8px;
    font-size: 0.78rem;
}
.co-mrm-detail-sep { color: #d1d5db; }

/* Cards — billing aesthetic. Apply to .co-mrm-card AND restyle existing
   .co-mrm-card-primary so the whole detail page reads consistently. */
.co-mrm-admin .co-mrm-card,
.co-mrm-admin .co-mrm-card-primary {
    background: var(--co-mrm-card-bg);
    border: 1px solid var(--co-mrm-border);
    border-left: 1px solid var(--co-mrm-border);
    border-radius: var(--co-mrm-radius);
    box-shadow: var(--co-mrm-shadow);
    padding: 18px 22px;
    margin-bottom: 16px;
}
.co-mrm-admin .co-mrm-card > h2,
.co-mrm-admin .co-mrm-card-primary > h2 {
    margin: 0 0 12px;
    font-size: 1rem;
    color: var(--co-mrm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.co-mrm-admin .co-mrm-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.co-mrm-admin .co-mrm-card-head h2 {
    margin: 0;
    font-size: 1rem;
    color: var(--co-mrm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.co-mrm-admin .co-mrm-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Collapsible sections — restyle existing <details> to match card aesthetic */
.co-mrm-admin .co-mrm-collapsible {
    background: var(--co-mrm-card-bg);
    border: 1px solid var(--co-mrm-border);
    border-radius: var(--co-mrm-radius);
    box-shadow: var(--co-mrm-shadow);
    margin-bottom: 14px;
}
.co-mrm-admin .co-mrm-collapsible > summary {
    padding: 14px 22px;
    color: var(--co-mrm-text);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
/* Green "has content" dot on the right of the summary bar (billing-parity).
   Applied per-accordion in PHP via .co-mrm-has-content. Absolute-positioned so
   it shows regardless of the summary's flex/list-item display (themes vary). */
.co-mrm-admin .co-mrm-collapsible.co-mrm-has-content > summary { position: relative; }
.co-mrm-admin .co-mrm-collapsible.co-mrm-has-content > summary::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--co-mrm-success);
    box-shadow: 0 0 0 2px rgba(22,163,74,.18);
}
.co-mrm-admin .co-mrm-collapsible > summary:hover { background: var(--co-mrm-bg); border-radius: var(--co-mrm-radius); }
.co-mrm-admin .co-mrm-collapsible[open] > summary { border-bottom: 1px solid var(--co-mrm-border); border-radius: var(--co-mrm-radius) var(--co-mrm-radius) 0 0; }
.co-mrm-admin .co-mrm-collapsible-body { padding: 16px 22px 18px; }

/* Patient Information card — primary card with the match dropdown */
.co-mrm-admin .co-mrm-patient-card { border-left: 4px solid var(--co-mrm-primary); }

/* Info table — replace cramped wp-admin look */
.co-mrm-admin .co-mrm-info-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.co-mrm-admin .co-mrm-info-table th { width: 140px; text-align: left; color: var(--co-mrm-text-muted); padding: 6px 8px 6px 0; vertical-align: top; font-weight: 500; font-size: 0.85rem; }
.co-mrm-admin .co-mrm-info-table td { padding: 6px 0; }
.co-mrm-admin .co-mrm-info-table a { color: var(--co-mrm-primary); }

/* Form controls inside the patient card */
.co-mrm-admin .co-mrm-form-group { margin-bottom: 14px; }
.co-mrm-admin .co-mrm-label-muted { display: block; font-size: 0.82rem; color: var(--co-mrm-text-muted); margin-bottom: 4px; }
.co-mrm-admin .co-mrm-select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--co-mrm-border);
    border-radius: var(--co-mrm-radius);
    font-size: 0.9rem;
    color: var(--co-mrm-text);
    background: #fff;
}
.co-mrm-admin .co-mrm-select:focus { outline: none; border-color: var(--co-mrm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* Badges */
.co-mrm-admin .co-mrm-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.co-mrm-admin .co-mrm-badge-linked    { background: #d1fae5; color: #065f46; }
.co-mrm-admin .co-mrm-badge-unmatched { background: #fef3c7; color: #92400e; }

/* Inline messages */
.co-mrm-admin .co-mrm-inline-msg { font-size: 0.85rem; padding: 6px 10px; border-radius: 4px; }
.co-mrm-admin .co-mrm-inline-msg.success { background: #d1fae5; color: #065f46; }
.co-mrm-admin .co-mrm-inline-msg.error   { background: #fee2e2; color: #991b1b; }

/* Modal — for Search Patient Records.
   Top-aligned (align-items: flex-start) so the header and close-X stay
   in view when the result table grows past viewport height. Overlay
   scrolls vertically; the modal itself stays a normal-flow block so
   long lists scroll naturally inside the page. */
.co-mrm-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9999;
    display: flex; align-items: flex-start; justify-content: center;
    overflow-y: auto;
    padding: 40px 16px;
}
.co-mrm-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 680px;
    max-width: 95vw;
    overflow: visible;
}
.co-mrm-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--co-mrm-border); }
.co-mrm-modal-head h2 { margin: 0; font-size: 1.05rem; }
.co-mrm-modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: #6b7280; line-height: 1; }
.co-mrm-modal-close:hover { color: #111827; }
.co-mrm-modal-body { padding: 20px 22px; }
.co-mrm-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--co-mrm-border); background: var(--co-mrm-bg); }
.co-mrm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.co-mrm-form-grid label { display: flex; flex-direction: column; font-size: 0.82rem; color: var(--co-mrm-text-muted); gap: 4px; }
.co-mrm-form-grid input { padding: 8px 10px; border: 1px solid var(--co-mrm-border); border-radius: var(--co-mrm-radius); font-size: 0.9rem; }
.co-mrm-form-grid input:focus { outline: none; border-color: var(--co-mrm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
@media (max-width: 600px) { .co-mrm-form-grid { grid-template-columns: 1fr; } }

/* Buttons inside the .co-mrm-admin context — keep existing wp .button shape
   but bump the primary blue to match the new accent. */
.co-mrm-admin .button-primary,
.co-mrm-admin button.button-primary {
    background: var(--co-mrm-primary);
    border-color: var(--co-mrm-primary);
}
.co-mrm-admin .button-primary:hover { background: var(--co-mrm-primary-dark); border-color: var(--co-mrm-primary-dark); }

/* Packet assembly — sortable list */
.co-sortable-list { list-style: none; padding: 0; margin: 0 0 16px; }
.co-sortable-list li { padding: 8px 12px; margin: 4px 0; background: #f9f9f9; border: 1px solid #ddd; border-radius: 3px; display: flex; align-items: center; gap: 8px; cursor: default; }
.co-sortable-list .dashicons-move { cursor: grab; color: #999; }
.co-sortable-list li.ui-sortable-helper { box-shadow: 0 2px 8px rgba(0,0,0,.15); background: #fff; }
.co-sortable-placeholder { height: 38px; border: 2px dashed #ccc; border-radius: 3px; margin: 4px 0; background: #f5f5f5; }
.co-sort-badge { margin-left: auto; font-size: 11px; color: #888; background: #eee; padding: 1px 6px; border-radius: 2px; }

/* ── Text input (matches .co-mrm-select) + inline form row (v1.31.0) ────────── */
.co-mrm-admin .co-mrm-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--co-mrm-border);
    border-radius: var(--co-mrm-radius);
    font-size: 0.9rem;
    color: var(--co-mrm-text);
    background: #fff;
}
.co-mrm-admin .co-mrm-input:focus { outline: none; border-color: var(--co-mrm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.co-mrm-admin .co-mrm-form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Messages card — inline thread + composer (v1.31.0, billing-parity) ─────── */
.co-mrm-admin .co-mrm-thread {
    max-height: 360px;
    overflow-y: auto;
    padding: 4px 2px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.co-mrm-admin .co-mrm-thread-empty { color: var(--co-mrm-text-muted); font-size: 0.9rem; margin: 8px 0; }
.co-mrm-admin .co-mrm-msg { max-width: 80%; padding: 8px 12px; border-radius: 10px; font-size: 0.9rem; line-height: 1.4; }
.co-mrm-admin .co-mrm-msg-inbound  { align-self: flex-start; background: #f1f5f9; border: 1px solid var(--co-mrm-border); border-bottom-left-radius: 2px; }
.co-mrm-admin .co-mrm-msg-outbound { align-self: flex-end;   background: #e0edff; border: 1px solid #c7dbfb; border-bottom-right-radius: 2px; }
.co-mrm-admin .co-mrm-msg-meta { font-size: 0.72rem; color: var(--co-mrm-text-muted); margin-bottom: 3px; }
.co-mrm-admin .co-mrm-msg-subject { font-weight: 600; font-size: 0.82rem; margin-bottom: 2px; }
.co-mrm-admin .co-mrm-msg-body { white-space: pre-wrap; word-break: break-word; }
.co-mrm-admin .co-mrm-msg-count { font-size: 0.8rem; font-weight: 400; color: var(--co-mrm-text-muted); }

.co-mrm-admin .co-mrm-send-form { border-top: 1px solid var(--co-mrm-border); padding-top: 12px; }
.co-mrm-admin .co-mrm-channel-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.co-mrm-admin .co-mrm-channel-tab {
    padding: 5px 14px;
    border: 1px solid var(--co-mrm-border);
    background: #fff;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--co-mrm-text-muted);
}
.co-mrm-admin .co-mrm-channel-tab:hover:not(:disabled) { border-color: var(--co-mrm-primary); color: var(--co-mrm-primary); }
.co-mrm-admin .co-mrm-channel-tab.active { background: var(--co-mrm-primary); border-color: var(--co-mrm-primary); color: #fff; }
.co-mrm-admin .co-mrm-channel-tab:disabled { opacity: .5; cursor: not-allowed; }
