/* =========================================================================
   PurpleCare Clinician Portal — Dark Theme Override
   Wolfgang, 27 May 2026
   Palette matched to /worker-app (worker portal):
     --bg:        #1a0a2e   page background (deep dark purple)
     --card:      #0d0d1a   card / panel background (deep navy)
     --card-2:    #14112b   raised surfaces / alt rows
     --purple:    #7c3aed   primary action / accent
     --purple-2:  #6d28d9   primary hover
     --purple-3:  #a78bfa   secondary accent text
     --text:      #f5f3ff   body text
     --muted:     #a78bfa   muted / labels
     --line:      #3b2566   borders
   This file loads LAST in base.html and aggressively overrides the legacy
   light palette with !important to defeat inline styles in page templates.
   ========================================================================= */

:root{
  --pc-bg:#1a0a2e;
  --pc-card:#0d0d1a;
  --pc-card-2:#14112b;
  --pc-purple:#7c3aed;
  --pc-purple-2:#6d28d9;
  --pc-purple-3:#a78bfa;
  --pc-text:#f5f3ff;
  --pc-muted:#a78bfa;
  --pc-line:#3b2566;
  --pc-ok:#10b981;
  --pc-warn:#f59e0b;
  --pc-err:#ef4444;
}

/* ---------- Page surface ---------- */
html,body{
  background:var(--pc-bg) !important;
  color:var(--pc-text) !important;
}
body, .main, .wrap{ background:transparent !important; }

a{ color:var(--pc-purple-3) !important; }
a:hover{ color:#c4b5fd !important; }

h1,h2,h3,h4,h5,h6{ color:var(--pc-text) !important; }
p, span, li, td, th, label, small, em, strong, div{ color:inherit; }

/* ---------- Nav ---------- */
.nav{
  background:linear-gradient(180deg,#1a0a2e 0%,#150826 100%) !important;
  border-bottom:1px solid var(--pc-line) !important;
}
.brand{ color:#fff !important; }
.brand .sub{ color:var(--pc-purple-3) !important; }
.brand .poweredby{ color:#c4b5fd !important; }
.brand .poweredby strong{ color:#fff !important; }
.nav-links a{ color:#e9d5ff !important; }
.nav-links a:hover{ color:#fff !important; }
.nav-links a.active{ color:#fff !important; border-bottom-color:var(--pc-purple) !important; }
.nav-row{ border-bottom-color:var(--pc-line) !important; }
.nav-toggle span{ background:#e9d5ff !important; }
.user-chip, .user-chip .who-line{ color:#e9d5ff !important; }
.user-chip .who{ color:#fff !important; }
.role-pill{ background:rgba(124,58,237,.25) !important; color:#e9d5ff !important; }

/* ---------- Page head ---------- */
.page-head h1{ color:#fff !important; }
.page-head .sub{ color:var(--pc-muted) !important; }

/* ---------- Cards / panels ---------- */
.card,
.calendar-wrap,
.stat,
.shift-card,
.note-item,
.msg{
  background:var(--pc-card) !important;
  border:1px solid var(--pc-line) !important;
  color:var(--pc-text) !important;
  box-shadow:0 1px 2px rgba(0,0,0,.35) !important;
}
.card h2, .card h3{ color:#e9d5ff !important; }
.stat .num{ color:var(--pc-purple-3) !important; }
.stat .lab{ color:var(--pc-muted) !important; }

/* Inline whitey backgrounds used in templates */
[style*="background:#fff"],
[style*="background: #fff"],
[style*="background:#ffffff"],
[style*="background: #ffffff"],
[style*="background:#faf7ff"],
[style*="background: #faf7ff"],
[style*="background:#f9fafb"],
[style*="background: #f9fafb"],
[style*="background:#f3f4f6"],
[style*="background: #f3f4f6"]{
  background:var(--pc-card) !important;
  color:var(--pc-text) !important;
}
[style*="background:#f3e8ff"],
[style*="background: #f3e8ff"],
[style*="background:#ede9fe"],
[style*="background: #ede9fe"],
[style*="background:#ddd6fe"],
[style*="background: #ddd6fe"]{
  background:var(--pc-card-2) !important;
  color:var(--pc-text) !important;
}

/* Form fields must stay WHITE even when their inline style says background:#fff
   (the above attribute selector would otherwise repaint them dark). */
input[style*="background:#fff"],input[style*="background: #fff"],
input[style*="background:#ffffff"],input[style*="background: #ffffff"],
textarea[style*="background:#fff"],textarea[style*="background: #fff"],
textarea[style*="background:#ffffff"],textarea[style*="background: #ffffff"],
select[style*="background:#fff"],select[style*="background: #fff"],
select[style*="background:#ffffff"],select[style*="background: #ffffff"],
input[style*="background:#f9fafb"],textarea[style*="background:#f9fafb"],select[style*="background:#f9fafb"],
input[style*="background:#f3f4f6"],textarea[style*="background:#f3f4f6"],select[style*="background:#f3f4f6"],
input[style*="background:#faf7ff"],textarea[style*="background:#faf7ff"],select[style*="background:#faf7ff"]{
  background:#ffffff !important;
  color:#1a0a2e !important;
  -webkit-text-fill-color:#1a0a2e !important;
}


/* ---------- Tables ---------- */
table{ color:var(--pc-text) !important; }
table th{
  color:#e9d5ff !important;
  background:#1f0f3a !important;
  border-bottom:1px solid var(--pc-line) !important;
}
table td{
  border-bottom:1px solid var(--pc-line) !important;
  color:var(--pc-text) !important;
  background:transparent !important;
}
table tbody tr:nth-child(even) td{ background:rgba(124,58,237,.05) !important; }
table tr:hover td{ background:rgba(124,58,237,.12) !important; }
/* legacy purple thead (kept readable) */
thead[style*="#7c3aed"] th,
thead[style*="#5b21b6"] th,
thead[style*="#6d28d9"] th,
tr[style*="#7c3aed"] th,
tr[style*="#5b21b6"] th{
  background:var(--pc-purple) !important;
  color:#fff !important;
}

/* ---------- Forms (WHITE BG GLOBAL — Wolfgang 12 Jun 2026) ---------- */
/* Every input/textarea/select must be white with dark readable text across
   every page of the staff portal, regardless of inline page styles. */
input[type=text],input[type=email],input[type=password],input[type=search],
input[type=date],input[type=time],input[type=datetime-local],input[type=number],
input[type=tel],input[type=url],input[type=month],input[type=week],
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]):not([type=color]):not([type=range]):not([type=hidden]):not([type=image]),
textarea,
select{
  background:#ffffff !important;
  background-color:#ffffff !important;
  color:#1a0a2e !important;
  border:1px solid #d1d5db !important;
  -webkit-text-fill-color:#1a0a2e !important;
  caret-color:#1a0a2e !important;
}
input::placeholder,textarea::placeholder{ color:#6b7280 !important; opacity:1 !important; }
input:focus,textarea:focus,select:focus{
  background:#ffffff !important;
  color:#1a0a2e !important;
  border-color:var(--pc-purple) !important;
  box-shadow:0 0 0 3px rgba(124,58,237,.28) !important;
  outline:none !important;
}
input:disabled,textarea:disabled,select:disabled,
input[readonly],textarea[readonly]{
  background:#f3f4f6 !important;
  color:#4b5563 !important;
  border-color:#e5e7eb !important;
  -webkit-text-fill-color:#4b5563 !important;
  cursor:not-allowed;
  opacity:1 !important;
}
/* Dropdown options stay readable on white */
select option,
select optgroup{
  background:#ffffff !important;
  color:#1a0a2e !important;
}
/* Autofill (Chrome/Edge/Safari) — kill the dark/yellow background */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill{
  -webkit-box-shadow:0 0 0 1000px #ffffff inset !important;
  -webkit-text-fill-color:#1a0a2e !important;
  caret-color:#1a0a2e !important;
  border:1px solid #d1d5db !important;
}
/* Date / time picker indicator stays visible on white */
input[type=date]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator,
input[type=month]::-webkit-calendar-picker-indicator,
input[type=week]::-webkit-calendar-picker-indicator{
  filter:invert(15%) sepia(40%) saturate(2000%) hue-rotate(255deg);
  cursor:pointer;
  opacity:1 !important;
}
/* Number spinner */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button{ opacity:1; }

/* Labels — keep brand purple on dark page surface */
label{ color:var(--pc-muted) !important; }
/* Labels that sit INSIDE a white card (page-local .efh-card etc.) need dark text */
.efh-card label,
.card-light label,
[style*="background:#fff"] label,
[style*="background: #fff"] label,
[style*="background:#ffffff"] label,
[style*="background: #ffffff"] label{
  color:#5b21b6 !important;
}

/* ---------- Buttons ---------- */
.btn{ font-weight:600; }
.btn-primary{
  background:var(--pc-purple) !important;
  color:#fff !important;
  border:0 !important;
}
.btn-primary:hover{ background:var(--pc-purple-2) !important; }
.btn-ghost{
  background:transparent !important;
  color:#e9d5ff !important;
  border:1px solid var(--pc-line) !important;
}
.btn-ghost:hover{ background:rgba(124,58,237,.15) !important; }
.btn-danger{ background:var(--pc-err) !important; color:#fff !important; }
button.ai-btn{
  background:rgba(124,58,237,.18) !important;
  color:#e9d5ff !important;
  border:1px solid var(--pc-line) !important;
}
button.ai-btn:hover{ background:rgba(124,58,237,.32) !important; }

/* generic <button> not otherwise styled: keep purple */
button:not(.btn):not(.voice-mic):not(.nav-toggle):not(.ai-btn):not([class*="qc"]):not([style*="background"]){
  background:var(--pc-purple);
  color:#fff;
  border:0;
}

/* ---------- Tags / pills ---------- */
.tag{ background:rgba(124,58,237,.22) !important; color:#e9d5ff !important; }
.tag.scheduled{ background:rgba(59,130,246,.22) !important; color:#bfdbfe !important; }
.tag.in_progress{ background:rgba(245,158,11,.22) !important; color:#fde68a !important; }
.tag.completed,.tag.active{ background:rgba(16,185,129,.22) !important; color:#a7f3d0 !important; }
.tag.cancelled,.tag.high,.tag.severe{ background:rgba(239,68,68,.22) !important; color:#fecaca !important; }
.tag.medium{ background:rgba(245,158,11,.22) !important; color:#fde68a !important; }
.tag.low,.tag.inactive{ background:rgba(148,163,184,.22) !important; color:#cbd5e1 !important; }

/* Compliance badges (keep semantic colours on dark) */
.badge-green,[class*="compl-ok"],.tag.ok{ background:rgba(16,185,129,.22) !important; color:#a7f3d0 !important; border:1px solid rgba(16,185,129,.45) !important; }
.badge-amber,[class*="compl-warn"],.tag.warn{ background:rgba(245,158,11,.22) !important; color:#fde68a !important; border:1px solid rgba(245,158,11,.45) !important; }
.badge-red,[class*="compl-bad"],.tag.bad{ background:rgba(239,68,68,.22) !important; color:#fecaca !important; border:1px solid rgba(239,68,68,.45) !important; }

/* ---------- Flash messages ---------- */
.flash.ok{ background:rgba(16,185,129,.15) !important; color:#a7f3d0 !important; border:1px solid rgba(16,185,129,.45) !important; }
.flash.error{ background:rgba(239,68,68,.15) !important; color:#fecaca !important; border:1px solid rgba(239,68,68,.45) !important; }

/* ---------- Notes / messages ---------- */
.note-head .author{ color:#fff !important; }
.note-head{ color:var(--pc-muted) !important; }
.note-body{ color:#e9d5ff !important; }
.summary{
  background:rgba(124,58,237,.12) !important;
  border-left:3px solid var(--pc-purple) !important;
  color:#e9d5ff !important;
}
.msg{ background:var(--pc-card-2) !important; border:1px solid var(--pc-line) !important; }
.msg .who{ color:var(--pc-purple-3) !important; }
.msg .when{ color:var(--pc-muted) !important; }
.msg .body{ color:var(--pc-text) !important; }

/* ---------- Empty state ---------- */
.empty{ color:var(--pc-muted) !important; }

/* ---------- GPS / pin chip ---------- */
.gps-pin{ background:rgba(124,58,237,.18) !important; color:#e9d5ff !important; }

/* ---------- Modals (generic dialogs) ---------- */
dialog, .modal, .modal-content, [role="dialog"]{
  background:var(--pc-card) !important;
  color:var(--pc-text) !important;
  border:1px solid var(--pc-line) !important;
}
.modal-backdrop, .backdrop{ background:rgba(10,5,25,.7) !important; }

/* ---------- FullCalendar dark theme ---------- */
.fc{ color:var(--pc-text) !important; }
.fc .fc-toolbar-title{ color:#fff !important; }
.fc .fc-button{
  background:var(--pc-purple) !important;
  border:1px solid var(--pc-purple-2) !important;
  color:#fff !important;
}
.fc .fc-button:hover{ background:var(--pc-purple-2) !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active{
  background:var(--pc-purple-2) !important;
  border-color:var(--pc-purple-2) !important;
}
.fc-theme-standard td,.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid{
  border-color:var(--pc-line) !important;
}
.fc-theme-standard .fc-list{ border-color:var(--pc-line) !important; }
.fc .fc-daygrid-day, .fc .fc-timegrid-slot, .fc .fc-list-day-cushion{
  background:var(--pc-card) !important;
}
.fc .fc-day-today{ background:rgba(124,58,237,.15) !important; }
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text{ color:#e9d5ff !important; }
.fc .fc-list-event:hover td{ background:rgba(124,58,237,.18) !important; }
.fc .fc-event{ border-color:var(--pc-purple-2) !important; }

/* ---------- Charts (canvas / svg backgrounds) ---------- */
canvas, svg.chart, .chart-wrap{ background:transparent !important; }

/* ---------- Shift tabs (overrides shift_tabs.css if light) ---------- */
.shift-tabs, .shift-tabs *{ color:var(--pc-text); }
.shift-tabs a, .shift-tabs button{ color:#e9d5ff !important; }
.shift-tabs .active, .shift-tabs a.active{ color:#fff !important; border-color:var(--pc-purple) !important; }

/* ---------- Worker bubbles (already purple) ---------- */
.worker-bubble{ border-color:var(--pc-line) !important; }

/* ---------- Mobile responsive nav drawer recolour ---------- */
@media(max-width:899px){
  .nav-links,.user-chip{ border-top-color:var(--pc-line) !important; }
  .nav-links a{ border-bottom-color:var(--pc-line) !important; }
  .nav-links a.active{ background:rgba(124,58,237,.18) !important; color:#fff !important; border-left-color:var(--pc-purple) !important; }
}

/* ---------- Scrollbar (webkit) ---------- */
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:#10061f; }
::-webkit-scrollbar-thumb{ background:#3b2566; border-radius:6px; }
::-webkit-scrollbar-thumb:hover{ background:#5b21b6; }

/* ---------- HR / dividers ---------- */
hr{ border-color:var(--pc-line) !important; background:var(--pc-line) !important; }

/* ---------- Code / pre ---------- */
code, pre{ background:#10061f !important; color:#e9d5ff !important; border:1px solid var(--pc-line); border-radius:6px; padding:2px 6px; }

/* end theme-dark.css */

/* =========================================================================
   Page-specific class overrides
   ========================================================================= */

/* login.html uses .pc-* classes in a page-local <style> after theme-dark */
.pc-card{
  background:var(--pc-card) !important;
  border:1px solid var(--pc-line) !important;
  color:var(--pc-text) !important;
  box-shadow:0 4px 14px rgba(0,0,0,.45) !important;
}
.pc-h{ color:#fff !important; }
.pc-sub{ color:var(--pc-muted) !important; }
.pc-field label{ color:#e9d5ff !important; }
.pc-field input{
  background:#10061f !important;
  color:var(--pc-text) !important;
  border:1.5px solid var(--pc-line) !important;
}
.pc-field input:focus{
  border-color:var(--pc-purple) !important;
  box-shadow:0 0 0 3px rgba(124,58,237,.25) !important;
}
.pc-btn-primary{ background:var(--pc-purple) !important; color:#fff !important; }
.pc-btn-primary:hover{ background:var(--pc-purple-2) !important; }
.pc-flash.error{
  background:rgba(239,68,68,.15) !important;
  color:#fecaca !important;
  border:1px solid rgba(239,68,68,.45) !important;
}
.pc-footer-note{ color:var(--pc-muted) !important; }

/* =========================================================================
   READABLE BODY TEXT — Wolfgang 12 Jun 2026 (bodytext fix)
   Bug: participant profile tabs (Notes, Care Plan, History, Medications,
   Shifts, NDIS Funding, Goals, Documents) and the CRM contact detail modal
   rendered body/value text near-black on the dark theme. Labels and dates
   were fine; values were invisible.
   Fix: force high-contrast light (#E5E7EB) on classed value elements and on
   any element whose inline style hard-codes a near-black colour.
   CSS only — no logic changes.
   ========================================================================= */

/* --- Participant profile tab content (participant_detail.html) --- */
.note-body,
.history-desc,
.med-card-head strong,
.ai-section li,
.ai-narrative,
.pc-modal-box,
.pc-modal-box h3,
.tab-pane, .tab-panel, .tab-content,
.goal-desc, .doc-name, .careplan-field, .kv .v{
  color:#E5E7EB !important;
}
.ai-narrative{ background:rgba(124,58,237,.12) !important; }
.tab-btn.active{ color:#fff !important; }

/* --- CRM contact detail modal + profile grid values (crm.html, sc_crm_*) --- */
.profile-grid .v{ color:#E5E7EB !important; }
.profile-grid .v.mono{ color:#c4b5fd !important; }
.modal label{ color:var(--pc-muted) !important; }
.modal h4{ color:#e9d5ff !important; }
.modal p, .modal li, .modal td{ color:#E5E7EB !important; }

/* --- Inline near-black colours hard-coded in JS-rendered markup ---
   Covers #111 / #111827 / #1a1330 / #1f2937 / #222 / #333 / #0f172a /
   #374151 / #4b5563 in both "color:#x" and "color: #x" spellings.
   Form fields are excluded: they sit on forced-white backgrounds and must
   keep dark text (see WHITE BG GLOBAL section above). */
[style*="color:#111"]:not(input):not(textarea):not(select),
[style*="color: #111"]:not(input):not(textarea):not(select),
[style*="color:#222"]:not(input):not(textarea):not(select),
[style*="color: #222"]:not(input):not(textarea):not(select),
[style*="color:#333"]:not(input):not(textarea):not(select),
[style*="color: #333"]:not(input):not(textarea):not(select),
[style*="color:#0f172a"]:not(input):not(textarea):not(select),
[style*="color: #0f172a"]:not(input):not(textarea):not(select),
[style*="color:#1a1330"]:not(input):not(textarea):not(select),
[style*="color: #1a1330"]:not(input):not(textarea):not(select),
[style*="color:#1f2937"]:not(input):not(textarea):not(select),
[style*="color: #1f2937"]:not(input):not(textarea):not(select),
[style*="color:#374151"]:not(input):not(textarea):not(select),
[style*="color: #374151"]:not(input):not(textarea):not(select),
[style*="color:#4b5563"]:not(input):not(textarea):not(select),
[style*="color: #4b5563"]:not(input):not(textarea):not(select),
[style*="color:black"]:not(input):not(textarea):not(select){
  color:#E5E7EB !important;
}

/* end bodytext fix */

/* =========================================================================
   CRM LIST TABLES — Wolfgang 13 Jun 2026 (crmtables fix)
   Bug: main CRM contacts table (crm.html .crm-table) and SC/PM CRM list
   (sc_crm_list.html .sc-tbl) kept their page-local white backgrounds while
   td text was repainted light — values rendered unreadable on dark.
   Same bug class as the profile-tabs bodytext fix above. CSS only.
   ========================================================================= */
.crm-table, .sc-tbl{
  background:var(--pc-card) !important;
  border-color:var(--pc-line) !important;
  box-shadow:0 1px 2px rgba(0,0,0,.35) !important;
}
.crm-table th, .sc-tbl th{
  background:#1f0f3a !important;
  color:#e9d5ff !important;
  border-bottom:1px solid var(--pc-line) !important;
}
.crm-table td, .sc-tbl td,
.crm-table td b, .sc-tbl td b,
.crm-table td strong, .sc-tbl td strong{
  color:#E5E7EB !important;
}
.sc-tbl tr:hover, .crm-table tr:hover{ background:rgba(124,58,237,.12) !important; }
.crm-empty{
  background:var(--pc-card) !important;
  color:var(--pc-muted) !important;
  border-color:var(--pc-line) !important;
}
/* accent classes in sc_crm_list — keep readable on dark */
.pot-high{ color:#34d399 !important; }
.pot-medium{ color:#fbbf24 !important; }
.pot-low{ color:#9ca3af !important; }
.fu-overdue{ color:#f87171 !important; }
.fu-today{ color:#93c5fd !important; }
/* end crmtables fix */
