/* PLnet Dark Mode for Cassiopeia */

/* Hide Joomla's built-in color scheme selector from user profile (PLnet uses own toggle) */
.com_users [name="jform[params][colorScheme]"],
.com_users label[for="jform_params_colorScheme"] {
	display: none;
}

/* Bootstrap 5.3 dark mode variables */
:root[data-bs-theme="dark"] {
	color-scheme: dark;

	/* Core */
	--body-color: #dee2e6;
	--body-color-rgb: 222, 226, 230;
	--body-bg: #212529;
	--body-bg-rgb: 33, 37, 41;
	--emphasis-color: #fff;
	--emphasis-color-rgb: 255, 255, 255;

	/* Secondary/Tertiary */
	--secondary-color: #dee2e6bf;
	--secondary-color-rgb: 222, 226, 230;
	--secondary-bg: #343a40;
	--secondary-bg-rgb: 52, 58, 64;
	--tertiary-color: #dee2e680;
	--tertiary-color-rgb: 222, 226, 230;
	--tertiary-bg: #2b3035;
	--tertiary-bg-rgb: 43, 48, 53;

	/* Text emphasis */
	--primary-text-emphasis: #7fa5d4;
	--secondary-text-emphasis: #a3a8ad;
	--success-text-emphasis: #8fb198;
	--info-text-emphasis: #7fa5d4;
	--warning-text-emphasis: #f6ce95;
	--danger-text-emphasis: #dc7e7d;
	--light-text-emphasis: #f8f9fa;
	--dark-text-emphasis: #dee2e6;

	/* Subtle backgrounds */
	--primary-bg-subtle: #081525;
	--secondary-bg-subtle: #141618;
	--success-bg-subtle: #0e1911;
	--info-bg-subtle: #081525;
	--warning-bg-subtle: #302310;
	--danger-bg-subtle: #270808;
	--light-bg-subtle: #343a40;
	--dark-bg-subtle: #1a1d20;

	/* Subtle borders */
	--primary-border-subtle: #193f6e;
	--secondary-border-subtle: #3d4247;
	--success-border-subtle: #294b32;
	--info-border-subtle: #193f6e;
	--warning-border-subtle: #90682f;
	--danger-border-subtle: #761817;
	--light-border-subtle: #495057;
	--dark-border-subtle: #343a40;

	/* Links */
	--link-color: #689ddf;
	--link-hover-color: #8ccce2;
	--link-color-rgb: 111, 191, 219;
	--link-hover-color-rgb: 140, 204, 226;

	/* Misc */
	--heading-color: inherit;
	--code-color: #c17196;
	--highlight-color: #dee2e6;
	--highlight-bg: #664808;
	--border-color: #495057;
	--border-color-translucent: #ffffff26;

	/* Forms */
	--form-valid-color: #8fb198;
	--form-valid-border-color: #8fb198;
	--form-invalid-color: #dc7e7d;
	--form-invalid-border-color: #dc7e7d;

	/* Cassiopeia custom variables */
	--template-bg-light: #1a1d20;
	--template-text-dark: #dee2e6;
	--template-text-light: #f8f9fa;
	--template-link-color: var(--link-color);
	--template-special-color: #6fbfdb;
	--cassiopeia-color-primary: #4879dd;
	--cassiopeia-color-link: #6fbfdb;
	--cassiopeia-color-hover: #738df7;
}

/* Bootstrap utility bg-* overrides (used e.g. by com_users MFA status) */
[data-bs-theme="dark"] .bg-light {
	background-color: #2b3035 !important;
	color: #dee2e6;
}

/* MFA method icons are designed for light background – keep them light */
[data-bs-theme="dark"] .com-users-methods-list-method-image.bg-light {
	background-color: #dee2e6 !important;
}

/* Navbar brand */
[data-bs-theme="dark"] .navbar-brand a {
	color: #dee2e6;
}

/* Site grid background */
[data-bs-theme="dark"] .site-grid {
	background-color: var(--body-bg);
}

/* Cards */
[data-bs-theme="dark"] .card {
	--bs-card-bg: #2b3035;
	--bs-card-border-color: #495057;
	--bs-card-color: #dee2e6;
}

[data-bs-theme="dark"] .card-header {
	border-bottom-color: #495057;
}

/* Tables */
[data-bs-theme="dark"] .table {
	--bs-table-bg: transparent;
	--bs-table-color: #dee2e6;
	--bs-table-border-color: #495057;
	--bs-table-striped-bg: #2c3034;
	--bs-table-striped-color: #dee2e6;
	--bs-table-hover-bg: #323539;
	--bs-table-hover-color: #dee2e6;
}

/* Alerts */
[data-bs-theme="dark"] .alert-info {
	background: #081525;
	color: #c6defd;
	border-color: #7a8da6;
}

[data-bs-theme="dark"] .alert-warning {
	--bs-alert-bg: #302310;
	--bs-alert-color: #f6ce95;
	--bs-alert-border-color: #90682f;
}

[data-bs-theme="dark"] .alert-danger {
	--bs-alert-bg: #270808;
	--bs-alert-color: #dc7e7d;
	--bs-alert-border-color: #761817;
}

/* Joomla web component <joomla-alert> – has hardcoded white bg in cassiopeia */
[data-bs-theme="dark"] #system-message-container joomla-alert[type="success"],
[data-bs-theme="dark"] #system-message-container joomla-alert[type="message"] {
	background-color: #0e1911;
	color: #8fb198;
}

[data-bs-theme="dark"] #system-message-container joomla-alert[type="info"],
[data-bs-theme="dark"] #system-message-container joomla-alert[type="notice"] {
	background-color: #081525;
	color: #7fa5d4;
}

[data-bs-theme="dark"] #system-message-container joomla-alert[type="warning"] {
	background-color: #302310;
	color: #f6ce95;
}

[data-bs-theme="dark"] #system-message-container joomla-alert[type="error"],
[data-bs-theme="dark"] #system-message-container joomla-alert[type="danger"] {
	background-color: #270808;
	color: #dc7e7d;
}

/* Joomla switcher field (Ano/Ne toggle) */
[data-bs-theme="dark"] .switcher .toggle-outside {
	background: #495057;
	border-color: #6c757d;
}

[data-bs-theme="dark"] .switcher .toggle-inside {
	background: #adb5bd;
}

[data-bs-theme="dark"] .switcher input ~ input:checked ~ .toggle-outside {
	background: #2f7d32;
}

[data-bs-theme="dark"] .switcher input ~ input:checked ~ .toggle-outside .toggle-inside {
	background: #fff;
}

[data-bs-theme="dark"] .alert-success {
	--bs-alert-bg: #0e1911;
	--bs-alert-color: #8fb198;
	--bs-alert-border-color: #294b32;
}

/* Buttons */
[data-bs-theme="dark"] .btn-primary:hover, .btn-primary:focus {
    background-color: var(--cassiopeia-color-hover);
    border-color: var(--cassiopeia-color-hover);
}

[data-bs-theme="dark"] .btn-outline-primary {
	background-color: #010156;
	border-color: #909090;
	color: #ffffff;
}

[data-bs-theme="dark"] .com-users-methods-list-method-addnew {
	background-color: #2b3035;
	border-color: #495057;
	color: #dee2e6;
}

[data-bs-theme="dark"] .com-users-methods-list-method-addnew:hover {
	background-color: #343a40;
}


[data-bs-theme="dark"] .input-group-text {
	--bs-btn-color: transparent;
	background-color: #a3a8ad;
	border-color: #495057;
	color: var(--gray-800);
}

[data-bs-theme="dark"] .btn-secondary {
	--bs-btn-color: transparent;
	background-color: #a3a8ad;
	border-color: #495057;
}

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .custom-select {
	background-color: #2b3035;
	background-image: url("../images/select-bg-dark.svg");
	color: #dee2e6;
	border-color: #495057;
}

[data-bs-theme="dark"] .form-control:focus {
	background-color: #343a40;
	border-color: var(--cassiopeia-color-primary);
	color: #dee2e6;
}

[data-bs-theme="dark"] .choices {
	background-color: #2b3035;
	border-color: #495057;
	color: #dee2e6;
}

[data-bs-theme="dark"] .choices .choices__inner,
[data-bs-theme="dark"] .choices[data-type*="select-one"] .choices__inner,
[data-bs-theme="dark"] .choices[data-type*="select-multiple"] .choices__inner {
	background-color: #2b3035;
	background-image: url("../images/select-bg-dark.svg");
	color: #dee2e6;
}

[data-bs-theme="dark"] .choices__list--dropdown,
[data-bs-theme="dark"] .choices__list[aria-expanded] {
	background-color: #2b3035;
	border-color: #495057;
}

[data-bs-theme="dark"] .choices__list--dropdown .choices__item--selectable.is-highlighted {
	background-color: #343a40;
	color: #dee2e6;
}

[data-bs-theme="dark"] .choices .choices__input {
	background-color: transparent;
	color: #dee2e6;
}

[data-bs-theme="dark"] .com-users-profile__multifactor {
	background-color: #2b3035;
	border-color: #495057;
	color: #dee2e6;
}

/* Login form */
[data-bs-theme="dark"] .login .card,
[data-bs-theme="dark"] .com_users .card {
	--bs-card-bg: #2b3035;
}

/* Footer */
[data-bs-theme="dark"] .container-footer {
	background-color: #1a1d20;
	color: #a3a8ad;
}

/* Badges */
[data-bs-theme="dark"] .badge.bg-warning {
	color: #212529 !important;
}

/* Text muted */
[data-bs-theme="dark"] .text-muted {
	color: #9ca3ab !important;
}

/* HR */
[data-bs-theme="dark"] hr {
	border-color: #dee2e6;
}

/* Sidebar */
[data-bs-theme="dark"] .container-sidebar-right .card,
[data-bs-theme="dark"] .container-sidebar-left .card {
	--bs-card-bg: #2b3035;
}

/* Header toggle */
.container-header .grid-child-brand {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.theme-toggle-header {
	padding: 0.45rem 0.55rem;
	font-size: 1.5rem;
	line-height: 1;
	border-radius: 0.375rem;
	color: #fff;
	border-color: #fff;
	background-color: transparent;
}

.theme-toggle-header:hover {
	color: #fff;
	border-color: #656a70;
	background-color: #656a70;
}

/* Theme switcher */
.theme-switcher {
	display: flex;
	gap: 0.25rem;
	justify-content: center;
	margin-top: 1rem;
}

.theme-switcher .btn {
	padding: 0.25rem 0.5rem;
	font-size: 0.8rem;
}

.theme-switcher .btn.active {
	font-weight: bold;
}

[data-bs-theme="dark"] .theme-switcher .btn-outline-secondary {
	--bs-btn-color: transparent;
	background-color: #a3a8ad;
	--bs-btn-border-color: #656a70;
}

[data-bs-theme="dark"] .theme-switcher .btn-outline-secondary.active {
	--bs-btn-active-bg: #6fbfdb;
	--bs-btn-active-border-color: #6fbfdb;
	--bs-btn-active-color: #212529;
	background-color: #6fbfdb;
	border-color: #6fbfdb;
	color: #212529;
}
