/* ════════════════════════════════════════════════════════════════════════════
   SGA BRANDING — Formatic Labs UI, Estilo Apple v1 (adaptado a RosarioSIS)
   Todo vive dentro de .sga-ui: las pantallas nativas de RosarioSIS no se tocan.
   Modo: automático (sin atributo), claro (data-theme="light"), oscuro (data-theme="dark").
   Acento: verde (defecto), data-accent="indigo" o "azul". Bloques de acento al final.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── TOKENS: MODO CLARO ───────────────────────────────────────────────────── */
.sga-ui {
	color-scheme: light;
	--accent: #1A7F45;
	--accent-hover: #156B3A;
	--accent-soft: rgba(26, 127, 69, 0.12);
	--accent-border: rgba(26, 127, 69, 0.32);
	--on-accent: #FFFFFF;
	--green: #34C759;   --green-text: #248A3D;  --green-soft: rgba(52, 199, 89, 0.14);
	--yellow: #FF9F0A;  --yellow-text: #B25000; --yellow-soft: rgba(255, 159, 10, 0.16);
	--red: #FF3B30;     --red-text: #D70015;    --red-soft: rgba(255, 59, 48, 0.12);
	--bg: #F2F2F7;
	--surface: #FFFFFF;
	--surface3: #E5E5EA;
	--fill: rgba(118, 118, 128, 0.12);
	--fill-strong: rgba(118, 118, 128, 0.2);
	--text: #1D1D1F;
	--text2: #6E6E73;
	--text3: #8E8E93;
	--border: rgba(60, 60, 67, 0.14);
	--border2: rgba(60, 60, 67, 0.29);
	--radius-container: 20px;
	--radius-card: 14px;
	--radius-control: 10px;
	--radius-capsule: 9999px;
	--control-h: 36px;
	--icon-btn: 34px;
	--font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
	--dur-fast: 120ms;
	--dur: 200ms;
}

/* ── TOKENS: MODO OSCURO ──────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
	.sga-ui:not([data-theme="light"]) {
		color-scheme: dark;
		--accent: #248A3D; --accent-hover: #2EA04C; --accent-soft: rgba(36, 138, 61, 0.22); --accent-border: rgba(36, 138, 61, 0.5);
		--green: #30D158; --green-text: #30D158; --green-soft: rgba(48, 209, 88, 0.16);
		--yellow: #FF9F0A; --yellow-text: #FFB340; --yellow-soft: rgba(255, 159, 10, 0.18);
		--red: #FF453A; --red-text: #FF6961; --red-soft: rgba(255, 69, 58, 0.16);
		--bg: #000000; --surface: #1C1C1E; --surface3: #3A3A3C;
		--fill: rgba(118, 118, 128, 0.24); --fill-strong: rgba(118, 118, 128, 0.36);
		--text: #F5F5F7; --text2: #AEAEB2; --text3: #8D8D93;
		--border: rgba(84, 84, 88, 0.5); --border2: rgba(84, 84, 88, 0.8);
	}
}
.sga-ui[data-theme="dark"] {
	color-scheme: dark;
	--accent: #248A3D; --accent-hover: #2EA04C; --accent-soft: rgba(36, 138, 61, 0.22); --accent-border: rgba(36, 138, 61, 0.5);
	--green: #30D158; --green-text: #30D158; --green-soft: rgba(48, 209, 88, 0.16);
	--yellow: #FF9F0A; --yellow-text: #FFB340; --yellow-soft: rgba(255, 159, 10, 0.18);
	--red: #FF453A; --red-text: #FF6961; --red-soft: rgba(255, 69, 58, 0.16);
	--bg: #000000; --surface: #1C1C1E; --surface3: #3A3A3C;
	--fill: rgba(118, 118, 128, 0.24); --fill-strong: rgba(118, 118, 128, 0.36);
	--text: #F5F5F7; --text2: #AEAEB2; --text3: #8D8D93;
	--border: rgba(84, 84, 88, 0.5); --border2: rgba(84, 84, 88, 0.8);
}

/* Pantallas táctiles: áreas mínimas de 44 px (Apple HIG) */
@media (pointer: coarse) {
	.sga-ui { --control-h: 44px; --icon-btn: 44px; }
}

/* ── LOGIN: pie "Acerca de" (el texto lo inyecta functions.php) ───────────── */
.about-rosariosis p.center::before {
	display: block;
	margin-bottom: 0.5em;
	font-weight: 600;
}

/* ── BASE DEL CONTENEDOR ──────────────────────────────────────────────────── */
.sga-ui {
	box-sizing: border-box;
	width: 100%;
	max-width: 1200px;
	margin: 8px auto 16px;
	padding: 20px;
	border-radius: var(--radius-container);
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-ui);
	font-size: 14px;
	line-height: 1.4;
	letter-spacing: -0.01em;
	-webkit-font-smoothing: antialiased;
}
.sga-ui *, .sga-ui *::before, .sga-ui *::after { box-sizing: border-box; }
.sga-ui .ico { width: 20px; height: 20px; flex-shrink: 0; display: block; }
.sga-ui :focus-visible { outline: 3px solid var(--accent-border); outline-offset: 2px; }
.sga-ui a { color: var(--accent); }

/* ── CABECERA Y PESTAÑAS ──────────────────────────────────────────────────── */
.sga-ui .sga-header { margin-bottom: 14px; }
.sga-ui .sga-title {
	margin: 0; padding: 0; border: 0;
	font-family: var(--font-ui); font-size: 26px; font-weight: 700; letter-spacing: -0.025em; color: var(--text);
}
.sga-ui .sga-subtitle { margin: 4px 0 0; font-size: 13px; color: var(--text2); }

/* Control segmentado */
.sga-ui .filter-tabs {
	display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
	padding: 2px; border-radius: 9px; background: var(--fill);
	overflow-x: auto; scrollbar-width: none;
}
.sga-ui .filter-tabs::-webkit-scrollbar { display: none; }
.sga-ui .filter-tab {
	display: flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 30px; padding: 0 12px; border-radius: 7px;
	font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none;
	white-space: nowrap; cursor: pointer; user-select: none;
	transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.sga-ui .filter-tab .ico { width: 16px; height: 16px; color: var(--text2); }
.sga-ui .filter-tab:hover { color: var(--text); }
.sga-ui .filter-tab.active {
	background: var(--surface); font-weight: 600;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.sga-ui .filter-tab.active .ico { color: var(--accent); }
@media (prefers-color-scheme: dark) {
	.sga-ui:not([data-theme="light"]) .filter-tab.active { background: var(--surface3); }
}
.sga-ui[data-theme="dark"] .filter-tab.active { background: var(--surface3); }
.sga-ui .sga-tabs { margin-bottom: 4px; }

/* ── PANEL, SECCIONES Y LISTAS AGRUPADAS ──────────────────────────────────── */
.sga-ui .sga-panel { padding-top: 4px; }
.sga-ui .section-title {
	margin: 18px 12px 6px; font-size: 12.5px; font-weight: 400;
	color: var(--text2); text-transform: uppercase; letter-spacing: 0.02em;
}
.sga-ui .sga-group {
	margin: 0; padding: 12px; list-style: none;
	background: var(--surface); border-radius: var(--radius-card);
}
.sga-ui .sga-hint { margin: 6px 12px 0; font-size: 12.5px; color: var(--text2); }
.sga-ui .sga-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

/* Filas tipo Ajustes */
.sga-ui .sga-rows { padding: 0; overflow: hidden; }
.sga-ui .info-row {
	position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
	min-height: 44px; padding: 10px 12px; font-size: 14px;
}
.sga-ui .info-row + .info-row::before {
	content: ''; position: absolute; top: 0; left: 12px; right: 0; height: 0.5px; background: var(--border);
}
.sga-ui .info-key { color: var(--text); }

/* ── ORDEN DEL MENÚ ───────────────────────────────────────────────────────── */
.sga-ui .sga-menu-order { padding: 0; overflow: hidden; }
.sga-ui .rr-item {
	position: relative; display: flex; align-items: center; gap: 10px;
	min-height: 48px; margin: 0; padding: 6px 8px 6px 12px;
	background: var(--surface); cursor: grab;
	transition: background var(--dur-fast) var(--ease);
}
.sga-ui .rr-item + .rr-item::before {
	content: ''; position: absolute; top: 0; left: 12px; right: 0; height: 0.5px; background: var(--border);
}
.sga-ui .rr-item:hover { background: var(--fill); }
.sga-ui .rr-item.sga-dragging { opacity: 0.4; }
.sga-ui .sga-grip { color: var(--text3); display: grid; place-items: center; }
.sga-ui .rr-item .module-icon { flex-shrink: 0; }
.sga-ui .rr-titulo {
	flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sga-ui .rr-item.sga-inactive .rr-titulo { color: var(--text3); font-weight: 500; }

/* ── CONTROLES ────────────────────────────────────────────────────────────── */
.sga-ui .icon-btn {
	width: var(--icon-btn); height: var(--icon-btn); min-width: 0; padding: 0; margin: 0;
	display: grid; place-items: center; flex-shrink: 0;
	border: 0; border-radius: 50%; background: var(--fill); background-image: none;
	color: var(--accent); cursor: pointer; box-shadow: none;
	transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.sga-ui .icon-btn:hover { background: var(--fill-strong); }
.sga-ui .icon-btn:active { transform: scale(0.94); }
.sga-ui .icon-btn .ico { width: 18px; height: 18px; }

.sga-ui .cfg-save-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: var(--control-h); padding: 0 18px; margin: 0;
	border: 0; border-radius: var(--radius-capsule); background: var(--accent); background-image: none;
	color: var(--on-accent); font-family: var(--font-ui); font-size: 14px; font-weight: 600;
	cursor: pointer; white-space: nowrap; box-shadow: none; text-shadow: none;
	transition: filter var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.sga-ui .cfg-save-btn:hover, .sga-ui .cfg-save-btn:focus { background: var(--accent); color: var(--on-accent); filter: brightness(1.06); }
.sga-ui .cfg-save-btn:active { transform: scale(0.97); }

.sga-ui .cfg-field + .cfg-field { margin-top: 14px; }
.sga-ui .cfg-label { display: block; margin: 0 4px 6px; font-size: 12.5px; font-weight: 500; color: var(--text2); }
.sga-ui .cfg-input {
	width: 100%; max-width: none; min-height: var(--control-h); margin: 0; padding: 0 12px;
	border: 0.5px solid var(--border2); border-radius: var(--radius-control);
	background: var(--surface); color: var(--text); font-family: var(--font-ui); font-size: 14px;
	outline: none; box-shadow: none;
	transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.sga-ui .cfg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.sga-ui .cfg-input[readonly] { color: var(--text2); background: var(--fill); }

/* Insignias */
.sga-ui .quality-badge {
	display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
	height: 26px; padding: 0 10px; border-radius: var(--radius-capsule);
	font-size: 12px; font-weight: 600; white-space: nowrap;
	background: var(--fill); color: var(--text2);
}
.sga-ui .quality-badge.is-online { background: var(--green-soft); color: var(--green-text); }
.sga-ui .quality-badge.is-warning { background: var(--yellow-soft); color: var(--yellow-text); }
.sga-ui .quality-badge.is-offline { background: var(--red-soft); color: var(--red-text); }
.sga-ui .quality-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Radios como control segmentado o muestras de color */
.sga-ui .sga-radio { position: relative; display: block; margin: 0; }
.sga-ui .sga-radio input {
	position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.sga-ui .sga-radio input:checked + .filter-tab {
	background: var(--surface); font-weight: 600;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.sga-ui .sga-radio input:focus-visible + span { outline: 3px solid var(--accent-border); outline-offset: 2px; }
.sga-ui .sga-radio input:disabled + span { cursor: default; opacity: 0.6; }
@media (prefers-color-scheme: dark) {
	.sga-ui:not([data-theme="light"]) .sga-radio input:checked + .filter-tab { background: var(--surface3); }
}
.sga-ui[data-theme="dark"] .sga-radio input:checked + .filter-tab { background: var(--surface3); }

.sga-ui .theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.sga-ui .theme-swatch {
	display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer;
	border-radius: var(--radius-card); background: var(--surface); border: 2px solid transparent;
	transition: border-color var(--dur) var(--ease);
}
.sga-ui .theme-swatch:hover { border-color: var(--border2); }
.sga-ui .sga-radio input:checked + .theme-swatch { border-color: var(--accent); }
.sga-ui .theme-swatch-name { font-size: 14px; font-weight: 500; }
.sga-ui .theme-swatch-check { margin-left: auto; color: var(--accent); visibility: hidden; }
.sga-ui .sga-radio input:checked + .theme-swatch .theme-swatch-check { visibility: visible; }
.sga-ui .accent-dot { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15); }
/* Muestras fijas: cada una enseña su propio acento (no el activo) */
.sga-ui .sga-accent-verde { background: #1A7F45; }
.sga-ui .sga-accent-indigo { background: #5856D6; }
.sga-ui .sga-accent-azul { background: #0071E3; }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
	.sga-ui { padding: 16px; margin: 0 0 12px; border-radius: var(--radius-card); }
	.sga-ui .sga-title { font-size: 22px; }
	.sga-ui .filter-tabs { grid-auto-columns: max-content; }
	.sga-ui .sga-actions .cfg-save-btn { width: 100%; min-height: 50px; font-size: 16px; }
}
@media (max-width: 420px) {
	.sga-ui .filter-tab span { display: none; }
	.sga-ui .filter-tab .ico { width: 20px; height: 20px; }
	.sga-ui .sga-tabs { grid-auto-columns: 1fr; }
	.sga-ui .info-row { flex-wrap: wrap; }
}

/* Accesibilidad: movimiento reducido */
@media (prefers-reduced-motion: reduce) {
	.sga-ui *, .sga-ui *::before, .sga-ui *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── COLORES DE ACENTO (al final para ganar a los bloques de modo oscuro) ── */
.sga-ui[data-accent="indigo"] {
	--accent: #5856D6; --accent-hover: #4A48C4; --accent-soft: rgba(88, 86, 214, 0.12); --accent-border: rgba(88, 86, 214, 0.32);
}
.sga-ui[data-accent="azul"] {
	--accent: #0071E3; --accent-hover: #0062C4; --accent-soft: rgba(0, 113, 227, 0.12); --accent-border: rgba(0, 113, 227, 0.32);
}
@media (prefers-color-scheme: dark) {
	.sga-ui[data-accent="indigo"]:not([data-theme="light"]) {
		--accent: #5E5CE6; --accent-hover: #7472EE; --accent-soft: rgba(94, 92, 230, 0.2); --accent-border: rgba(94, 92, 230, 0.45);
	}
	.sga-ui[data-accent="azul"]:not([data-theme="light"]) {
		--accent: #0071E3; --accent-hover: #1A84F0; --accent-soft: rgba(0, 113, 227, 0.24); --accent-border: rgba(0, 113, 227, 0.5);
	}
}
.sga-ui[data-accent="indigo"][data-theme="dark"] {
	--accent: #5E5CE6; --accent-hover: #7472EE; --accent-soft: rgba(94, 92, 230, 0.2); --accent-border: rgba(94, 92, 230, 0.45);
}
.sga-ui[data-accent="azul"][data-theme="dark"] {
	--accent: #0071E3; --accent-hover: #1A84F0; --accent-soft: rgba(0, 113, 227, 0.24); --accent-border: rgba(0, 113, 227, 0.5);
}
