/* Wave 3 — Productividad, móvil, confianza */

/* D: Acciones rápidas en fila */
.messageListItem {
	position: relative;
}

.tn-row-actions {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	gap: 4px;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--tn-transition, 0.18s ease);
	z-index: 3;
	background: rgba(255, 255, 255, 0.96);
	padding: 4px;
	border-radius: 999px;
	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
	border: 1px solid var(--tn-border, #e2e8f0);
}

.messageListItem:hover .tn-row-actions,
.messageListItem.tn-kb-focus .tn-row-actions {
	opacity: 1;
	pointer-events: auto;
}

.tn-row-actions button {
	border: none;
	background: var(--tn-surface-subtle, #f1f5f9);
	width: 32px;
	height: 32px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 0.85rem;
	line-height: 1;
	padding: 0;
}

.tn-row-actions button:hover {
	background: var(--tn-primary, #2980b9);
	color: #fff;
}

.messageListItem.tn-kb-focus {
	outline: 2px solid var(--tn-primary-bright, #3498db);
	outline-offset: -2px;
}

/* D: Ordenar */
.tn-sort-wrap {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
}

.tn-sort-label {
	font-size: 0.72rem;
	font-weight: 600;
	color: var(--tn-text-muted, #64748b);
}

.tn-sort-select {
	border: 1px solid var(--tn-border-strong, #94a3b8);
	border-radius: 6px;
	padding: 4px 8px;
	font-size: 0.75rem;
	background: #fff;
	color: var(--tn-text-secondary, #1e293b);
	min-height: 32px;
}

/* E: Pull to refresh */
.tn-ptr-indicator {
	display: none;
	text-align: center;
	padding: 10px;
	font-size: 0.8rem;
	color: var(--tn-primary, #2980b9);
	font-weight: 600;
}

.tn-ptr-indicator.is-visible {
	display: block;
}

/* E: Compose drag-drop */
.tn-drop-zone {
	display: none;
	margin: 8px 12px;
	padding: 16px;
	border: 2px dashed var(--tn-border-strong, #94a3b8);
	border-radius: var(--tn-radius-sm, 8px);
	text-align: center;
	font-size: 0.84rem;
	color: var(--tn-text-muted, #64748b);
	background: var(--tn-surface-subtle, #f8fafc);
}

#V-PopupsCompose.tn-drag-over .tn-drop-zone,
.tn-drag-over .tn-drop-zone {
	display: block;
	border-color: var(--tn-primary, #2980b9);
	color: var(--tn-primary, #2980b9);
	background: #e8f4fd;
}

body.tn-compose-fullscreen #V-PopupsCompose {
	position: fixed !important;
	inset: 0 !important;
	width: 100% !important;
	max-width: none !important;
	height: 100dvh !important;
	max-height: 100dvh !important;
	margin: 0 !important;
	border-radius: 0 !important;
	z-index: 20000 !important;
}

body.tn-compose-fullscreen #V-PopupsCompose header {
	position: sticky;
	top: 0;
	z-index: 2;
}

body.tn-compose-fullscreen #V-PopupsCompose .button-save {
	position: sticky;
	bottom: 0;
}

/* E: Sidebar móvil */
.tn-sidebar-toggle {
	display: none;
	border: none;
	background: transparent;
	font-size: 1.35rem;
	padding: 8px;
	color: var(--tn-primary, #2980b9);
	min-width: 44px;
	min-height: 44px;
}

.tn-sidebar-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	z-index: 8000;
}

@media (max-width: 768px) {
	.tn-sidebar-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	body.tn-sidebar-open .tn-sidebar-backdrop {
		display: block;
	}

	body.tn-sidebar-open #rl-left {
		position: fixed !important;
		left: 0;
		top: 0;
		bottom: 0;
		z-index: 9000;
		width: min(280px, 88vw) !important;
		max-height: 100dvh !important;
		height: 100dvh !important;
		box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
	}

	body.tn-sidebar-open #rl-left > .b-toolbar:last-of-type {
		padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
	}

	.messageListItem:hover .tn-row-actions {
		opacity: 0;
		pointer-events: none;
	}
}

/* F: Enlaces externos */
.tn-ext-url {
	word-break: break-all;
	font-size: 0.82rem;
	color: var(--tn-text-muted, #64748b);
	background: var(--tn-surface-subtle, #f1f5f9);
	padding: 8px;
	border-radius: 6px;
}

/* F: Sesión */
.tn-session-modal {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 100001;
	max-width: 320px;
	padding: 14px 16px;
	background: #1e293b;
	color: #f8fafc;
	border-radius: var(--tn-radius-md, 12px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
	border: 1px solid #334155;
}

.tn-session-modal p {
	margin: 8px 0 12px;
	font-size: 0.84rem;
	line-height: 1.45;
	opacity: 0.92;
}

.tn-session-stay {
	border: none;
	background: var(--tn-primary, #3498db);
	color: #fff;
	padding: 8px 14px;
	border-radius: 8px;
	font-weight: 600;
	cursor: pointer;
	width: 100%;
}

/* F: Errores */
.tn-branded-error {
	border-left: 4px solid #ef4444 !important;
}

.tn-error-brand {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #b91c1c;
	margin-bottom: 4px;
}

/* F: Respuestas rápidas */
.tn-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 8px 12px;
	border-bottom: 1px solid var(--tn-border, #e2e8f0);
	background: var(--tn-surface-subtle, #f8fafc);
}

.tn-quick-replies button {
	border: 1px solid var(--tn-border, #cbd5e1);
	background: #fff;
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 0.78rem;
	font-weight: 500;
	color: var(--tn-text-secondary, #1e293b);
	cursor: pointer;
}

.tn-quick-replies button:hover {
	border-color: var(--tn-primary, #2980b9);
	color: var(--tn-primary, #2980b9);
}

/* F: Ajustes — panel derecho claro; menú lateral hereda sidebar azul */
#V-SettingsPane {
	background: var(--tn-surface, #fff) !important;
	color: var(--tn-text-secondary, #1e293b) !important;
}

#V-SettingsMenu nav a,
#V-SettingsMenu a {
	border-radius: 6px;
	margin: 2px 6px;
	padding: 10px 12px !important;
	font-weight: 500;
}

#V-SettingsPane .legend,
#V-SettingsPane h3 {
	color: var(--tn-text-secondary, #1e293b) !important;
	font-weight: 700;
}

#V-SettingsPane .btn.buttonLogin {
	background: linear-gradient(135deg, var(--tn-primary-bright, #3498db), var(--tn-primary, #2980b9)) !important;
	border: none !important;
	color: #fff !important;
}

#V-SettingsPane {
	max-width: 760px;
	margin: 0 auto;
	padding: 20px 24px 32px !important;
	box-sizing: border-box;
}

.tn-settings-header {
	margin-bottom: 20px;
	padding-bottom: 12px;
	border-bottom: 2px solid var(--tn-primary, #2980b9);
}

.tn-settings-exit {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 12px;
	padding: 8px 14px;
	border: 1px solid var(--tn-border-strong, #94a3b8);
	border-radius: 8px;
	background: var(--tn-surface-subtle, #f1f5f9);
	color: var(--tn-text-secondary, #1e293b);
	font-size: 0.84rem;
	font-weight: 700;
	cursor: pointer;
	transition: background var(--tn-transition), border-color var(--tn-transition);
}

.tn-settings-exit:hover {
	background: #e2e8f0;
	border-color: #64748b;
}

.tn-settings-title {
	margin: 0 0 4px;
	font-size: 1.35rem;
	font-weight: 800;
	color: var(--tn-text-secondary, #1e293b);
}

.tn-settings-section {
	margin: 0;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--tn-text-muted, #475569);
}

/* F: Alto contraste */
body.tn-hi-contrast {
	--tn-border: #0f172a;
	--tn-text: #000;
	--tn-text-secondary: #000;
}

body.tn-hi-contrast .messageListItem {
	border-bottom: 2px solid #000 !important;
}

body.tn-hi-contrast .messageListItem.unseen {
	background: #ffff00 !important;
	color: #000 !important;
}

body.tn-hi-contrast .tn-filter-chip,
body.tn-hi-contrast .btn {
	border-width: 2px !important;
}

.tn-hi-contrast-toggle {
	border: 1px solid var(--tn-border-strong, #94a3b8);
	background: #fff;
	color: var(--tn-text-muted, #475569);
	border-radius: var(--tn-radius-sm, 8px);
	padding: 6px 10px;
	font-size: 0.72rem;
	font-weight: 600;
	cursor: pointer;
	min-height: 32px;
}

/* Screen reader only */
.tn-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Dark + hi-contrast */
body.tn-theme-dark .tn-row-actions {
	background: #334155;
	border-color: #475569;
}

body.tn-theme-dark .tn-session-modal {
	background: #0f172a;
}

body.tn-theme-dark #V-SettingsPane,
body.tn-theme-dark #V-SettingsMenu {
	background: #1e293b !important;
	color: #e2e8f0 !important;
}

body.tn-theme-dark .tn-quick-replies {
	background: #334155;
	border-color: #475569;
}

body.tn-theme-dark .tn-quick-replies button {
	background: #1e293b;
	border-color: #475569;
	color: #f1f5f9;
}

@media print {
	.tn-row-actions,
	.tn-quick-replies,
	.tn-session-modal,
	.tn-sidebar-toggle,
	.tn-sidebar-backdrop,
	.tn-ptr-indicator,
	.tn-sort-wrap {
		display: none !important;
	}
}
