/*
 * DER-78: day / night mode for the doctor dashboard and the login/signup page.
 *
 * theme.js (in <head>) sets <html data-theme="light|dark">. Light is today's
 * look: the :root tokens below equal the existing colours and nothing else in
 * this file applies in light mode. Dark mode is an override layer, because the
 * legacy stylesheets hard-code their colours.
 *
 * Load LAST in <head> so it wins over the inline <style> blocks.
 * Specificity note: the dialog theme uses `.modal:is(#id, ...)` with
 * !important; `:not(#pf-none)` below adds one id of specificity to beat it.
 */

:root {
	--pf-bg: #ffffff;
	--pf-surface: #ffffff;
	--pf-raised: #f4f2f3;
	--pf-border: #ece6e8;
	--pf-text: #242426;
	--pf-text-muted: #6b6b73;
	--pf-pink: #d93364;        /* fills: avatar, buttons, active tab */
	--pf-pink-text: #bc2445;   /* pink text, AA on white */
	--pf-pink-tint: #fff1f5;
	--pf-green: #11a198;
	--pf-green-text: #0b7a73;
	--pf-green-tint: #e6f6f5;
	--pf-input-bg: #ffffff;
	--pf-pill-bg: #f1edef;
}

/* Dark palette "gray" (the original). theme.js picks the palette with ONE line:
   DARK_PALETTE = 'gray' | 'navy'. */
html[data-theme="dark"] {
	color-scheme: dark;
	--pf-bg: #1d1e20;
	--pf-surface: #2a2b2f;
	--pf-raised: #36373b;
	--pf-border: #3c3d41;
	--pf-text: #f2f2f3;
	--pf-text-muted: #a9aaae;
	--pf-pink: #d93364;
	--pf-pink-text: #f27a9e;   /* AA on every dark surface: 6.4 bg, 5.4 surface, 4.6 raised */
	--pf-pink-tint: #3a2a31;
	--pf-green: #11a198;
	--pf-green-text: #1fb8ad;  /* 6.8:1 on bg, 5.7:1 on surface */
	--pf-green-tint: #213634;
	--pf-input-bg: var(--pf-surface); /* same as the panels: no near-black strips (Derek) */
	--pf-pill-bg: var(--pf-raised);   /* pill track a step lighter than the menu, like hPanel */
	--pf-danger-text: #ff7a7a;        /* red warning links */
	--pf-tab-text: var(--pf-text-muted); /* DER-80 tab row (576-991px) and the "…" button */
	--pf-tab-strip: var(--pf-surface);
}

/* Dark palette "navy" (Derek's trial, from Chrome's dark UI). Only the tokens
   that differ from "gray"; accents re-checked for WCAG AA on these tones. */
html[data-theme="dark"][data-dark-palette="navy"] {
	--pf-bg: #18202f;          /* deep navy page */
	--pf-surface: #343c4c;     /* slate panels, cards, menus, inputs */
	--pf-raised: #3e4757;      /* panel headers, hover */
	--pf-border: #465063;
	--pf-text-muted: #b4bac6;  /* 4.8 surface, 4.6 on tints */
	--pf-pink-text: #f7a1bb;   /* 8.4 bg, 5.7 surface, 4.8 raised, 4.6 tint */
	--pf-pink-tint: #4f4557;
	--pf-green-text: #4fd3c8;  /* 8.9 bg, 6.1 surface, 5.1 raised, 4.9 tint */
	--pf-green-tint: #314d5a;
	--pf-danger-text: #ff9494; /* 5.3 surface */
}

/* ---- Theme pill (both modes) -------------------------------------------- */

.pf-theme-pill {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 3px;
	border-radius: 999px;
	background: var(--pf-pill-bg);
	border: 1px solid var(--pf-border);
}

.pf-theme-pill .pf-theme-opt {
	width: 34px;
	height: 28px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--pf-text-muted);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	line-height: 1;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.pf-theme-pill .pf-theme-opt:hover {
	color: var(--pf-text);
}

.pf-theme-pill .pf-theme-opt[aria-pressed="true"] {
	background: var(--pf-pink);
	color: #ffffff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pf-theme-pill .pf-theme-opt:focus-visible {
	outline: 3px solid var(--pf-pink-text);
	outline-offset: 1px;
}

/* Icons: beat the menu row icon rules (fixed 20px column, muted colour). */
.pf-avatar-menu .pf-am-row .pf-theme-opt i,
#mySidenav.pf-side-menu .mobile-nav .pf-theme-opt i {
	flex: none;
	width: auto;
	height: auto;
	margin: 0;
	border: 0;
	font-size: 15px;
	line-height: 1;
	color: inherit !important;
}

/* Phone side menu Theme row (250px wide panel). */
#mySidenav.pf-side-menu .pf-sm-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px 10px 20px;
	font-size: 15px;
	font-weight: 500;
	color: var(--pf-am-text);
}

#mySidenav.pf-side-menu .pf-sm-row .pf-theme-opt {
	width: 30px;
}

#mySidenav.pf-side-menu .mobile-nav li.pf-sm-theme {
	margin-top: 6px;
	padding-top: 6px;
	border-top: 1px solid var(--pf-am-border);
}

/* ====================================================================== */
/* Dark mode overrides                                                     */
/* ====================================================================== */

/* ---- page ---- */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] .main-wrapper {
	background-color: var(--pf-bg) !important;
	color: var(--pf-text);
}

html[data-theme="dark"] :is(h1, h2, h3, h4, h5, h6, p, label, li, td, th, dt, dd) {
	color: inherit;
}

/* ---- header bar ----
 * Light grey even in dark mode (Derek, 2026-11-22): the Phrasefire logo has dark
 * and saturated text, so it needs a light bar. #D9DADD keeps the purple at 5.6:1,
 * the black (c) at 15:1 and the pink wordmark at 4.1:1 (large-text AA; the pink is
 * 4.4:1 even on white). The rest of the page stays dark. */
html[data-theme="dark"] {
	--pf-header-bar: #d9dadd;
}

html[data-theme="dark"] :is(header .header-top, header .bg-white, .header-top.bg-white, .mobile-header-wrapper, .mobile-header, .mobile-menu) {
	background-color: var(--pf-header-bar) !important;
	color: #242426;
	border-color: #c4c5c9 !important;
	box-shadow: 0 1px 0 #c4c5c9, 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* The logo file has an opaque white background; multiply lets the bar show
   through the white and leaves the pink, purple and black as they are. */
html[data-theme="dark"] :is(header .brand-logo, .mobile-brand-logo) img {
	mix-blend-mode: multiply;
}

/* ---- DER-82: navy header with the dark-background logo ----
 * Navy palette only (Derek, 2026-11-22, Option A). The header is the page colour
 * (#18202F) with a thin #343C4C line below, and the approved dark logo (navy
 * background, pink PHRASEFIRE, light-purple MEDICAL, white (c)) replaces the
 * uploaded logo. Light mode and the gray palette keep the uploaded logo and the
 * light-grey bar above. theme.js sets data-theme/data-dark-palette in <head>,
 * so the right logo is chosen before the first paint. */
.pf-logo-dark {
	display: none !important;
}

html[data-theme="dark"][data-dark-palette="navy"] .pf-logo-light {
	display: none !important;
}

/* DER-84: the markup also hides .pf-logo-dark with an inline style="display:none" (safe when this
 * file is old or fails to load). Keep !important here: it is what overrides that inline style. */
html[data-theme="dark"][data-dark-palette="navy"] .pf-logo-dark {
	display: inline-block !important;
	mix-blend-mode: normal !important; /* its background already matches the header */
}

html[data-theme="dark"][data-dark-palette="navy"] :is(header .header-top, header .bg-white, .header-top.bg-white, .mobile-header-wrapper, .mobile-header, .mobile-menu) {
	background-color: var(--pf-bg) !important;
	color: var(--pf-text);
	border-color: var(--pf-surface) !important;
	box-shadow: 0 1px 0 var(--pf-surface); /* the thin #343C4C line */
}

/* An optional secondary (partner) logo keeps a small light chip, as on the grey bar. */
html[data-theme="dark"][data-dark-palette="navy"] header .secondary-logo {
	padding: 2px 6px;
	border-radius: 8px;
	background-color: var(--pf-header-bar);
}

/* ---- DER-85: soft light-gray outline (#CDD2DC) on every header logo ----
 * Light and dark, desktop (.brand-logo) and phone (.mobile-brand-logo) headers.
 * Logos with a solid background (the uploaded Phrasefire logo: white; the dark logo: navy;
 * solid partner logos: white) use the SVG filters in includes/logo-outline-filters, which
 * trace the shapes instead of the image's rectangle. Transparent partner logos (marked
 * server-side by LogoTransparency) use a plain drop-shadow. */
:is(header .brand-logo, .mobile-brand-logo) img.pf-logo-light,
:is(header .brand-logo, .mobile-brand-logo) .secondary-logo.pf-logo-solid img {
	filter: url(#pf-logo-outline-white);
}

:is(header .brand-logo, .mobile-brand-logo) img.pf-logo-dark {
	filter: url(#pf-logo-outline-navy);
}

:is(header .brand-logo, .mobile-brand-logo) .secondary-logo.pf-logo-transparent img {
	filter: drop-shadow(0 0 1.5px #CDD2DC) drop-shadow(0 0 1.5px #CDD2DC);
}

/* Navy dark mode: a transparent partner logo sits straight on the header (no chip), like
   Derek's mockup. A solid one keeps the light chip above as the fallback, unfiltered. */
html[data-theme="dark"][data-dark-palette="navy"] header .secondary-logo.pf-logo-transparent {
	padding: 0;
	border-radius: 0;
	background-color: transparent;
}

html[data-theme="dark"][data-dark-palette="navy"] header .secondary-logo.pf-logo-transparent img {
	mix-blend-mode: normal;
}

html[data-theme="dark"][data-dark-palette="navy"] header .secondary-logo.pf-logo-solid img {
	filter: none;
}

/* ---- DER-87: desktop header, Phrasefire and partner logos at the same size ----
 * Desktop header only (.header-top is shown from 992px up; the phone header is separate).
 * Both logos are 40px tall, the Phrasefire logo's size when there is no partner logo, so
 * that case is unchanged. The logo area used to be capped at 120px wide, which shrank a
 * partner logo to ~33x11. It now sizes to its content; the empty middle column takes the
 * rest, so the avatar stays on the right and nothing wraps. Light and dark; the DER-85
 * outline and the solid-logo chip are unchanged (the chip keeps the header height). */
.header-top .header_logo {
	flex: 0 0 auto;
	width: auto;
	max-width: none;
}

.header-top .header-top-navigation {
	flex: 1 1 0;
	width: auto;
	min-width: 0;
}

.header-top .brand-logo {
	max-width: none;
	width: auto;
	align-items: center;
	gap: 14px;
}

.header-top .brand-logo > a {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}

.header-top .brand-logo .main-logo img {
	width: auto;
	height: 40px;
}

.header-top .brand-logo .secondary-logo img {
	display: block;
	width: auto;
	height: auto;
	max-width: 150px;
	max-height: 40px;
}

html[data-theme="dark"][data-dark-palette="navy"] .header-top .brand-logo .secondary-logo.pf-logo-solid img {
	max-height: 36px; /* + the chip's 2px padding = 40px */
}

/* DER-84: the phone header shows the secondary (partner) logo too, beside the Phrasefire
   logo, sized to fit left of the avatar button at 390px. Light and dark mode; the dark
   chip above applies here as well. Only rendered when the user's secondary logo is on. */
.mobile-brand-logo.pf-has-secondary {
	display: flex;
	align-items: center;
	gap: 10px;
	width: auto;
	max-width: calc(100vw - 80px); /* room for the avatar button on the right */
}

.mobile-brand-logo.pf-has-secondary > a {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}

.mobile-brand-logo.pf-has-secondary .pf-mobile-main-logo img {
	width: 100px;
	height: auto;
}

.mobile-brand-logo.pf-has-secondary .secondary-logo img {
	display: block;
	width: auto;
	height: auto;
	max-width: 120px;
	max-height: 32px;
}

/* Tab strip from 576px up (DER-80 keeps it a top row down to there); below that the
   same menu is the green phone bottom bar, which stays green. */
@media (min-width: 576px) {
	html[data-theme="dark"] :is(.doctor-menu-bar, .doctor-menu, .main_menu) {
		background-color: var(--pf-surface) !important;
	}

	html[data-theme="dark"] .main_menu li a,
	html[data-theme="dark"] .main_menu li a :is(h3, i) {
		color: var(--pf-text-muted) !important;
	}

	html[data-theme="dark"] .main_menu li:is(.active, :hover) a,
	html[data-theme="dark"] .main_menu li:is(.active, :hover) a :is(h3, i) {
		color: #ffffff !important;
	}
}

/* ---- cards, widgets, panels ---- */
html[data-theme="dark"] :is(.card, .widget-item, .user-box, .share-box-inner, .list-group-item, .dropdown-menu, .popover, .toast, .jumbotron) {
	background-color: var(--pf-surface) !important;
	color: var(--pf-text);
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .widget-title {
	background-color: var(--pf-raised) !important;
	color: var(--pf-pink-text) !important;
	border-bottom-color: var(--pf-green) !important;
}

html[data-theme="dark"] .widget-title span {
	color: var(--pf-text) !important;
}

html[data-theme="dark"] .widget-item h5 {
	color: var(--pf-text);
	border-color: var(--pf-border);
}

/* ---- phrase chips ---- */
html[data-theme="dark"] .unorder-list-info {
	background-color: var(--pf-green-tint) !important;
	border-color: var(--pf-green) !important;
}

html[data-theme="dark"] .unorder-list-info :is(.list-title, .list-title a, a) {
	color: var(--pf-text) !important;
}

html[data-theme="dark"] .unorder-list-info i {
	color: var(--pf-green-text) !important;
}

html[data-theme="dark"] .unorder-list-info:hover {
	box-shadow: 0 0 0 1px var(--pf-green-text);
}

/* ---- forms ---- */
html[data-theme="dark"] :is(.form-control:not(button):not(.btn), input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="tel"], input[type="url"], textarea, select, .nice-select, .custom-select, .bootstrap-tagsinput) {
	background-color: var(--pf-input-bg) !important;
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] :is(.form-control, input, textarea)::placeholder {
	color: var(--pf-text-muted) !important;
	opacity: 1;
}

html[data-theme="dark"] .nice-select .list {
	background-color: var(--pf-surface);
}

html[data-theme="dark"] .nice-select .option:is(:hover, .focus, .selected.focus) {
	background-color: var(--pf-raised);
}

/* ---- tables ---- */
html[data-theme="dark"] :is(table, .table) {
	color: var(--pf-text);
	background-color: transparent;
}

html[data-theme="dark"] .table :is(th, td),
html[data-theme="dark"] .table thead th {
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
	background-color: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .table-hover tbody tr:hover {
	background-color: var(--pf-raised);
	color: var(--pf-text);
}

/* ---- modals (Bootstrap + the approved dialog theme) ---- */
html[data-theme="dark"] .modal:not(#pf-none) :is(.modal-content, .modal-header, .modal-footer) {
	background-color: var(--pf-surface) !important;
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .modal:not(#pf-none) .modal-body {
	background-color: var(--pf-bg) !important;
	color: var(--pf-text) !important;
}

html[data-theme="dark"] .modal:not(#pf-none) .modal-title {
	color: var(--pf-text) !important;
}

html[data-theme="dark"] .modal:not(#pf-none) :is(.close, .btn-close, .btn-close1) {
	background-color: var(--pf-raised) !important;
	border-color: var(--pf-border) !important;
	color: var(--pf-pink-text) !important;
}

html[data-theme="dark"] .modal:not(#pf-none) :is(.btn-info, .btn-warning, .cancel, [data-dismiss="modal"].btn, [data-bs-dismiss="modal"].btn) {
	background-color: var(--pf-raised) !important;
	color: var(--pf-pink-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .modal-backdrop.show {
	opacity: 0.7;
}

/* SweetAlert dialogs */
html[data-theme="dark"] .pf-dialog-theme :is(.swal-modal, .sweet-alert, .swal2-popup) {
	background: var(--pf-surface) !important;
	color: var(--pf-text);
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .pf-dialog-theme :is(.swal-title, .sweet-alert h2, .swal2-title) {
	color: var(--pf-text) !important;
}

html[data-theme="dark"] .pf-dialog-theme :is(.swal-text, .swal2-html-container, .sweet-alert p) {
	color: var(--pf-text) !important;
	background: var(--pf-raised) !important; /* a step lighter than the alert, not a near-black strip */
	border-color: var(--pf-border) !important;
}

/* ---- popup text fixes (DER-82 follow-up; Derek, live bug 2026-11-22) ----
 * Dark mode only. Found by e2e/tests/dark-popups.spec.ts, which opens every popup. */
/* Share popup ("Find Phrasefire Helpful? ..."): the approved dialog theme fixes its
   text at #242426 with an id-level !important rule, so it was dark on the navy popup. */
html[data-theme="dark"] .pf-dialog-theme #popup-share :is(.title-content, .description-content) {
	color: #ffffff !important;
}

/* Delete confirmation (Browse, Notes): style.css greys the heading (#837272, 3.6:1 on navy). */
html[data-theme="dark"] #confirm_delete :is(h4, h6) {
	color: var(--pf-text) !important;
}

/* Phrase popup "View Link" / "Share with Patients": white on #DC386D is 4.35:1;
   the dialog theme's #BC2445 gives 5.9:1. */
html[data-theme="dark"] #search_result .post-link {
	background: #bc2445 !important;
}

/* ---- posts (My Assessment/Plans, Favorites, Notes) ---- */
html[data-theme="dark"] :is(.post-content, .post-meta, .inner-post-content) {
	background-color: var(--pf-surface) !important;
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .post-content :is(strong, small, p, span:not(.badge)) {
	color: inherit !important;
}

/* Same roles as light mode: grey author and actions, green titles. */
html[data-theme="dark"] :is(.post-content .author a, .post-meta a) {
	color: var(--pf-text-muted) !important;
}

html[data-theme="dark"] .post-meta a:hover {
	color: var(--pf-pink-text) !important;
}

html[data-theme="dark"] .post-content h4 a {
	color: var(--pf-green-text) !important;
}

/* Save / favourite / comment icons: dark grey in light mode; keep the active
   (.save / .favourite) colours from style.css. */
html[data-theme="dark"] :is(.post-meta-like:not(.save):not(.favourite), .post-share) i {
	color: var(--pf-text-muted) !important;
}

html[data-theme="dark"] .badge {
	background: var(--pf-raised) !important;
	color: var(--pf-pink-text) !important;
	border-color: var(--pf-border) !important;
}

/* Phrase popup title and author */
html[data-theme="dark"] #search_result :is(.post-title, .author, .copy-by) {
	color: var(--pf-pink-text) !important;
}

/* Change Password submit: transparent with black text in both themes. */
html[data-theme="dark"] .add-product_btn {
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

/* ---- profile / refer ---- */
html[data-theme="dark"] .author-into-list li a {
	color: var(--pf-text-muted) !important;
}

html[data-theme="dark"] a[onclick^="cancel_membership"] {
	color: var(--pf-danger-text) !important; /* red warning, AA on dark */
}

html[data-theme="dark"] .Admin-url .url {
	background-color: var(--pf-input-bg) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .Admin-url .url p {
	color: var(--pf-text) !important;
}

/* DataTables (referral list) */
html[data-theme="dark"] .dataTables_wrapper :is(.dataTables_info, .dataTables_length, .dataTables_filter, .dataTables_processing, .dataTables_paginate) {
	color: var(--pf-text-muted) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
	color: var(--pf-text-muted) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
	background: var(--pf-raised) !important;
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] table.dataTable :is(thead th, tbody td) {
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] table.dataTable tbody tr {
	background-color: transparent !important;
}

/* ---- login / signup page ---- */
/* The logo sits on the dark page here, so give it the same light-grey card as
   the header bar (and the same multiply blend for its white background). */
html[data-theme="dark"] .signup-form-wrapper .brand_logo {
	display: inline-block;
	padding: 10px 16px;
	border-radius: 12px;
	background-color: var(--pf-header-bar);
}

html[data-theme="dark"] .signup-form-wrapper .brand_logo img {
	mix-blend-mode: multiply;
}

/* DER-82: with the navy palette the dark logo sits straight on the page; no card. */
html[data-theme="dark"][data-dark-palette="navy"] .signup-form-wrapper .brand_logo {
	padding: 0;
	border-radius: 0;
	background-color: transparent;
}

html[data-theme="dark"] .login.signup,
html[data-theme="dark"] .login.signup span,
html[data-theme="dark"] .alreagy_acc {
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] .links a,
html[data-theme="dark"] .alreagy_acc a {
	color: var(--pf-pink-text) !important;
}

html[data-theme="dark"] :is(#modallogin, #modalsignup, #forgot) :is(.modal-content, .modal-header) {
	background: var(--pf-surface) !important;
	color: var(--pf-text) !important;
	border-color: var(--pf-border) !important;
}

html[data-theme="dark"] :is(#modallogin, #modalsignup, #forgot) .modal-title {
	color: var(--pf-text) !important;
}

html[data-theme="dark"] :is(#modallogin, #modalsignup, #forgot) a {
	color: var(--pf-pink-text);
}

html[data-theme="dark"] :is(#modallogin .btn-close1, #modalsignup .btn-close, #forgot .btn-close) {
	background: var(--pf-raised) !important;
	border-color: var(--pf-border) !important;
	color: var(--pf-pink-text) !important;
}

html[data-theme="dark"] #signup-confirmation {
	background: var(--pf-surface);
	color: var(--pf-text);
	border-color: var(--pf-border);
}

html[data-theme="dark"] #signup-confirmation h2 {
	color: var(--pf-text);
}

html[data-theme="dark"] #signup-confirmation p {
	color: var(--pf-text);
	background: var(--pf-raised); /* a step lighter than the dialog, not a near-black strip */
	border-color: var(--pf-border);
}

html[data-theme="dark"] #signup-confirmation .confirmation-close {
	background: var(--pf-raised);
	border-color: var(--pf-border);
	color: var(--pf-pink-text);
}
