/**
 * TaskBrowse Smart Mega Menu — frontend styles.
 *
 * TB-SMM-002  This file contains NO breakpoint media queries. The responsive
 *             cut-off is injected as an inline <style> block by the PHP plugin
 *             (generate_breakpoint_css) using the admin-configured integer,
 *             so CSS and JS share a single source of truth.
 *
 * TB-SMM-004  RTL selectors target [dir="rtl"] on .tb-smm-panel directly —
 *             the panel always carries dir="rtl" when RTL is on, making the
 *             selector reliable in both standalone and injected contexts.
 *
 * TB-SMM-005  Desktop mega panel uses CSS clamp() to prevent off-screen
 *             overflow. JS reinforces this at open-time via --tb-smm-vp-offset.
 */

.tb-smm,
.tb-smm * {
	box-sizing: border-box;
}

.tb-smm {
	--tb-smm-red:      #C8102E;
	--tb-smm-ink:      #202124;
	--tb-smm-bg:       #FFFFFF;
	--tb-smm-panel-bg: #FFFFFF;
	--tb-smm-border:   #E4E0DA;
	--tb-smm-muted:    #6B6864;
	--tb-smm-maxw:     1100px;
	--tb-smm-radius:   12px;
	--tb-smm-icon:     20px;
	font-family: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
	color: var(--tb-smm-ink);
}

/* ---- Standalone trigger ---- */
.tb-smm--standalone .tb-smm-root {
	position: relative;
	display: inline-block;
}

.tb-smm-trigger-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 8px 4px;
	background: none;
	border: 0;
	font: inherit;
	font-weight: 600;
	color: inherit;
	cursor: pointer;
	line-height: 1.2;
}
.tb-smm-trigger-btn:focus-visible {
	outline: 2px solid var(--tb-smm-ink);
	outline-offset: 3px;
	border-radius: 2px;
}
.tb-smm-caret {
	display: inline-flex;
	transition: transform .18s ease;
}
.tb-smm-trigger-btn[aria-expanded="true"] .tb-smm-caret {
	transform: rotate(180deg);
}

/* ---- Panel base ---- */
.tb-smm-panel {
	background: var(--tb-smm-panel-bg);
	color: var(--tb-smm-ink);
	border: 1px solid var(--tb-smm-border);
	border-radius: var(--tb-smm-radius);
}
.tb-smm-panel[hidden] { display: none; }
.tb-smm-panel[data-shadow="1"] {
	box-shadow: 0 18px 50px -24px rgba(32,33,36,.35);
}

/* TB-SMM-005: viewport-safe desktop positioning.
   --tb-smm-vp-offset is written by JS at open-time for full browser support.
   The clamp() fallback handles modern browsers without JS.
   left is clamped so the panel cannot overflow the right viewport edge.        */
.tb-smm--standalone .tb-smm-panel,
.tb-smm-trigger-li  .tb-smm-panel {
	position: absolute;
	/* JS sets --tb-smm-vp-offset; fallback = 0px (aligned to trigger left). */
	left: var(--tb-smm-vp-offset, 0px);
	top: 100%;
	margin-top: 10px;
	width: min(var(--tb-smm-maxw), calc(100vw - 40px));
	z-index: 9999;
}
.tb-smm--standalone .tb-smm-root { position: relative; }
.tb-smm-trigger-li  { position: relative; }

/* RTL desktop: align from the right edge instead. */
.tb-smm-panel[dir="rtl"] {
	left: auto;
	right: var(--tb-smm-vp-offset, 0px);
}

.tb-smm-panel-inner {
	padding: 28px;
}

.tb-smm-columns {
	display: grid;
	gap: 28px;
}
.tb-smm-panel[data-cols="2"] .tb-smm-columns { grid-template-columns: 1fr 1fr; }
.tb-smm-panel[data-cols="3"] .tb-smm-columns { grid-template-columns: 1fr 1fr 1fr; }

/* ---- Sections ---- */
.tb-smm-section-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	margin: 0 0 4px;
	padding: 0;
	background: none;
	border: 0;
	font: inherit;
	cursor: default;
	color: var(--tb-smm-muted);
}
.tb-smm-section-title {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
}
.tb-smm-section-caret { display: none; }
.tb-smm-section-subtitle {
	margin: 0 0 12px;
	font-size: 13px;
	line-height: 1.5;
	color: var(--tb-smm-muted);
}

/* On desktop sections are always open — injected inline CSS handles this. */

/* ---- Items ---- */
.tb-smm-items { list-style: none; margin: 0; padding: 0; }
.tb-smm-item  { margin: 0; }

.tb-smm-item-link {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 10px;
	margin: 0 -10px;
	border-radius: 8px;
	text-decoration: none;
	color: var(--tb-smm-ink);
	border: 1px solid transparent;
	transition: background-color .15s ease, border-color .15s ease;
}
.tb-smm-panel[data-card="soft"]   .tb-smm-item-link:hover,
.tb-smm-panel[data-card="flat"]   .tb-smm-item-link:hover {
	background: rgba(32,33,36,.04);
}
.tb-smm-panel[data-card="border"] .tb-smm-item-link {
	border-color: var(--tb-smm-border);
	margin: 0 0 8px;
}
.tb-smm-panel[data-card="border"] .tb-smm-item-link:hover {
	border-color: var(--tb-smm-ink);
}
.tb-smm-item-link:focus-visible {
	outline: 2px solid var(--tb-smm-ink);
	outline-offset: 2px;
}

/* Icons are always charcoal (currentColor). Never red. */
.tb-smm-item-icon {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--tb-smm-ink);
	margin-top: 1px;
}
.tb-smm-item-icon svg { width: var(--tb-smm-icon); height: var(--tb-smm-icon); display: block; }

.tb-smm-item-text  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tb-smm-item-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.tb-smm-item-desc  { font-size: 12.5px; line-height: 1.45; color: var(--tb-smm-muted); }

/* Badges: neutral by design. The CTA is the only red element. */
.tb-smm-badge {
	display: inline-block;
	margin-inline-start: 6px;
	padding: 1px 6px;
	border-radius: 3px;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	vertical-align: middle;
	color: var(--tb-smm-muted);
	background: rgba(32,33,36,.06);
	border: 1px solid var(--tb-smm-border);
}

/* ---- Bottom strip — the single red element ---- */
.tb-smm-strip {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid var(--tb-smm-border);
}
.tb-smm-strip-text {
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--tb-smm-muted);
}
.tb-smm-strip-title { font-weight: 600; color: var(--tb-smm-ink); }
.tb-smm-strip-cta {
	flex: 0 0 auto;
	display: inline-block;
	padding: 10px 18px;
	border-radius: 6px;
	background: var(--tb-smm-red);
	color: #fff;
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	transition: filter .15s ease;
}
.tb-smm-strip-cta:hover   { filter: brightness(.92); color: #fff; }
.tb-smm-strip-cta:focus-visible {
	outline: 2px solid var(--tb-smm-ink);
	outline-offset: 2px;
}

/* ---- RTL (TB-SMM-004) ---- */
/* Target [dir="rtl"] on the panel — written by the renderer in both
   standalone (.tb-smm-panel[dir="rtl"]) and injected contexts. */
.tb-smm-panel[dir="rtl"] .tb-smm-section-toggle { text-align: right; }

/* Brand rule: no letter-spacing in Arabic. */
.tb-smm-panel[dir="rtl"] .tb-smm-section-title,
.tb-smm-panel[dir="rtl"] .tb-smm-badge,
.tb-smm[dir="rtl"]       .tb-smm-section-title,
.tb-smm[dir="rtl"]       .tb-smm-badge { letter-spacing: 0; }

/* ---- Full navigation mode (TB-SMM-010) ----------------------------------
   .tb-smm--full-nav renders the ENTIRE top-level bar. Each .tb-smm-nav-item
   is either a plain link (.tb-smm-nav-link with no panel) or a trigger
   (.tb-smm-trigger-li, reusing the exact same panel/clamping/RTL rules
   already defined above for the single_trigger case — no separate panel
   styling needed). */
.tb-smm--full-nav {
	display: block;
}
.tb-smm-nav-list {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.tb-smm-nav-item {
	position: relative;
	margin: 0;
}
.tb-smm-nav-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 12px;
	margin: 0;
	background: none;
	border: 0;
	border-radius: 6px;
	font: inherit;
	font-weight: 600;
	font-size: 14.5px;
	color: var(--tb-smm-ink);
	text-decoration: none;
	cursor: pointer;
	line-height: 1.2;
	white-space: nowrap;
}
.tb-smm-nav-link:hover {
	background: rgba(32, 33, 36, .04);
}
.tb-smm-nav-link:focus-visible {
	outline: 2px solid var(--tb-smm-ink);
	outline-offset: 2px;
	border-radius: 4px;
}
/* Disclosure buttons (type=label, or type=panel without its own caret-less
   anchor) get the same caret affordance as the single_trigger button. */
.tb-smm-nav-link[aria-expanded] .tb-smm-caret {
	display: inline-flex;
	transition: transform .18s ease;
}
.tb-smm-nav-link[aria-expanded="true"] .tb-smm-caret {
	transform: rotate(180deg);
}

/* type=panel split trigger: a genuinely-navigable link plus a separate caret
   button that toggles the panel, so neither affordance swallows the other. */
.tb-smm-nav-link-group {
	display: inline-flex;
	align-items: center;
	border-radius: 6px;
}
.tb-smm-nav-link-group:hover {
	background: rgba(32, 33, 36, .04);
}
.tb-smm-nav-link-group .tb-smm-nav-link--with-caret {
	padding-inline-end: 4px;
}
.tb-smm-nav-link-group:hover .tb-smm-nav-link--with-caret {
	background: none; /* avoid double-hover background from both the group and the link */
}
.tb-smm-nav-caret-btn {
	display: inline-flex;
	align-items: center;
	padding: 10px 8px 10px 2px;
	margin: 0;
	background: none;
	border: 0;
	cursor: pointer;
	color: var(--tb-smm-ink);
}
.tb-smm-nav-caret-btn:focus-visible {
	outline: 2px solid var(--tb-smm-ink);
	outline-offset: 2px;
	border-radius: 4px;
}
.tb-smm-nav-caret-btn .tb-smm-caret {
	display: inline-flex;
	transition: transform .18s ease;
}
.tb-smm-nav-caret-btn[aria-expanded="true"] .tb-smm-caret {
	transform: rotate(180deg);
}

/* RTL: mirror the bar direction; panel-edge mirroring is already handled by
   the existing .tb-smm-panel[dir="rtl"] rules above (same selector, reused). */
.tb-smm--full-nav[dir="rtl"] .tb-smm-nav-list {
	flex-direction: row-reverse;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
	.tb-smm-caret,
	.tb-smm-section-caret,
	.tb-smm-item-link,
	.tb-smm-strip-cta,
	.tb-smm-nav-link[aria-expanded] .tb-smm-caret,
	.tb-smm-nav-caret-btn .tb-smm-caret { transition: none; }
}
