/* Domotel new look: "Luz de día" (light) and "Modo noche" (dark).
   Loaded last so it restyles the existing screens without touching their markup. */

:root {
	--font-ui: 'Nunito', 'Segoe UI', Arial, sans-serif;
	--bg: #F5F1E8;
	--surface: #FFFDF8;
	--surface-2: #F3EDE0;
	--line: #E6DFCF;
	--ink: #1B1E23;
	--ink-soft: #6B6455;
	--brand: #F2B620;
	--on-brand: #1B1E23;
	--on-tint: #FFF1C9;
	--accent-ink: #9A6E00;
	--off: #B9B2A3;
	--danger: #B3261E;
	--success: #2E7D32;
	--shadow: 0 10px 30px rgba(27, 30, 35, 0.08);
	--radius: 20px;
	--sidebar-width: 260px;
	color-scheme: light;
}

:root[data-theme="dark"] {
	--bg: #12151B;
	--surface: #1C212A;
	--surface-2: #252B36;
	--line: #2C333F;
	--ink: #EEF0F3;
	--ink-soft: #9AA3AF;
	--brand: #F5C04A;
	--on-brand: #12151B;
	--on-tint: #2E2A1E;
	--accent-ink: #F5C04A;
	--off: #5D6573;
	--danger: #F2867E;
	--success: #7BC97F;
	--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	color-scheme: dark;
}

/* ---------- Base ---------- */

* {
	font-family: var(--font-ui);
}

html,
body,
.primaryBody {
	background: var(--bg);
	color: var(--ink);
}

h1, h2, h3, h4, h5, h6 {
	color: var(--ink);
	font-weight: 800;
}

hr {
	border-top-color: var(--line);
}

a {
	color: var(--accent-ink);
}

/* Page title: the first heading of every screen. */
.hub-page > h3:first-child,
.vistaWeb > h3:first-child,
.vistaMovil > h3:first-child {
	text-align: left !important;
	font-size: 2rem;
	font-weight: 900;
	margin: 0.5rem 0 1rem;
}

/* ponytail: the old cyan accent lives as inline style in ~35 views; recolored here so this branch
   does not touch every view (fewer merge conflicts with main). Replace inline styles when a view is reworked. */
[style*="5bd3f1"] {
	color: var(--accent-ink) !important;
}

/* ---------- Content area next to the sidebar ---------- */

@media (min-width: 1025px) {
	.container-fluid {
		left: calc(var(--sidebar-width) + 32px);
		right: 32px;
		width: auto;
		margin-top: 1.5rem;
		padding-bottom: 2rem;
	}
}

/* ---------- On / off colours ---------- */

.text-roommatik,
.text-roommatik-small,
.text-roommatik-big,
.text-roommatik-big2 {
	color: var(--accent-ink);
}

.text-roommatik-gray,
.text-roommatik-gray-small,
.text-roommatik-gray-big {
	color: var(--off);
}

.text-roommatik-yellow,
.menu-content h5 {
	color: var(--accent-ink);
}

.text-roommatik-red,
.text-roommatik-red-big,
.red {
	color: var(--danger);
}

.text-roommatik-green,
.green {
	color: var(--success);
}

.status-blind {
	color: var(--accent-ink);
}

/* ---------- Cards ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	color: var(--ink);
}

.card-header,
.card-footer {
	background: var(--surface-2);
	border-color: var(--line);
}

.card-header:first-child {
	border-radius: var(--radius) var(--radius) 0 0;
}

.card-text {
	color: var(--ink);
}

/* ---------- Buttons ---------- */

.btn {
	border-radius: 999px;
	font-weight: 700;
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active {
	background: var(--brand);
	border-color: var(--brand);
	color: var(--on-brand);
}

.btn-primary:disabled,
.btn-primary.disabled {
	background-color: var(--brand);
	border-color: var(--brand);
	color: var(--on-brand);
}

.btn-primary:hover {
	filter: brightness(0.95);
}

.btn-outline-primary,
.btn-outline-info {
	color: var(--accent-ink);
	border-color: var(--brand);
}

.btn-outline-primary:hover,
.btn-outline-info:hover,
.btn-outline-primary.active,
.btn-outline-info.active {
	background: var(--brand);
	border-color: var(--brand);
	color: var(--on-brand);
}

.btn-secondary,
.btn-dark {
	background: var(--surface-2);
	border-color: var(--line);
	color: var(--ink);
}

.btn-outline-secondary {
	color: var(--ink-soft);
	border-color: var(--line);
}

.btn-outline-secondary:hover {
	background: var(--surface-2);
	color: var(--ink);
}

.btn:focus,
.form-control:focus {
	box-shadow: 0 0 0 3px rgba(242, 182, 32, 0.45);
}

/* ---------- Switches and sliders ---------- */

input[type="checkbox"].ios-switch + div {
	background-color: var(--surface-2);
	border-color: var(--line);
}

input[type="checkbox"].ios-switch:checked + div,
input[type="checkbox"].green.ios-switch:checked + div {
	background-color: var(--brand);
	border-color: var(--brand);
	box-shadow: inset 0 0 0 10px var(--brand);
}

input[type="checkbox"].ios-switch:checked + div > div {
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input[type="range"] {
	accent-color: var(--brand);
}

/* ---------- Forms ---------- */

.form-control,
/* Beats the unscoped login rule for input[type=password] in custom.css. */
.form-control[type=password],
.custom-select,
select,
textarea {
	background-color: var(--surface);
	border-color: var(--line);
	color: var(--ink);
	border-radius: 12px;
}

.form-control:focus {
	background-color: var(--surface);
	border-color: var(--brand);
	color: var(--ink);
}

.form-control::placeholder {
	color: var(--ink-soft);
}

.form-control:disabled,
.form-control[readonly] {
	background-color: var(--bg);
	color: var(--ink-soft);
}

.input-group-addon,
.input-group-text {
	background: var(--surface-2);
	border-color: var(--line);
	color: var(--ink);
}

/* ---------- Tables ---------- */

.table {
	color: var(--ink);
}

.table th,
.table td,
.table thead th,
.table-bordered,
.table-bordered th,
.table-bordered td {
	border-color: var(--line);
}

.table thead th,
.thead-light th {
	background: var(--surface-2) !important;
	color: var(--ink-soft) !important;
	border-color: var(--line) !important;
}

.table-striped tbody tr:nth-of-type(odd) {
	background-color: var(--surface-2);
}

.table-hover tbody tr:hover {
	background-color: var(--on-tint);
	color: var(--ink);
}

/* ---------- Modals and dropdowns ---------- */

.modal-content,
.dropdown-menu,
.list-group-item {
	background: var(--surface);
	border-color: var(--line);
	color: var(--ink);
}

.modal-content {
	border-radius: var(--radius);
}

.modal-header,
.modal-footer {
	border-color: var(--line);
}

.close {
	color: var(--ink);
}

.dropdown-item {
	color: var(--ink);
}

.dropdown-item:hover {
	background: var(--surface-2);
}

/* ---------- Breadcrumb ---------- */

#breadcrumb li i {
	background: var(--surface-2);
	color: var(--ink);
}

/* ---------- Sidebar ---------- */

.nav-side-menu {
	width: var(--sidebar-width);
	background: var(--surface-2);
	box-shadow: none;
	border-right: 1px solid var(--line);
	font-size: 1rem;
	font-weight: 600;
	padding: 1.5rem 1rem 0.75rem;
	gap: 0.75rem;
}

.nav-side-menu .brand {
	background: transparent;
	text-align: left;
	line-height: 1;
	padding: 0 0.5rem;
}

.nav-side-menu .brand img {
	width: 150px !important;
}

.nav-side-menu .brand .logo-dark,
:root[data-theme="dark"] .nav-side-menu .brand .logo-light {
	display: none;
}

:root[data-theme="dark"] .nav-side-menu .brand .logo-dark {
	display: inline;
}

.nav-side-menu ul,
.nav-side-menu li {
	line-height: 1.4;
}

.nav-side-menu .menu-content li {
	border-radius: 14px;
	margin-bottom: 4px;
	transition: background-color 0.15s ease;
}

.nav-side-menu li:hover {
	border-left: 0;
	background-color: var(--surface);
	transition: background-color 0.15s ease;
}

.nav-side-menu .menu-content li.is-active,
.nav-side-menu .menu-content li.is-active:hover {
	background: var(--brand);
}

.nav-side-menu .menu-content li a {
	display: flex !important;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem 0.85rem;
	color: var(--ink);
}

.nav-side-menu .menu-content li.is-active a,
.nav-side-menu .menu-content li.is-active a i {
	color: var(--on-brand);
	font-weight: 900;
}

.nav-side-menu .menu-list .menu-content li * {
	font-size: 1.05rem;
}

.nav-side-menu li a i {
	width: 1.5rem;
	padding: 0;
	text-align: center;
	color: var(--ink-soft);
}

.user-info-bar {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 16px;
	padding: 0.6rem 0.75rem;
	gap: 0.6rem;
}

.user-info-icon {
	color: var(--accent-ink);
}

.user-info-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	line-height: 1.2;
}

.user-info-name {
	color: var(--ink);
	font-size: 1rem;
	font-weight: 800;
}

.user-info-role {
	color: var(--ink-soft);
	font-size: 0.85rem;
}

.btn-logout,
.btn-theme {
	color: var(--ink-soft);
	border: 1px solid var(--line);
	background: transparent;
	border-radius: 10px;
	padding: 2px 8px;
}

.btn-theme:hover {
	color: var(--ink);
	background: var(--surface-2);
}

.app-version {
	color: var(--ink-soft);
}

.nav-side-menu .menu-list::-webkit-scrollbar-track {
	background: transparent;
}

.nav-side-menu .menu-list::-webkit-scrollbar-thumb {
	background: var(--line);
}

/* Top-right of the page (scrolls away with it); beside the menu button on the mobile top bar. */
.header-clock {
	position: absolute;
	top: 0.75rem;
	right: 1.5rem;
	z-index: 20;
	color: var(--ink);
	font-size: 1.25rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

@media (max-width: 1025px) {
	.header-clock {
		top: 1.1rem;
		right: 4.5rem;
	}

	.nav-side-menu {
		width: 100%;
		border-right: 0;
		border-bottom: 1px solid var(--line);
	}

	.nav-side-menu .toggle-btn {
		background: var(--surface);
		color: var(--ink);
	}

	.nav-side-menu li a i {
		margin-top: 0;
		font-size: 1.1rem;
	}

	.nav-side-menu {
		padding: 0.75rem 1rem;
		gap: 0.5rem;
	}

	.nav-side-menu .brand img {
		width: 110px !important;
	}

	.nav-side-menu .toggle-btn {
		top: 0.6rem;
		right: 1rem;
		font-size: 2rem !important;
		width: 2.6rem;
		border: 1px solid var(--line);
		border-radius: 12px;
	}

	.app-version {
		display: none;
	}
}

/* ---------- Hub pages (Ajustes, Instalación) ---------- */

.hub-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 1rem;
}

.hub-card {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	padding: 1.25rem 1.4rem;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	color: var(--ink) !important;
	text-decoration: none !important;
	transition: transform 0.15s ease, border-color 0.15s ease;
}

.hub-card:hover {
	border-color: var(--brand);
	transform: translateY(-2px);
}

.hub-card i {
	font-size: 1.6rem;
	color: var(--accent-ink);
}

.hub-card strong {
	font-size: 1.15rem;
	font-weight: 800;
}

.hub-card span {
	color: var(--ink-soft);
}

.page-tabs {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.page-tabs a {
	padding: 0.4rem 1rem;
	border-radius: 999px;
	border: 1px solid var(--line);
	color: var(--ink);
	font-weight: 700;
	text-decoration: none;
}

.page-tabs a.is-active {
	background: var(--brand);
	border-color: var(--brand);
	color: var(--on-brand);
}

/* ---------- Floating buttons and loading ---------- */

.float,
.floatMovil,
.microMovil,
.microWeb,
.microWeb3,
.microWeb4 {
	background-color: var(--brand) !important;
	color: var(--on-brand) !important;
	box-shadow: var(--shadow) !important;
}

.float2,
.floatMovil2,
.microWeb2 {
	background-color: var(--success) !important;
	color: var(--surface) !important;
}

.spinnerLoading > div {
	background-color: var(--brand);
}

.loading:before {
	background-color: rgba(18, 21, 27, 0.45);
}

/* ---------- Registro de actividad ---------- */

.activity-intro {
	color: var(--ink-soft);
}

.activity-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem 1rem;
	margin-bottom: 1rem;
}

.activity-filter .form-group {
	flex: 1 1 10rem;
	margin-bottom: 0;
}

.activity-message {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1rem;
	margin-bottom: 1rem;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	color: var(--ink-soft);
}

.activity-message-danger {
	color: var(--danger);
	border-color: var(--danger);
}

.activity-table .activity-date {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.activity-detail {
	display: block;
	font-weight: 400;
	color: var(--ink-soft);
	overflow-wrap: anywhere;
}

.activity-empty {
	text-align: center;
	color: var(--ink-soft);
}

.activity-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.15rem 0.6rem;
	border-radius: 999px;
	border: 1px solid currentColor;
	font-size: 0.8rem;
	font-weight: 700;
	white-space: nowrap;
}

.activity-badge::before {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: currentColor;
}

.activity-badge-ok {
	color: var(--success);
}

.activity-badge-warn {
	color: var(--accent-ink);
}

.activity-badge-ko {
	color: var(--danger);
}

/* Phones: one stacked card per entry instead of a four-column table. */
@media (max-width: 575.98px) {
	.activity-table thead {
		display: none;
	}

	.activity-table tr {
		display: grid;
		grid-template-columns: 1fr auto;
		grid-template-areas: "date result" "user user" "action action";
		gap: 0.25rem 0.75rem;
		padding: 0.75rem 1rem;
		border-top: 1px solid var(--line);
	}

	.activity-table tbody tr:first-child {
		border-top: 0;
	}

	.activity-table td {
		display: block;
		padding: 0;
		border: 0;
	}

	.activity-table .activity-date { grid-area: date; color: var(--ink-soft); }
	.activity-table .activity-user { grid-area: user; font-weight: 800; }
	.activity-table .activity-action { grid-area: action; }
	.activity-table .activity-result { grid-area: result; }
}

/* ---------- Correo saliente y avisos por Telegram ---------- */

/* custom.css floats card labels to the right on narrow screens. */
.mail-settings .card-body label,
.telegram-settings .card-body label {
	float: none;
	margin-top: 0;
}

.mail-settings .form-check,
.telegram-settings .form-check {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding-left: 0;
}

/* Static checkboxes: Bootstrap's absolute ones end up under the scrolling device list and cannot be clicked. */
.mail-settings .form-check-input,
.telegram-settings .form-check-input {
	position: static;
	margin: 0;
}

.telegram-remotes {
	max-height: 26rem;
	overflow-y: auto;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
}

.telegram-remote + .telegram-remote {
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px solid var(--line);
}

.telegram-remote-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.75rem;
	margin-bottom: 0.25rem;
}

.telegram-remote-head .btn-link {
	margin-left: auto;
	padding: 0;
}

/* ---------- Contraseña olvidada (la tarjeta de login no cambia con el tema: colores fijos) ---------- */

/* custom.css only sizes input[type=submit]; the single sign-on button is a plain button. */
.loginmodal-container .loginmodal-submit {
	display: block;
	width: 100%;
	margin-bottom: 10px;
}

.loginmodal-container .login-sso-help {
	margin-bottom: 1rem;
	text-align: center;
}

.loginmodal-container .login-link {
	display: block;
	margin-top: 0.5rem;
	text-align: center;
	color: #4d4d4d;
	text-decoration: underline;
}

.loginmodal-container label,
.loginmodal-container .login-help {
	color: #333;
}

.loginmodal-container .login-error {
	color: #B3261E;
}

/* ---------- Perfiles ---------- */

.profiles-page .card-body label {
	float: none;
	margin-top: 0;
}

.profiles-legend {
	font-size: 1rem;
	font-weight: 800;
	margin-bottom: 0.5rem;
}

.profiles-checks {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
	gap: 0.25rem 1rem;
}

.profiles-chips {
	gap: 0.5rem;
}

.profiles-scope {
	margin-top: 0.75rem;
	padding: 1rem;
	border: 1px solid var(--line);
	border-radius: 12px;
}

.profiles-devices {
	max-height: 18rem;
	overflow-y: auto;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
}

/* Static checkboxes: Bootstrap's absolute ones end up under the scrolling device list and cannot be clicked. */
.profiles-page .form-check {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding-left: 0;
}

.profiles-page .form-check-input {
	position: static;
	margin: 0;
}

.profiles-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

/* Fan glyph (Font Awesome Free "fan", CC BY 4.0): the bundled FA 5.0.6 predates it. */
.fa-fan:before {
	content: "";
	display: inline-block;
	width: 1em;
	height: 1em;
	vertical-align: -0.125em;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M352.57 128c-28.09 0-54.09 4.52-77.06 12.86l12.41-123.11C289 7.31 279.81-1.18 269.33.13 189.63 10.13 128 77.64 128 159.43c0 28.09 4.52 54.09 12.86 77.06L17.75 224.08C7.31 223-1.18 232.19.13 242.67c10 79.7 77.51 141.33 159.3 141.33 28.09 0 54.09-4.52 77.06-12.86l-12.41 123.11c-1.05 10.43 8.11 18.93 18.59 17.62 79.7-10 141.33-77.51 141.33-159.3 0-28.09-4.52-54.09-12.86-77.06l123.11 12.41c10.44 1.05 18.93-8.11 17.62-18.59-10-79.7-77.51-141.33-159.3-141.33zM256 288a32 32 0 1 1 32-32 32 32 0 0 1-32 32z'/%3E%3C/svg%3E") no-repeat center / contain;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M352.57 128c-28.09 0-54.09 4.52-77.06 12.86l12.41-123.11C289 7.31 279.81-1.18 269.33.13 189.63 10.13 128 77.64 128 159.43c0 28.09 4.52 54.09 12.86 77.06L17.75 224.08C7.31 223-1.18 232.19.13 242.67c10 79.7 77.51 141.33 159.3 141.33 28.09 0 54.09-4.52 77.06-12.86l-12.41 123.11c-1.05 10.43 8.11 18.93 18.59 17.62 79.7-10 141.33-77.51 141.33-159.3 0-28.09-4.52-54.09-12.86-77.06l123.11 12.41c10.44 1.05 18.93-8.11 17.62-18.59-10-79.7-77.51-141.33-159.3-141.33zM256 288a32 32 0 1 1 32-32 32 32 0 0 1-32 32z'/%3E%3C/svg%3E") no-repeat center / contain;
}
