/*
 * Student portal only (HANDOFF-portal-responsive.md). Linked from pagesapp/page.jsp after
 * estilosmqueries.css. Every rule is scoped under .portal (<body class="portal">) because the
 * stylesheets in scripts-2.14 are a symlink to the staff app (front): nothing here may leak there.
 *
 * Breakpoints: < 576px = phone (cards instead of tables); < 768px = phone/small tablet title block;
 * max-height 500px = phone in landscape.
 */

/* ---- Safe areas (notch / home indicator); needs viewport-fit=cover in page.jsp ---- */
.portal {
	padding-left: env(safe-area-inset-left);
	padding-right: env(safe-area-inset-right);
}

.portal header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-top: calc(2px + env(safe-area-inset-top));
	padding-left: calc(15px + env(safe-area-inset-left));
	padding-right: calc(15px + env(safe-area-inset-right));
}

.portal header .usuario,
.portal header .usuarioIconos {
	float: none;
	margin-top: 0;
}

/* ---- Item 3: .headerTit is a full-width float; the content that follows must start below it ---- */
.portal .headerTit + .content {
	clear: both;
}

/* ---- Item 4: room for the fixed bottom bar at the end of every page ---- */
.portal .content {
	padding-bottom: calc(var(--portalStackH, 130px) + 40px + env(safe-area-inset-bottom));
}

/* UM-543: a screen's own buttons (back, save, send...) form a second row right above the general bar.
   --portalBarH / --portalStackH are measured by pagesapp/portal_bar_include.jsp (fallbacks cover no-JS). */
.portal .botonesFixed2.portalOwnRow {
	bottom: calc(16px + env(safe-area-inset-bottom) + var(--portalBarH, 64px) + 8px);
}

/* UM-540: the bottom bar is always ONE row. The buttons shrink (keeping their circle through aspect-ratio) when
   they do not fit; font-size:0 on the bar makes the &nbsp; text nodes between the buttons zero-width flex items. */
.portal .botonesFixed2 {
	bottom: calc(16px + env(safe-area-inset-bottom));
	right: calc(16px + env(safe-area-inset-right));
	left: auto;
	max-width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: flex-end;
	font-size: 0;
}

.portal .botonesFixed2 .btn-admin {
	flex: 0 1 auto;
	min-width: 0;
	height: auto;
	aspect-ratio: 1 / 1;
}

/* ---- Item 6: tap targets >= 44px on touch screens and phones (padding grows the hit area, not the glyph) ---- */
@media (pointer: coarse), (max-width: 767.98px) {
	.portal .usuarioIconos a {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 44px;
		min-height: 44px;
		margin-left: 0;
		font-size: 18px;
		line-height: 1;
	}
	.portal .adminTitle i[role="button"] {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 44px;
		min-height: 44px;
	}
	.portal .customButton2 {
		min-width: 44px;
		min-height: 44px;
	}
}

/* Bottom-bar buttons: 48px circles on phones (portrait and landscape) */
@media (max-width: 767.98px), (max-height: 500px) {
	.portal .botonesFixed2 .btn-admin {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 48px;
		padding: 0;
		font-size: clamp(13px, 5.2vw, 20px);
		line-height: 1;
		margin: 0 3px;
	}
	/* Logout button: .ms-3 is !important, so the separator it adds shrinks with the width as well */
	.portal .botonesFixed2 .btn-admin.ms-3 {
		margin-left: clamp(0px, 3vw, 12px) !important;
	}
}

/* ---- Items 10 and 7: compact title block on phones and in landscape ---- */
@media (max-width: 767.98px), (max-height: 500px) {
	.portal .headerTit {
		padding: calc(56px + env(safe-area-inset-top)) 80px 10px calc(16px + env(safe-area-inset-left));
		font-size: 22px;
		line-height: 24px;
		margin-bottom: 8px;
	}
	.portal .logo {
		top: calc(52px + env(safe-area-inset-top));
		right: calc(16px + env(safe-area-inset-right));
	}
	.portal .logo img {
		height: 40px;
	}
}

/* ---- Item 5: iOS Safari zooms into any focused field below 16px and never zooms back ---- */
@media (hover: none) and (pointer: coarse) {
	.portal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
	.portal select,
	.portal textarea,
	.portal .input,
	.portal .inputContainer .input,
	.portal .loginBoxLogin input {
		font-size: 16px;
	}
}

/* ---- Item 11: dynamic viewport height on the login picture (mobile address bar) ---- */
.portal .loginImg {
	height: 100vh;
	height: 100dvh;
}

@media (max-width: 1200px) and (orientation: portrait) {
	.portal .loginImg {
		height: auto;
	}
	.portal .loginBoxLogin {
		height: 35vh;
		height: 35dvh;
	}
}

/* ---- Items 1, 2 and 9: tables become cards below 576px ---- */
.portal .pcOnly,
.portal .portalSort {
	display: none;
}

.portal .portalSort {
	margin: 0 0 10px;
}

.portal .portalSort select {
	width: 100%;
	min-height: 44px;
}

@media (max-width: 575.98px) {
	.portal .portalSort {
		display: block;
	}
	.portal .pcOnly {
		display: inline;
	}

	.portal .portalCards,
	.portal .portalCards tbody {
		display: block;
		width: 100%;
	}
	.portal .portalCards thead {
		display: none;
	}
	.portal .portalCards tr {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: 10px;
		align-items: center;
		margin-bottom: 8px;
		padding: 8px 10px;
		border: 1px solid #e6e6e6;
		border-radius: 10px;
		background: #fff;
	}
	.portal .portalCards tr.active {
		background: #f6f6f6;
	}
	.portal .portalCards td {
		display: block;
		min-width: 0;
		padding: 2px 0;
		border: 0;
		font-size: 14px;
		line-height: 1.3;
		overflow-wrap: anywhere;
		text-align: left;
	}
	.portal .portalCards td:empty {
		padding: 0;
	}
	.portal .portalCards td.pc-title { grid-column: 1; grid-row: 1; font-size: 15px; }
	.portal .portalCards td.pc-date { grid-column: 2; grid-row: 1; text-align: right; white-space: nowrap; font-size: 12px; }
	.portal .portalCards td.pc-subject { grid-column: 1; grid-row: 2; }
	.portal .portalCards td.pc-badge { grid-column: 2; grid-row: 2; text-align: right; }
	.portal .portalCards td.pc-student { grid-column: 1; grid-row: 3; font-size: 12px; color: var(--colorSoftGray); }
	.portal .portalCards td.pc-count { grid-column: 2; grid-row: 3; text-align: right; font-size: 12px; color: var(--colorSoftGray); }

	/* Activities: name + amount on the first line, due date + the three "mail sent" ticks on the second */
	.portal .portalCards.portalCardsActivities tr {
		grid-template-columns: minmax(0, 1fr) auto auto auto;
	}
	.portal .portalCards.portalCardsActivities td.pc-title { grid-column: 1 / 4; grid-row: 1; }
	.portal .portalCards.portalCardsActivities td.pc-amount { grid-column: 4; grid-row: 1; text-align: right; white-space: nowrap; }
	.portal .portalCards.portalCardsActivities td.pc-due { grid-column: 1; grid-row: 2; font-size: 12px; color: var(--colorSoftGray); }
	.portal .portalCards.portalCardsActivities td.pc-mail { grid-row: 2; text-align: center; padding-left: 8px; }
	.portal .portalCards.portalCardsActivities td.pc-mail1 { grid-column: 2; }
	.portal .portalCards.portalCardsActivities td.pc-mail2 { grid-column: 3; }
	.portal .portalCards.portalCardsActivities td.pc-mail3 { grid-column: 4; }

	/* Reports: type, file name, then received date + the view / download icons */
	.portal .portalCards.portalCardsReports tr {
		grid-template-columns: minmax(0, 1fr) auto auto;
	}
	.portal .portalCards.portalCardsReports td.pc-title { grid-column: 1 / 4; grid-row: 1; }
	.portal .portalCards.portalCardsReports td.pc-doc { grid-column: 1 / 4; grid-row: 2; font-size: 12px; color: var(--colorSoftGray); }
	.portal .portalCards.portalCardsReports td.pc-due { grid-column: 1; grid-row: 3; font-size: 12px; color: var(--colorSoftGray); }
	.portal .portalCards.portalCardsReports td.pc-ico { grid-row: 3; text-align: center; padding-left: 8px; }
	.portal .portalCards.portalCardsReports td.pc-ico1 { grid-column: 2; }
	.portal .portalCards.portalCardsReports td.pc-ico2 { grid-column: 3; }

	/* Images: thumbnail on the left spanning two rows, space + date in the middle, download icon on the right */
	.portal .portalCards.portalCardsImages tr {
		grid-template-columns: auto minmax(0, 1fr) auto;
	}
	.portal .portalCards.portalCardsImages td.pc-thumb { grid-column: 1; grid-row: 1 / 3; padding-right: 8px; }
	.portal .portalCards.portalCardsImages td.pc-title { grid-column: 2; grid-row: 1; }
	.portal .portalCards.portalCardsImages td.pc-due { grid-column: 2; grid-row: 2; font-size: 12px; color: var(--colorSoftGray); }
	.portal .portalCards.portalCardsImages td.pc-ico { grid-column: 3; grid-row: 1 / 3; text-align: center; padding-left: 8px; }

	/* Contacts: teacher, alias (may wrap), then the two action buttons in a row */
	.portal .portalCards.portalCardsContacts tr {
		grid-template-columns: minmax(0, 1fr);
	}
	.portal .portalCards.portalCardsContacts td.pc-title,
	.portal .portalCards.portalCardsContacts td.pc-alias,
	.portal .portalCards.portalCardsContacts td.pc-actions {
		grid-column: 1;
		grid-row: auto;
		text-align: left;
	}
	.portal .portalCards.portalCardsContacts td.pc-actions {
		display: flex;
		gap: 8px;
	}
	.portal .portalCards.portalCardsContacts td.pc-actions .customButton2 {
		float: none;
		margin: 4px 0;
		padding: 0;
		width: 44px;
		height: 44px;
		line-height: 40px;
	}
}

/* ---- Item 8: activity modal ---- */
.portal .portalModalChecks {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 20px;
	margin-bottom: 1rem;
	text-align: left;
}

.portal .portalModalFile {
	overflow-wrap: anywhere;
	text-align: left;
}

.portal .swal-modal {
	max-width: 100%;
}

.portal .portalModalClose {
	margin-top: 12px;
}

/* ---- UM-537: remaining tap targets >= 44px on touch screens (main actions only; TinyMCE toolbar buttons stay as they are) ---- */
@media (hover: none) and (pointer: coarse) {
	/* Table/card action icons (28x28) */
	.portal .adminIco.zoom {
		min-width: 44px;
		min-height: 44px;
	}
	/* Document links of the activity modal (18px high): the hit area grows, the text keeps its size */
	.portal .portalModalFile {
		min-height: 44px;
	}
	/* Logo link of the header (40x26) */
	.portal .logo a {
		display: inline-flex;
		align-items: center;
		min-width: 44px;
		min-height: 44px;
	}
	/* Filter buttons (27px) */
	.portal .customButton {
		min-height: 44px;
	}
}

/* ---- UM-540: localized file control of the absence justification dialog (the real input is visually hidden) ---- */
.portal .portalFilePick {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
}
.portal .portalFilePick .portalFileBtn {
	display: inline-flex;
	align-items: center;
	margin: 0;
	min-height: 38px;
	cursor: pointer;
}
.portal .portalFilePick .portalFileText {
	min-width: 0;
	font-size: 14px;
	color: var(--colorSoftGray);
	overflow-wrap: anywhere;
}
.portal .portalFilePick input:focus-visible + .portalFileBtn {
	outline: 3px solid var(--colorBlue);
	outline-offset: 2px;
}
@media (hover: none) and (pointer: coarse) {
	.portal .portalFilePick .portalFileBtn {
		min-height: 44px;
	}
}

/* ---- Login screens (PN=D1): info icon under the e-mail / code field, opening a help popup ---- */
/* The field's own bottom margin (30px desktop, 20px phones) moves below the icon row */
.portal .loginBoxLogin input:has(+ .loginFieldInfo) {
	margin-bottom: 4px;
}
.portal .loginBoxLogin .loginFieldInfo {
	text-align: right;
	line-height: 1;
	margin: 0 0 8px;
}
/* The shared ".loginBoxLogin>div i" rule positions icons absolutely inside the field: undo it here */
.portal .loginBoxLogin .loginFieldInfo i {
	position: static;
	font-size: 18px;
	color: var(--color2);
}
.portal .loginBoxLogin .loginFieldInfo a:hover i,
.portal .loginBoxLogin .loginFieldInfo a:focus-visible i {
	color: var(--color1);
}
/* The code is typed uppercase and spaced out; the descriptive placeholder must stay as written */
.portal .loginBoxLogin #code::placeholder {
	text-transform: none;
	letter-spacing: normal;
}
