/* ==========================================================================
   KH Registro de Horas — interfaz del estudiante
   Mobile-first. En desktop: columna de estado fija + columna de acciones.
   ========================================================================== */

.kh-h-wrap {
	--kh-purple: #cd7ddb;
	--kh-purple-dark: #8e4fa0;
	--kh-ink: #2f2f2f;
	--kh-muted: #6b6b6b;
	--kh-line: #ece7f0;
	--kh-soft: #f6f2f8;
	--kh-radius: 18px;

	max-width: 1080px;
	margin: 0 auto;
	padding: 4px 0 48px;
	color: var(--kh-ink);
}

/* ---------- Encabezado ---------- */
.kh-h-head {
	display: flex; flex-wrap: wrap; gap: 12px;
	align-items: flex-end; justify-content: space-between;
	margin-bottom: 20px;
}
.kh-h-title { margin: 0; font-size: 28px; line-height: 1.2; }
.kh-h-sub { margin: 4px 0 0; color: var(--kh-muted); font-size: 14px; }
.kh-h-program-chip {
	background: var(--kh-soft); color: #7a5a8c; border-radius: 999px;
	padding: 7px 16px; font-size: 13px; font-weight: 600; white-space: nowrap;
}

/* ---------- Rejilla ---------- */
.kh-h-grid { display: block; }

/* ---------- Tarjetas ---------- */
.kh-h-card {
	background: #fff; border: 1px solid var(--kh-line); border-radius: var(--kh-radius);
	padding: 22px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.kh-h-card-empty { text-align: center; }
.kh-h-h3 { margin: 0 0 6px; font-size: 19px; }
.kh-h-muted { color: var(--kh-muted); font-size: 13.5px; margin: 0 0 16px; line-height: 1.5; }
.kh-h-empty { color: var(--kh-muted); font-size: 14px; margin: 0; }
.kh-h-fineprint { color: #8a8a8a; font-size: 12.5px; margin: 10px 0 0; text-align: center; line-height: 1.45; }
.kh-h-label {
	display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
	color: var(--kh-muted); margin: 16px 0 6px; font-weight: 600;
}

/* ---------- Reloj ---------- */
.kh-h-clock.is-running { border-color: #dcc4e6; background: linear-gradient(180deg,#fdfaff 0%,#fff 60%); }
.kh-h-clock-help { text-align: center; font-size: 15px; font-weight: 600; margin: 0 0 12px; }

.kh-h-live { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
.kh-h-live-dot {
	width: 9px; height: 9px; border-radius: 50%; background: #d24a4a;
	animation: kh-pulse 1.8s ease-in-out infinite;
}
@keyframes kh-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.85); } }
.kh-h-live-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--kh-purple-dark); font-weight: 700; }

.kh-h-elapsed-big {
	font-size: 42px; font-weight: 300; text-align: center; line-height: 1.1;
	font-variant-numeric: tabular-nums; margin: 2px 0 6px;
}
.kh-h-since { text-align: center; font-size: 13px; color: var(--kh-muted); margin: 0 0 4px; }
.kh-h-since strong { font-weight: 600; color: var(--kh-ink); }
.kh-h-chip {
	display: inline-block; background: var(--kh-soft); color: #7a5a8c;
	border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}

/* ---------- Botones ---------- */
.kh-h-btn {
	display: block; width: 100%; border: 0; border-radius: 14px;
	padding: 17px 16px; font-size: 16.5px; font-weight: 700; cursor: pointer;
	color: #fff; background: var(--kh-purple); margin-top: 14px;
	transition: transform .08s ease, box-shadow .2s ease, opacity .15s ease;
	box-shadow: 0 4px 14px rgba(205,125,219,.32);
}
.kh-h-btn:hover { box-shadow: 0 6px 18px rgba(205,125,219,.42); }
.kh-h-btn:active { transform: translateY(1px); }
.kh-h-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.kh-h-btn-start { background: var(--kh-purple); }
.kh-h-btn-stop { background: var(--kh-purple-dark); box-shadow: 0 4px 14px rgba(142,79,160,.32); }

/* ---------- Selector presencial / teoría ---------- */
.kh-h-toggle { display: flex; background: var(--kh-soft); border-radius: 14px; padding: 5px; gap: 5px; margin: 8px 0 4px; }
.kh-h-toggle button {
	flex: 1; border: 0; background: transparent; border-radius: 10px;
	padding: 11px 8px; cursor: pointer; text-align: center;
	display: flex; flex-direction: column; gap: 2px; transition: background .15s ease;
}
.kh-h-toggle button.is-active { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.10); }
.kh-h-toggle-title { font-size: 14px; font-weight: 700; color: var(--kh-muted); }
.kh-h-toggle-desc { font-size: 11.5px; color: #9a9a9a; }
.kh-h-toggle button.is-active .kh-h-toggle-title { color: var(--kh-ink); }
.kh-h-toggle button.is-active .kh-h-toggle-desc { color: #7a5a8c; }

/* ---------- Anillo de progreso ---------- */
.kh-h-summary { text-align: center; }
.kh-h-ring { position: relative; width: 190px; margin: 4px auto 10px; }
.kh-h-ring svg { width: 100%; height: auto; transform: rotate(-90deg); display: block; }
.kh-h-ring-track { fill: none; stroke: #eee8f0; stroke-width: 10; }
.kh-h-ring-fill {
	fill: none; stroke: var(--kh-purple); stroke-width: 10; stroke-linecap: round;
	transition: stroke-dashoffset .6s ease;
}
.kh-h-ring-center {
	position: absolute; inset: 0; display: flex; flex-direction: column;
	align-items: center; justify-content: center; gap: 2px; padding: 0 18px;
}
.kh-h-ring-top { font-size: 25px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kh-h-ring-sub { font-size: 12.5px; color: var(--kh-muted); }

.kh-h-decimal { font-size: 12.5px; color: var(--kh-muted); margin: 0 0 8px; }
.kh-h-help {
	display: inline-flex; align-items: center; justify-content: center;
	width: 15px; height: 15px; border-radius: 50%; background: #e6dcec;
	color: #7a5a8c; font-size: 10px; font-weight: 700; cursor: help; vertical-align: 1px;
}
.kh-h-remaining {
	background: var(--kh-soft); border-radius: 12px; padding: 11px 14px;
	font-size: 13.5px; color: #5f4a6b; margin: 0 0 18px; line-height: 1.45;
}

/* ---------- Desglose ---------- */
.kh-h-breakdown { text-align: left; display: grid; gap: 14px; }
.kh-h-block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.kh-h-block-label { font-size: 13.5px; font-weight: 600; }
.kh-h-block-val { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kh-h-block-goal { font-size: 11.5px; color: #9a9a9a; }
.kh-h-bar { background: #eee8f0; border-radius: 999px; height: 7px; overflow: hidden; margin: 6px 0 4px; }
.kh-h-bar span { display: block; height: 100%; background: var(--kh-purple); border-radius: 999px; transition: width .5s ease; }

/* ---------- Pestañas ---------- */
.kh-h-tabs {
	display: flex; gap: 4px; background: var(--kh-soft); padding: 5px;
	border-radius: 14px; margin-bottom: 18px; overflow-x: auto;
}
.kh-h-tab {
	flex: 1; border: 0; background: transparent; border-radius: 10px; cursor: pointer;
	padding: 12px 14px; font-size: 14px; font-weight: 600; color: var(--kh-muted);
	white-space: nowrap; transition: background .15s ease;
}
.kh-h-tab.is-active { background: #fff; color: var(--kh-ink); box-shadow: 0 1px 4px rgba(0,0,0,.10); }
.kh-h-badge {
	display: inline-block; background: #e6dcec; color: #7a5a8c; border-radius: 999px;
	padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 4px;
}
.kh-h-tabpanel { display: none; }
.kh-h-tabpanel.is-active { display: block; animation: kh-fade .25s ease; }
@keyframes kh-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Campos ---------- */
.kh-h-row { display: flex; gap: 12px; flex-wrap: wrap; }
.kh-h-field { flex: 1; min-width: 130px; }
.kh-h-field-sm { flex: 0 0 92px; min-width: 92px; }
.kh-h-wrap input[type="date"],
.kh-h-wrap input[type="number"],
.kh-h-wrap input[type="text"],
.kh-h-wrap select {
	width: 100%; box-sizing: border-box; border: 1px solid #e2dbe8; border-radius: 12px;
	padding: 13px 14px; font-size: 16px; background: #faf8fb; color: var(--kh-ink);
}
.kh-h-wrap input:focus, .kh-h-wrap select:focus {
	outline: 2px solid var(--kh-purple); outline-offset: 1px; background: #fff;
}

/* ---------- Firma ---------- */
.kh-h-sig {
	width: 100%; height: 140px; border: 2px dashed #ddd3e4; border-radius: 12px;
	background: #fff; touch-action: none; display: block; cursor: crosshair;
}
.kh-h-clear { background: none; border: 0; color: var(--kh-purple); font-size: 13px; cursor: pointer; padding: 8px 0; text-decoration: underline; }
.kh-h-sig-block { margin: 16px 0 4px; }

/* ---------- Prácticas ---------- */
.kh-h-pract-list { display: grid; gap: 10px; }
.kh-h-pract {
	display: flex; align-items: center; gap: 14px;
	border: 1px solid var(--kh-line); border-radius: 14px; padding: 14px 16px;
	transition: border-color .15s ease, background .15s ease;
}
.kh-h-pract:hover { border-color: #dcc4e6; }
.kh-h-pract.is-complete { background: #f7fbf7; border-color: #d6e8d6; }
.kh-h-pract-info { flex: 1; min-width: 0; }
.kh-h-pract-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.kh-h-pract-label { font-size: 14px; font-weight: 600; line-height: 1.35; }
.kh-h-pract-count { font-size: 13px; color: var(--kh-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kh-h-pract-count strong { color: var(--kh-ink); font-size: 15px; }
.kh-h-pract-btn {
	flex: 0 0 auto; background: var(--kh-purple); border: 0; color: #fff;
	border-radius: 10px; width: 46px; height: 42px; font-size: 15px; font-weight: 700; cursor: pointer;
	transition: opacity .15s ease;
}
.kh-h-pract-btn:hover { opacity: .88; }
.kh-h-pract-btn:disabled { opacity: .5; cursor: not-allowed; }
.kh-h-pract-done { flex: 0 0 auto; color: #4a8a4a; font-size: 12px; font-weight: 700; }

/* ---------- Tabla ---------- */
.kh-h-table-wrap { overflow-x: auto; }
.kh-h-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kh-h-table th {
	text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
	color: var(--kh-muted); border-bottom: 1px solid var(--kh-line); padding: 9px 8px; font-weight: 600;
}
.kh-h-table td { padding: 12px 8px; border-bottom: 1px solid #f4f1f6; }
.kh-h-flag { background: #fdf3e3; color: #9a6a1f; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.kh-h-void { color: #a33; font-size: 11px; font-weight: 600; }

/* ---------- Aviso flotante ---------- */
.kh-h-toast {
	position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
	background: var(--kh-ink); color: #fff; padding: 14px 22px; border-radius: 12px;
	font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 99999;
	max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.kh-h-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.kh-h-toast.is-error { background: #b4544f; }

/* ==========================================================================
   Reloj flotante (mientras estudia)
   ========================================================================== */
.kh-h-float {
	position: fixed; right: 24px; bottom: 92px; z-index: 99998;
	font-family: inherit; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.kh-h-float-toggle {
	display: flex; align-items: center; gap: 9px;
	background: #fff; border: 1px solid #dcc4e6; border-radius: 999px;
	padding: 11px 18px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.14);
	font-size: 15px; font-weight: 700; color: #2f2f2f;
	font-variant-numeric: tabular-nums; transition: transform .12s ease;
}
.kh-h-float-toggle:hover { transform: translateY(-1px); }
.kh-h-float-dot {
	width: 9px; height: 9px; border-radius: 50%; background: #d24a4a; flex: 0 0 auto;
	animation: kh-pulse 1.8s ease-in-out infinite;
}
.kh-h-float-panel {
	background: #fff; border: 1px solid #ece7f0; border-radius: 14px; padding: 16px;
	box-shadow: 0 8px 26px rgba(0,0,0,.16); max-width: 260px; order: -1;
}
.kh-h-float-panel[hidden] { display: none; }
.kh-h-float-title { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: #8e4fa0; text-transform: uppercase; letter-spacing: .04em; }
.kh-h-float-note { margin: 0 0 12px; font-size: 13px; color: #6b6b6b; line-height: 1.45; }
.kh-h-float-link {
	display: block; text-align: center; background: #8e4fa0; color: #fff !important;
	border-radius: 10px; padding: 11px 14px; font-size: 14px; font-weight: 700; text-decoration: none !important;
}

/* ==========================================================================
   Desktop
   ========================================================================== */
@media (min-width: 900px) {
	.kh-h-grid {
		display: grid;
		grid-template-columns: 350px minmax(0, 1fr);
		gap: 22px;
		align-items: start;
	}
	.kh-h-side { position: sticky; top: 24px; }
	.kh-h-title { font-size: 32px; }
	.kh-h-card { padding: 24px; }
	.kh-h-tab { flex: 0 1 auto; }
}

@media (min-width: 1200px) {
	.kh-h-grid { grid-template-columns: 380px minmax(0, 1fr); gap: 26px; }
}

/* ==========================================================================
   Mobile
   ========================================================================== */
@media (max-width: 560px) {
	.kh-h-head { flex-direction: column; align-items: stretch; }
	.kh-h-title { font-size: 24px; }
	.kh-h-card { padding: 18px; border-radius: 16px; }
	.kh-h-ring { width: 165px; }
	.kh-h-ring-top { font-size: 22px; }
	.kh-h-elapsed-big { font-size: 36px; }
	.kh-h-tab { font-size: 13px; padding: 11px 10px; }
	.kh-h-field-sm { flex: 1 1 calc(50% - 6px); min-width: 0; }
	.kh-h-float { right: 12px; bottom: 84px; }

	/* Tabla en formato tarjeta */
	.kh-h-table thead { display: none; }
	.kh-h-table, .kh-h-table tbody, .kh-h-table tr, .kh-h-table td { display: block; width: 100%; }
	.kh-h-table tr {
		border: 1px solid var(--kh-line); border-radius: 12px;
		padding: 10px 12px; margin-bottom: 10px;
	}
	.kh-h-table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; }
	.kh-h-table td::before {
		content: attr(data-label); color: var(--kh-muted); font-size: 12px;
		text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
	}
	.kh-h-table td:empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.kh-h-live-dot, .kh-h-float-dot { animation: none; }
	.kh-h-tabpanel.is-active { animation: none; }
	.kh-h-ring-fill, .kh-h-bar span { transition: none; }
}


/* ==========================================================================
   Historial: agrupado por día, con filtros y paginación
   ========================================================================== */
.kh-h-log-head {
	display: flex; flex-wrap: wrap; gap: 12px;
	align-items: flex-end; justify-content: space-between; margin-bottom: 18px;
}
.kh-h-filters { display: flex; gap: 6px; background: var(--kh-soft); padding: 4px; border-radius: 10px; }
.kh-h-filter {
	padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
	color: var(--kh-muted); text-decoration: none !important; white-space: nowrap;
}
.kh-h-filter:hover { color: var(--kh-ink); }
.kh-h-filter.is-active { background: #fff; color: var(--kh-ink); box-shadow: 0 1px 3px rgba(0,0,0,.10); }

.kh-h-day { margin-bottom: 22px; }
.kh-h-day-head {
	display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
	padding-bottom: 7px; border-bottom: 1px solid var(--kh-line); margin-bottom: 4px;
}
.kh-h-day-date { font-size: 13px; font-weight: 700; }
.kh-h-day-total {
	font-size: 12.5px; font-weight: 700; color: #7a5a8c;
	background: var(--kh-soft); border-radius: 999px; padding: 3px 11px;
	font-variant-numeric: tabular-nums; white-space: nowrap;
}

.kh-h-log { list-style: none; margin: 0; padding: 0; }
.kh-h-log-item {
	display: grid;
	grid-template-columns: auto 74px 1fr auto;
	align-items: center; gap: 12px;
	padding: 12px 4px; border-bottom: 1px solid #f6f3f8;
}
.kh-h-log-item:last-child { border-bottom: 0; }
.kh-h-log-item.is-void { opacity: .5; }
.kh-h-log-time { font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kh-h-log-meta { font-size: 12.5px; color: var(--kh-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kh-h-log-status { text-align: right; }

.kh-h-pill {
	display: inline-block; border-radius: 999px; padding: 4px 11px;
	font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.kh-h-pill-inperson { background: #f3ecf6; color: #7a5a8c; }
.kh-h-pill-online { background: #eaf2f7; color: #4a6f88; }
.kh-h-signed { font-size: 11px; color: #7a9a7a; font-weight: 600; }

.kh-h-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 20px; }
.kh-h-pager-btn {
	background: var(--kh-soft); border-radius: 10px; padding: 10px 18px;
	font-size: 13.5px; font-weight: 600; color: #7a5a8c; text-decoration: none !important;
}
.kh-h-pager-btn:hover { background: #ece0f2; }
.kh-h-pager-btn.is-disabled { opacity: .4; pointer-events: none; }
.kh-h-pager-info { font-size: 13px; color: var(--kh-muted); font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
	.kh-h-log-head { flex-direction: column; align-items: stretch; }
	.kh-h-filters { justify-content: space-between; }
	.kh-h-filter { flex: 1; text-align: center; }
	.kh-h-log-item {
		grid-template-columns: auto 1fr; gap: 6px 10px;
		padding: 12px 2px;
	}
	.kh-h-log-time { grid-column: 2; text-align: right; }
	.kh-h-log-meta { grid-column: 1 / -1; white-space: normal; }
	.kh-h-log-status { grid-column: 1 / -1; text-align: left; }
	.kh-h-log-status:empty { display: none; }
}


/* ==========================================================================
   Indicador de espera en botones
   ========================================================================== */
@keyframes kh-spin { to { transform: rotate(360deg); } }

.kh-h-btn.is-loading,
.kh-h-pract-btn.is-loading {
	position: relative;
	pointer-events: none;
}

/* Botón pequeño (+1): se oculta el texto y queda sólo el giro. */
.kh-h-pract-btn.is-loading { color: transparent !important; }
.kh-h-pract-btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%; left: 50%;
	width: 16px; height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba(255,255,255,.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: kh-spin .6s linear infinite;
}

/* Botones grandes: conservan su texto y el giro va al lado. */
.kh-h-btn.is-loading { padding-right: 44px; }
.kh-h-btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%; right: 18px;
	width: 17px; height: 17px;
	margin-top: -9px;
	border: 2px solid rgba(255,255,255,.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: kh-spin .6s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
	.kh-h-btn.is-loading::after,
	.kh-h-pract-btn.is-loading::after { animation-duration: 1.6s; }
}

/* Historial mientras se intercambia por AJAX */
[data-kh-historial] {
	transition: opacity .18s ease;
}
[data-kh-historial].is-loading {
	opacity: .45;
	pointer-events: none;
}

/* ==========================================================================
   Selector de curso: mismo aspecto que la etiqueta, pero elegible
   ========================================================================== */
.kh-h-course-pick {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.kh-h-sr {
	position: absolute; width: 1px; height: 1px;
	margin: -1px; padding: 0; overflow: hidden;
	clip: rect(0 0 0 0); clip-path: inset(50%);
	white-space: nowrap; border: 0;
}

.kh-h-program-select {
	appearance: none;
	-webkit-appearance: none;
	border: 1px solid transparent;
	cursor: pointer;
	max-width: 280px;
	padding-right: 38px;
	line-height: 1.4;
	text-overflow: ellipsis;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%237a5a8c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	transition: border-color .15s ease, background-color .15s ease;
}

.kh-h-program-select:hover { border-color: var(--kh-purple); }

.kh-h-program-select:focus-visible {
	outline: 2px solid var(--kh-purple-dark);
	outline-offset: 2px;
}

/* Mientras se trae el otro curso */
.kh-h-course-pick.is-loading .kh-h-program-select {
	background-image: none;
	opacity: .6;
}

.kh-h-chip-spin { display: none; }

.kh-h-course-pick.is-loading .kh-h-chip-spin {
	display: block;
	position: absolute;
	top: 50%; right: 13px;
	width: 14px; height: 14px;
	margin-top: -7px;
	border: 2px solid rgba(122, 90, 140, .28);
	border-top-color: #7a5a8c;
	border-radius: 50%;
	animation: kh-spin .6s linear infinite;
}

/* La vista completa mientras se reemplaza */
.kh-h-wrap { transition: opacity .18s ease; }
.kh-h-wrap.is-swapping { opacity: .5; pointer-events: none; }

@media (max-width: 640px) {
	.kh-h-course-pick { width: 100%; }
	.kh-h-program-select { max-width: 100%; width: 100%; }
}
