/* ============================================================
   GF BEO Billing Tracker — Frontend Styles
   ============================================================ */

:root {
    --beo-primary:     #2563eb;
    --beo-primary-dark:#1d4ed8;
    --beo-success:     #16a34a;
    --beo-danger:      #dc2626;
    --beo-warning:     #d97706;
    --beo-neutral:     #6b7280;
    --beo-bg:          #f9fafb;
    --beo-card-bg:     #ffffff;
    --beo-border:      #e5e7eb;
    --beo-text:        #111827;
    --beo-text-muted:  #6b7280;
    --beo-radius:      8px;
    --beo-shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Wrap ─────────────────────────────────────────────────── */
.beo-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--beo-text);
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ── Header ───────────────────────────────────────────────── */
.beo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.beo-header h1 { margin: 0; font-size: 1.6rem; }
.beo-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.beo-badge-count {
    background: var(--beo-primary);
    color: #fff;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: .85rem;
    font-weight: 600;
}
.beo-subhead { color: var(--beo-text-muted); margin-top: -8px; }
.beo-breadcrumb { margin-bottom: 16px; }
.beo-breadcrumb a { color: var(--beo-primary); text-decoration: none; font-size: .9rem; }
.beo-breadcrumb a:hover { text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────────── */
.beo-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--beo-radius);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.beo-btn-primary   { background: var(--beo-primary);   color: #fff; border-color: var(--beo-primary); }
.beo-btn-primary:hover { background: var(--beo-primary-dark); }
.beo-btn-secondary { background: #fff; color: var(--beo-primary); border-color: var(--beo-primary); }
.beo-btn-success   { background: var(--beo-success);   color: #fff; }
.beo-btn-danger    { background: var(--beo-danger);    color: #fff; }
.beo-btn-ghost     { background: transparent; color: var(--beo-neutral); border-color: var(--beo-border); }
.beo-btn-ghost:hover { background: var(--beo-bg); }
.beo-btn-sm        { padding: 4px 10px; font-size: .82rem; }
.beo-btn-lg        { padding: 11px 24px; font-size: 1rem; }
.beo-btn:disabled  { opacity: .55; cursor: not-allowed; }

/* ── Cards ────────────────────────────────────────────────── */
.beo-card {
    background: var(--beo-card-bg);
    border: 1px solid var(--beo-border);
    border-radius: var(--beo-radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--beo-shadow);
}
.beo-card h2 { margin: 0 0 12px; font-size: 1.2rem; }
.beo-card h3 { margin: 0 0 12px; font-size: 1rem; color: var(--beo-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.beo-card-resolved { border-left: 4px solid var(--beo-success); }

/* ── Filters ──────────────────────────────────────────────── */
.beo-filters { margin-bottom: 16px; }
.beo-filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.beo-filter-form select { padding: 7px 10px; border: 1px solid var(--beo-border); border-radius: var(--beo-radius); font-size: .9rem; }

/* ── Table ────────────────────────────────────────────────── */
.beo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    background: var(--beo-card-bg);
    border-radius: var(--beo-radius);
    overflow: hidden;
    box-shadow: var(--beo-shadow);
}
.beo-table thead th {
    background: var(--beo-bg);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--beo-text-muted);
    border-bottom: 1px solid var(--beo-border);
}
.beo-table tbody tr { border-bottom: 1px solid var(--beo-border); }
.beo-table tbody tr:last-child { border-bottom: none; }
.beo-table tbody tr:hover { background: var(--beo-bg); }
.beo-table td { padding: 10px 14px; vertical-align: middle; }
.beo-patient-name { font-weight: 600; color: var(--beo-primary); text-decoration: none; }
.beo-patient-name:hover { text-decoration: underline; }
.beo-dob { display: block; font-size: .78rem; color: var(--beo-text-muted); margin-top: 2px; }
.beo-email { color: var(--beo-primary); font-size: .85rem; text-decoration: none; }
.beo-date { font-size: .82rem; color: var(--beo-text-muted); white-space: nowrap; }
.beo-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Badges ───────────────────────────────────────────────── */
.beo-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.beo-badge-new      { background: #dbeafe; color: #1e40af; }
.beo-badge-open     { background: #d1fae5; color: #065f46; }
.beo-badge-warning  { background: #fef3c7; color: #92400e; }
.beo-badge-danger   { background: #fee2e2; color: #991b1b; }
.beo-badge-hold     { background: #f3f4f6; color: #374151; }
.beo-badge-resolved { background: #e0e7ff; color: #3730a3; }
.beo-badge-default  { background: #f3f4f6; color: #374151; }

/* Source tags */
.beo-source-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
}
.beo-source-gravity_form { background: #ede9fe; color: #5b21b6; }
.beo-source-voicemail    { background: #fef3c7; color: #78350f; }
.beo-source-portal       { background: #d1fae5; color: #065f46; }
.beo-source-google_group { background: #dbeafe; color: #1e40af; }
.beo-source-manual       { background: #f3f4f6; color: #374151; }

/* ── Status controls ──────────────────────────────────────── */
.beo-status-change { margin-top: 6px; }
.beo-status-select { font-size: .82rem; padding: 3px 6px; border: 1px solid var(--beo-border); border-radius: 4px; }
.beo-assign-select { font-size: .85rem; padding: 5px 8px; border: 1px solid var(--beo-border); border-radius: 4px; width: 100%; }

/* ── Notes ────────────────────────────────────────────────── */
.beo-notes-panel td { padding: 0 !important; }
.beo-notes-inner { padding: 16px 20px; background: #fafbff; border-top: 1px solid var(--beo-border); }
.beo-notes-list { list-style: none; margin: 0 0 12px; padding: 0; }
.beo-note-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--beo-border);
}
.beo-note-item:last-child { border-bottom: none; }
.beo-note-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.beo-note-date { font-size: .78rem; color: var(--beo-text-muted); }
.beo-note-text { font-size: .9rem; color: var(--beo-text); }
.beo-no-notes  { color: var(--beo-text-muted); font-size: .9rem; }
.beo-note-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.beo-note-input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--beo-border); border-radius: var(--beo-radius); font-size: .9rem; resize: vertical; }

/* ── Audit ────────────────────────────────────────────────── */
.beo-audit-list { list-style: none; margin: 0; padding: 0; }
.beo-audit-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--beo-border);
    font-size: .85rem;
    flex-wrap: wrap;
}
.beo-audit-item:last-child { border-bottom: none; }
.beo-audit-text { flex: 1; }
.beo-audit-by   { color: var(--beo-text-muted); font-size: .78rem; }
.beo-audit-date { color: var(--beo-text-muted); font-size: .75rem; white-space: nowrap; }

/* ── Detail page ──────────────────────────────────────────── */
.beo-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.beo-detail-header h1 { margin: 0; font-size: 1.5rem; }
.beo-detail-grid { display: grid; grid-template-columns: 1fr 400px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .beo-detail-grid { grid-template-columns: 1fr; } }
.beo-info-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.beo-info-table th { width: 140px; text-align: left; color: var(--beo-text-muted); padding: 6px 8px 6px 0; vertical-align: top; }
.beo-info-table td { padding: 6px 0; }
.beo-form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }

/* ── Forms ────────────────────────────────────────────────── */
.beo-form-group { margin-bottom: 14px; }
.beo-form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.beo-input, .beo-select, .beo-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--beo-border);
    border-radius: var(--beo-radius);
    font-size: .9rem;
    color: var(--beo-text);
}
.beo-input:focus, .beo-select:focus, .beo-textarea:focus {
    outline: none;
    border-color: var(--beo-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.beo-two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.beo-three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; flex-wrap: wrap; }
.beo-half      { max-width: 260px; }
@media (max-width: 600px) { .beo-two-col, .beo-three-col { grid-template-columns: 1fr; } }
.beo-form-actions { display: flex; gap: 10px; margin-top: 20px; }
.req { color: var(--beo-danger); }

/* ── Notices ──────────────────────────────────────────────── */
.beo-notice {
    padding: 10px 16px;
    border-radius: var(--beo-radius);
    margin-bottom: 16px;
    font-size: .9rem;
}
.beo-notice-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.beo-notice-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.beo-notice-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.beo-inline-msg { font-size: .85rem; padding: 6px 10px; border-radius: 4px; margin-top: 6px; }
.beo-inline-msg.success { background: #d1fae5; color: #065f46; }
.beo-inline-msg.error   { background: #fee2e2; color: #991b1b; }
.beo-loading { color: var(--beo-text-muted); font-style: italic; font-size: .85rem; }

/* ── Empty state ──────────────────────────────────────────── */
.beo-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--beo-text-muted);
    background: var(--beo-card-bg);
    border: 1px solid var(--beo-border);
    border-radius: var(--beo-radius);
}

/* ── Modal ────────────────────────────────────────────────── */
.beo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.beo-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 480px;
    max-width: 95vw;
    overflow: hidden;
}
.beo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--beo-border);
}
.beo-modal-header h2 { margin: 0; font-size: 1.1rem; }
.beo-modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--beo-neutral); line-height: 1; }
.beo-modal-close:hover { color: var(--beo-text); }
.beo-modal-body { padding: 20px; }
.beo-modal-patient-name { font-weight: 600; margin-bottom: 16px; }
.beo-modal-error { background: #fee2e2; color: #991b1b; padding: 8px 12px; border-radius: 4px; font-size: .85rem; }
.beo-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--beo-border);
    background: var(--beo-bg);
}

/* ── Unmatched / Find Patient section ────────────────────── */
.beo-unmatched-section {
    margin-bottom: 28px;
    border: 2px solid #f59e0b;
    border-radius: var(--beo-radius);
    overflow: hidden;
}
.beo-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
}
.beo-section-header-alert { background: #fffbeb; border-bottom: 1px solid #fde68a; }
.beo-section-header h2 { margin: 0; font-size: 1rem; color: #92400e; }
.beo-section-count { font-weight: 700; }
.beo-section-desc { margin: 0; padding: 8px 18px 12px; font-size: .85rem; color: var(--beo-text-muted); background: #fffbeb; }
.beo-unmatched-table { border-radius: 0; box-shadow: none; }
.beo-badge-count-alert { background: #f59e0b; }
.beo-contact-found { font-size: .83rem; }
.beo-found-tag { display: inline-block; background: #f3f4f6; border-radius: 4px; padding: 2px 7px; margin: 2px 2px 2px 0; }
.beo-text-muted { color: var(--beo-text-muted); font-size: .82rem; }
.beo-optional { color: var(--beo-text-muted); font-weight: 400; font-size: .82rem; }
.beo-badge-findpatient { background: #fef3c7; color: #78350f; }

/* ── Wide modal variant ───────────────────────────────────── */
.beo-modal-wide { width: 680px; }

/* ── Email viewer modal ───────────────────────────────────── */
.beo-email-meta-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: .88rem; }
.beo-email-meta-table th { width: 90px; text-align: left; color: var(--beo-text-muted); padding: 4px 8px 4px 0; vertical-align: top; }
.beo-email-meta-table td { padding: 4px 0; word-break: break-word; }
.beo-email-body-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--beo-text-muted); margin-bottom: 6px; }
.beo-email-body {
    background: var(--beo-bg);
    border: 1px solid var(--beo-border);
    border-radius: var(--beo-radius);
    padding: 14px 16px;
    font-size: .88rem;
    line-height: 1.6;
    max-height: 340px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Patient modal hint ───────────────────────────────────── */
.beo-modal-hint {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--beo-radius);
    padding: 10px 14px;
    font-size: .85rem;
    color: #1e40af;
    margin-bottom: 16px;
}
/* ── Parsed-by badge ──────────────────────────────────────── */
.beo-parsed-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.beo-parsed-ai    { background: #ede9fe; color: #5b21b6; }
.beo-parsed-regex { background: #f3f4f6; color: #374151; }

/* ── Contact methods checkboxes ───────────────────────────── */
.beo-contact-methods {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.beo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: .9rem;
}
.beo-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.beo-checkbox-required { font-weight: 600; }
.beo-required-tag {
    font-size: .75rem;
    color: var(--beo-text-muted);
    font-weight: 400;
}

/* ── Memo card ────────────────────────────────────────────── */
.beo-card-memo { border-left: 4px solid var(--beo-primary); }
.beo-memo-text {
    font-size: .9rem;
    line-height: 1.6;
    color: var(--beo-text);
    background: var(--beo-bg);
    border: 1px solid var(--beo-border);
    border-radius: var(--beo-radius);
    padding: 12px 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Invoice number column ────────────────────────────────── */
.beo-invoice-num {
    font-size: .85rem;
    font-family: monospace;
    white-space: nowrap;
}

.beo-search-form { margin-bottom: 20px; }
.beo-search-row  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.beo-search-input { flex: 1; min-width: 240px; }
.beo-result-count { font-size: .9rem; color: var(--beo-text-muted); margin-bottom: 12px; }

/* ── Settings ─────────────────────────────────────────────── */
.beo-settings-table td { vertical-align: middle; }
.beo-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: .85rem; }
.beo-add-resolution { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--beo-border); }
.beo-add-resolution h3 { font-size: .9rem; margin-bottom: 8px; }
.beo-gf-mapping-row { background: var(--beo-bg); border: 1px solid var(--beo-border); border-radius: var(--beo-radius); padding: 16px; margin-bottom: 12px; }
.beo-gf-mapping-row h4 { margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }

/* ── Logs page ────────────────────────────────────────────── */
.beo-log-table-wrap { overflow-x: auto; }
.beo-log-table { font-size: .82rem; }
.beo-log-table td { vertical-align: top; padding: 7px 10px; }

/* Row background by level */
.beo-log-error   { background: #fff5f5; }
.beo-log-warning { background: #fffbeb; }
.beo-log-info    {}

/* Level badge */
.beo-log-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}
.beo-log-level-info    { background: #dbeafe; color: #1e40af; }
.beo-log-level-warning { background: #fef3c7; color: #92400e; }
.beo-log-level-error   { background: #fee2e2; color: #991b1b; }

.beo-log-time      { font-size: .78rem; color: var(--beo-text-muted); white-space: nowrap; }
.beo-log-component { font-size: .78rem; color: var(--beo-text-muted); white-space: nowrap; }
.beo-log-message   { word-break: break-word; }

/* Context pre block inside modal */
.beo-context-pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px;
    border-radius: var(--beo-radius);
    font-size: .82rem;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 400px;
    white-space: pre;
    margin: 0;
}

/* Pagination */
.beo-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    font-size: .85rem;
}
.beo-page-info { color: var(--beo-text-muted); }

/* ── Inline context expand ────────────────────────────────── */
.beo-ctx-details summary { list-style: none; }
.beo-ctx-details summary::-webkit-details-marker { display: none; }
.beo-ctx-inline {
    margin: 8px 0 0;
    padding: 10px 12px;
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: var(--beo-radius);
    font-size: .78rem;
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
    max-width: 400px;
    max-height: 300px;
    overflow-y: auto;
}

/* ── Ignored section ──────────────────────────────────────── */
.beo-ignored-section {
    margin-bottom: 20px;
    border: 1px solid var(--beo-border);
    border-radius: var(--beo-radius);
    overflow: hidden;
}
.beo-section-header-ignored { background: #f9fafb; border-bottom: 1px solid var(--beo-border); }
.beo-section-header-ignored h2 { color: var(--beo-text-muted); }

/* ── Possible duplicate badge ─────────────────────────────── */
.beo-possible-dup-badge {
    display: inline-block;
    margin-top: 3px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
}
.beo-badge-ignored   { background: #f3f4f6; color: #6b7280; }
.beo-badge-duplicate { background: #e0e7ff; color: #3730a3; }
.beo-btn-warning     { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.beo-btn-warning:hover { background: #d97706; }

/* ── Duplicate modal results ──────────────────────────────── */
.beo-dup-results { margin-top: 12px; }
.beo-dup-results .beo-table { font-size: .85rem; }

/* ── Detail page card header row ─────────────────────────── */
.beo-card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.beo-card-header-row h3 { margin: 0; }

/* ── Duplicate warning cards ──────────────────────────────── */
.beo-card-duplicate-warning { border-left: 4px solid #f59e0b; background: #fffbeb; }
.beo-card-possible-dup      { border-left: 4px solid #f59e0b; background: #fffbeb; }
.beo-card-duplicates-list   { border-left: 4px solid #6366f1; }
.beo-duplicates-list { list-style: none; margin: 0; padding: 0; }
.beo-duplicates-list li { padding: 5px 0; border-bottom: 1px solid var(--beo-border); font-size: .9rem; }
.beo-duplicates-list li:last-child { border-bottom: none; }

/* ── Patient match dropdown ───────────────────────────────── */
.beo-field-hint {
    font-size: .78rem;
    color: var(--beo-text-muted);
    margin: 4px 0 0;
}

/* ── Dashboard filters inline ─────────────────────────────── */
.beo-filter-form {
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
}
.beo-filter-form select {
    flex: 0 0 auto;
}

/* ── Patient record match card ────────────────────────────── */
.beo-card-patient-match { border-left: 4px solid #6366f1; }

/* ── Conflict resolution table ────────────────────────────── */
.beo-conflict-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 8px; }
.beo-conflict-table th {
    background: var(--beo-bg-light);
    padding: 7px 10px;
    text-align: left;
    border-bottom: 2px solid var(--beo-border);
    font-weight: 600;
}
.beo-conflict-table td { padding: 7px 10px; border-bottom: 1px solid var(--beo-border); vertical-align: middle; }
.beo-conflict-row td { background: #fffbeb; }
.beo-fill-row td    { background: #f0fdf4; }
.beo-same-row td    { background: #fff; }
.beo-radio-inline   { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px;
                       cursor: pointer; font-size: .82rem; }

/* ── Patient record conflict hints in edit form ───────────── */
.beo-field-conflict { border-color: #f59e0b !important; background: #fffbeb !important; }
.beo-field-filled   { border-color: #10b981 !important; background: #f0fdf4 !important; }
.beo-conflict-hint  {
    margin-top: 5px;
    padding: 6px 8px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    font-size: .8rem;
}
.beo-conflict-label { display: block; margin-bottom: 4px; color: #92400e; }
