/*
 * Offerist cabinet themes: html[data-theme="dark"] (default) and html[data-theme="light"].
 * The toggle lives in the profile menu (header.php); the choice is stored per account.
 *
 *  - Tokens (--th-*) below are the single palette. Dark = the landing page palette.
 *  - theme-dark.generated.css (scripts/build_dark_theme.js) maps every light background,
 *    dark text and light border of the cabinet CSS onto these tokens.
 *  - This file adds the hand-tuned shell: page, header, sidebar, forms, scrollbars,
 *    and the light-theme sidebar (so the whole interface is light, not just the content).
 */

/* ---------------------------------------------------------------- tokens */
html[data-theme="dark"] {
	--th-bg: #050816;
	--th-bg-2: #080d1f;
	--th-surface: #0c1530;
	--th-surface-rgb: 12, 21, 48;
	--th-surface-2: #111d3d;
	--th-surface-2-rgb: 17, 29, 61;
	--th-surface-3: #172650;
	--th-surface-3-rgb: 23, 38, 80;
	--th-border: rgba(148, 170, 220, .17);
	--th-border-strong: rgba(148, 170, 220, .3);
	--th-text: #eef3ff;
	--th-text-rgb: 238, 243, 255;
	--th-text-muted: #9aa7c7;
	--th-text-muted-rgb: 154, 167, 199;
	--th-accent: #7df9ff;
	--th-shadow: 0 18px 50px rgba(0, 0, 0, .45);
	--th-violet: #8a5cff;
	--th-violet-rgb: 138, 92, 255;
	/* every block painted white in the light design: one flat surface colour.
	   (A gradient here landed on table cells and field labels and looked patchy.) */
	--th-card-bg: var(--th-surface);

	/* existing project variables */
	--background-color: var(--th-bg);
	--default-color: var(--th-text);
	--sidebar-color: #060b1c;
	--so-border: var(--th-border);
	--so-text: var(--th-text);
	--so-bg: var(--th-surface-2);
	--so-muted: var(--th-text-muted);
	color-scheme: dark;
}

html[data-theme="light"] {
	--th-sidebar-bg: #ffffff;
	--th-sidebar-text: #1d2939;
	--th-sidebar-muted: #667085;
	--th-sidebar-border: #e6eaf2;
	--th-sidebar-hover: rgba(16, 24, 40, .05);
	--th-sidebar-pressed: rgba(16, 24, 40, .09);
	--sidebar-color: var(--th-sidebar-bg);
	color-scheme: light;
}

/* -------------------------------------------------------- theme switch */
.dropdown__item--theme {
	padding: 4px 12px 6px;
}
.theme-switch {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 6px 0;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}
.theme-switch__label {
	font-size: 15px;
}
.theme-switch__input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}
.theme-switch__track {
	position: relative;
	flex: 0 0 40px;
	width: 40px;
	height: 22px;
	border-radius: 999px;
	background: #d0d5dd;
	transition: background .2s ease;
}
.theme-switch__thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(16, 24, 40, .3);
	transition: transform .2s ease;
}
.theme-switch__input:checked + .theme-switch__track {
	background: linear-gradient(135deg, #7df9ff, #8a5cff);
}
.theme-switch__input:checked + .theme-switch__track .theme-switch__thumb {
	transform: translateX(18px);
}
.theme-switch__input:focus-visible + .theme-switch__track {
	box-shadow: 0 0 0 3px rgba(125, 249, 255, .35);
}
.top__user-dropdown {
	min-width: 230px;
	right: 24px; /* keep clear of the fixed UPGRADE/DEBUG side tabs */
}

/* --------------------------------------------------------------- logo */
.logo__image--on-light { display: none; }
html[data-theme="light"] .logo__image--on-dark { display: none; }
html[data-theme="light"] .logo__image--on-light { display: block; }

/* ======================================================== DARK THEME ===== */
html[data-theme="dark"],
html[data-theme="dark"] body {
	background: var(--th-bg);
	color: var(--th-text);
}
/* one soft violet glow behind the content, nothing more */
html[data-theme="dark"] .content {
	background:
		radial-gradient(1100px 620px at 88% -12%, rgba(138, 92, 255, .14), transparent 65%),
		radial-gradient(900px 600px at 0% 110%, rgba(138, 92, 255, .07), transparent 65%),
		var(--th-bg) !important;
	background-attachment: fixed !important;
}

/* cards: violet edge glow on hover */
html[data-theme="dark"] .so-card,
html[data-theme="dark"] .so-kpi-card,
html[data-theme="dark"] .super-card,
html[data-theme="dark"] .of-settings-card,
html[data-theme="dark"] .dc-library__item,
html[data-theme="dark"] .template-library-card {
	transition: border-color .2s ease, box-shadow .2s ease;
}
html[data-theme="dark"] .so-card:hover,
html[data-theme="dark"] .so-kpi-card:hover,
html[data-theme="dark"] .super-card:hover,
html[data-theme="dark"] .of-settings-card:hover,
html[data-theme="dark"] .dc-library__item:hover,
html[data-theme="dark"] .template-library-card:hover {
	border-color: rgba(var(--th-violet-rgb), .32) !important;
}
/* page containers never paint their own (formerly light-grey) background */
html[data-theme="dark"] body .main,
html[data-theme="dark"] body .main__in {
	background: transparent !important;
}

/* header */
html[data-theme="dark"] .top {
	background: rgba(8, 11, 30, .94) !important;
	border-bottom: 1px solid var(--th-border);
	box-shadow: 0 8px 30px rgba(0, 0, 0, .35) !important;
	backdrop-filter: blur(14px);
}
html[data-theme="dark"] .top__user-arrow svg path,
html[data-theme="dark"] .top__burger svg path,
html[data-theme="dark"] .top-alert-ico svg,
html[data-theme="dark"] .top-alert-ico svg path {
	fill: var(--th-text) !important;
}
html[data-theme="dark"] .top__status b,
html[data-theme="dark"] .top__user-name {
	color: var(--th-text);
}
html[data-theme="dark"] .top__status,
html[data-theme="dark"] .top__status em {
	color: var(--th-text-muted);
}
html[data-theme="dark"] .top__burger span,
html[data-theme="dark"] .top__burger::before,
html[data-theme="dark"] .top__burger::after {
	background-color: var(--th-text);
}
html[data-theme="dark"] .top-breadcrumbs,
html[data-theme="dark"] .top-breadcrumbs a {
	color: var(--th-text-muted);
}
html[data-theme="dark"] .top-breadcrumbs a:hover {
	color: var(--th-text);
}

/* sidebar: same deep navy as the landing hero */
html[data-theme="dark"] .sidebar {
	background:
		radial-gradient(420px 320px at 0% 0%, rgba(138, 92, 255, .14), transparent 70%),
		linear-gradient(180deg, #0a0c26 0%, #060918 100%) !important;
	border-right: 1px solid var(--th-border);
}
html[data-theme="dark"] .sidebar .menu {
	background: transparent;
}
/* active menu item: violet into teal */
html[data-theme="dark"] .sidebar .menu__link {
	--sidebar-nav-active-a: rgba(138, 92, 255, .22);
	--sidebar-nav-active-b: rgba(20, 184, 166, .16);
	--sidebar-nav-hover: rgba(255, 255, 255, .06);
}
html[data-theme="dark"] .sidebar .menu__item--active .menu__link,
html[data-theme="dark"] .sidebar .menu__item--navigating .menu__link {
	border-color: rgba(167, 139, 250, .22) !important;
	box-shadow: none !important;
}
html[data-theme="dark"] .sidebar .menu__link::after {
	background: linear-gradient(180deg, #c4b5fd 0%, #7df9ff 100%);
	box-shadow: 0 0 14px rgba(167, 139, 250, .55);
}

/* dropdowns / popovers */
html[data-theme="dark"] .dropdown__content {
	background: var(--th-surface-2);
	border: 1px solid var(--th-border);
	box-shadow: var(--th-shadow);
}
html[data-theme="dark"] .dropdown__link {
	color: var(--th-text);
}
html[data-theme="dark"] .dropdown__link:hover {
	background: rgba(var(--th-text-rgb), .06);
	color: var(--th-text);
}

/* forms: native fields everywhere in the cabinet */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input:not([type]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
	background-color: var(--th-surface-2);
	color: var(--th-text);
	border-color: var(--th-border-strong);
}
/* inputs that sit inside a styled field wrapper (search pills etc.) */
html[data-theme="dark"] .dc-library__search input,
html[data-theme="dark"] .template-library-modal__search-input,
html[data-theme="dark"] .search-input-wrapper input {
	background-color: transparent;
	border-color: transparent;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
	color: rgba(var(--th-text-muted-rgb), .75);
}
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] textarea:-webkit-autofill {
	-webkit-text-fill-color: var(--th-text);
	-webkit-box-shadow: 0 0 0 1000px var(--th-surface-2) inset;
}
html[data-theme="dark"] option {
	background: var(--th-surface-2);
	color: var(--th-text);
}

/* open select lists: keep the highlighted / selected option readable */
html[data-theme="dark"] .select2-dropdown {
	background: var(--th-surface-2);
	border-color: var(--th-border-strong);
}
html[data-theme="dark"] .select2-results__option {
	color: var(--th-text);
}
html[data-theme="dark"] .select2-results__option--highlighted,
html[data-theme="dark"] .select2-results__option--selected,
html[data-theme="dark"] .select2-results__option[aria-selected="true"] {
	color: var(--th-text) !important;
	background: rgba(125, 249, 255, .14) !important;
}

/* tables */
html[data-theme="dark"] table {
	color: var(--th-text);
}
html[data-theme="dark"] th,
html[data-theme="dark"] td {
	border-color: var(--th-border);
}

/* headings and generic text that inherit a hard-coded black */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] .section-title {
	color: var(--th-text);
}
html[data-theme="dark"] hr {
	border-color: var(--th-border);
}

/* dark line icons drawn as <img>: lighten them */
html[data-theme="dark"] img[src*="/action-icons/"],
html[data-theme="dark"] img[src*="/icons/actions/"] {
	filter: invert(.88) hue-rotate(180deg) brightness(1.15);
}

/* dark glyphs that are images: file-type icon, ChatGPT mark */
html[data-theme="dark"] img[src*="file-regular-full.svg"],
html[data-theme="dark"] img[src*="chatgpt-openai.svg"] {
	filter: invert(1) brightness(.92);
}
html[data-theme="dark"] .account-blog-search__box input {
	background-color: transparent;
	border-color: transparent;
}

/* empty donut: JS paints it inline with a light grey ring */
html[data-theme="dark"] .so-donut[style*="#e5e7eb"],
html[data-theme="dark"] .so-donut[style*="229, 231, 235"] {
	background: conic-gradient(var(--th-surface-3) 0 100%) !important;
}

/* scrollbars */
html[data-theme="dark"] * {
	scrollbar-color: rgba(148, 170, 220, .28) transparent;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
	background: rgba(148, 170, 220, .28);
	border-radius: 999px;
}
html[data-theme="dark"] ::-webkit-scrollbar-track {
	background: transparent;
}

/* ======================================================= LIGHT THEME ===== */
/* The whole interface is light: the sidebar follows the content.
   Menu items need real contrast on white: dark ink, solid icons, a tinted hover
   and an unmistakable active item (teal tint + accent bar + bold text). */
html[data-theme="light"] .sidebar {
	background: #ffffff !important;
	border-right: 1px solid #e4e7ec;
	box-shadow: 6px 0 28px rgba(16, 24, 40, .05);
}
html[data-theme="light"] .menu {
	background: transparent;
}
html[data-theme="light"] .sidebar .menu__link {
	--sidebar-nav-hover: #f2f4f7;
	--sidebar-nav-pressed: #e9edf3;
	--sidebar-nav-active-a: rgba(20, 184, 166, .16);
	--sidebar-nav-active-b: rgba(99, 102, 241, .10);
	color: #1d2939 !important;
	font-weight: 600;
}
html[data-theme="light"] .sidebar .menu__text {
	font-weight: 600;
}
html[data-theme="light"] .sidebar .menu__link:hover,
html[data-theme="light"] .sidebar .menu__link:active {
	color: #0b1020 !important;
	border-color: #e4e7ec !important;
}
/* active / navigating item */
html[data-theme="light"] .sidebar .menu__item--active .menu__link,
html[data-theme="light"] .sidebar .menu__item--navigating .menu__link {
	color: #0b1020 !important;
	border-color: rgba(20, 184, 166, .35) !important;
	box-shadow: 0 6px 18px rgba(20, 184, 166, .14) !important;
}
html[data-theme="light"] .sidebar .menu__item--active .menu__text,
html[data-theme="light"] .sidebar .menu__item--navigating .menu__text {
	font-weight: 800;
}
html[data-theme="light"] .sidebar .menu__link::after {
	background: linear-gradient(180deg, #14b8a6 0%, #6366f1 100%);
	box-shadow: 0 0 10px rgba(20, 184, 166, .35);
}
/* icons: white artwork becomes solid dark ink; active icon gets the teal accent */
html[data-theme="light"] .sidebar .menu__ico {
	filter: brightness(0) opacity(.82);
}
html[data-theme="light"] .sidebar .menu__link:hover .menu__ico {
	filter: brightness(0) opacity(1);
}
html[data-theme="light"] .sidebar .menu__item--active .menu__ico,
html[data-theme="light"] .sidebar .menu__item--navigating .menu__ico {
	/* #0d9488 (teal-600) from black */
	filter: brightness(0) saturate(100%) invert(39%) sepia(84%) saturate(1270%) hue-rotate(148deg) brightness(92%) contrast(101%);
}
html[data-theme="light"] .menu__divider {
	background: #e4e7ec !important;
}
html[data-theme="light"] .menu__item--adm {
	border-bottom-color: #e4e7ec;
}
html[data-theme="light"] .logout,
html[data-theme="light"] .sidebar__logout {
	color: #667085;
	background: #ffffff;
}
html[data-theme="light"] .logout__link {
	color: #1d2939;
}
/* collapsed (icon-only) sidebar */
html[data-theme="light"] .body--hide-menu .menu__link:hover {
	background: #f2f4f7 !important;
}
html[data-theme="light"] .body--hide-menu .menu__item--active .menu__link,
html[data-theme="light"] .body--hide-menu .menu__item--active .menu__link:hover {
	background: rgba(20, 184, 166, .14) !important;
}

/* ===================================================== SIDEBAR FOOTER ===== */
/* The copyright line used to float over the scrolling menu and cover the last
   items. It is now a solid strip at the bottom of the sidebar in both themes;
   the menu scrolls underneath it and keeps enough bottom padding to clear it. */
.sidebar .sidebar__logout {
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 3;
	padding: 12px 20px 14px;
	line-height: 1.3;
}
body:not(.body--hide-menu) .sidebar__scroll {
	padding-bottom: 72px !important;
}
html[data-theme="dark"] .sidebar .sidebar__logout {
	background: #060918;
	border-top: 1px solid var(--th-border);
	color: var(--th-text-muted);
}
html[data-theme="light"] .sidebar .sidebar__logout {
	background: #ffffff;
	border-top: 1px solid #e4e7ec;
}

/* ================================================ ACCENT BUTTON STANDARD ===== */
/* One rule for every cyan/green accent button in the cabinet, in both themes:
   dark ink text (#04111b), exactly like "Создать КП". Several buttons used to get
   white text from their own CSS or from link rules (e.g. ".so-table td a"), which
   made the same kind of button look different from page to page. */
.btn:not(.btn--gray):not(.btn--red):not(.btn--soft),
.of-form-btn--add,
.entity-btn--add,
.so-btn--primary,
.so-button--primary,
.ebl-btn--primary,
.upgrade-btn,
.dc-library__new,
.pay-cabinet__btn--primary,
.pay-tariff-card__button.is-filled,
.offerist-pjax-recovery__button {
	color: #04111b !important;
	-webkit-text-fill-color: #04111b !important;
}
.btn:not(.btn--gray):not(.btn--red):not(.btn--soft) .btn__text,
.of-form-btn--add span,
.entity-btn--add span,
.so-btn--primary span,
.so-button--primary span,
.ebl-btn--primary span {
	color: inherit !important;
	-webkit-text-fill-color: inherit !important;
}
/* Secondary "soft" button (.btn--soft, defined in styles.css) — dark theme. */
html[data-theme="dark"] .btn--soft {
	color: hsla(213, 42%, 72%, 1);
	background: var(--th-surface-2);
	border: 1px solid var(--th-border);
}
html[data-theme="dark"] .btn--soft:hover {
	background: rgba(var(--th-text-rgb), .08);
}
/* line icons inside these buttons follow the text colour */
.of-form-btn--add svg,
.entity-btn--add svg,
.so-btn--primary svg,
.so-button--primary svg,
.ebl-btn--primary svg {
	color: #04111b;
	stroke: currentColor;
}

/* Template table select menus in dark mode: selected and hovered rows remain legible. */
html[data-theme="dark"] :is(.template-custom-create-modal__dialog,.of-template-settings-modal__dialog) .select2-dropdown.of-select-dropdown {
  background: #0e1934 !important;
  border-color: #324365 !important;
}
html[data-theme="dark"] :is(.template-custom-create-modal__dialog,.of-template-settings-modal__dialog) .select2-dropdown.of-select-dropdown .select2-results__option {
  background: transparent !important;
  color: #dfe8fa !important;
}
html[data-theme="dark"] :is(.template-custom-create-modal__dialog,.of-template-settings-modal__dialog) .select2-dropdown.of-select-dropdown .select2-results__option--selected {
  background: #1c3458 !important;
  color: #eaf3ff !important;
  font-weight: 600;
}
html[data-theme="dark"] :is(.template-custom-create-modal__dialog,.of-template-settings-modal__dialog) .select2-dropdown.of-select-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
  background: #294b7b !important;
  color: #ffffff !important;
}
html[data-theme="dark"] :is(.template-custom-create-modal__dialog,.of-template-settings-modal__dialog) .select2-dropdown.of-select-dropdown .select2-results__option--disabled {
  background: transparent !important;
  color: #8090ae !important;
}
