/* BEschool Portal — RTL-first styles */

* { box-sizing: border-box; }

html { font-size: 16px; }

body.beschool-portal {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
	background: #f5f6f8;
	color: #1f2330;
	direction: ltr;
	line-height: 1.5;
}
/* Keep Hebrew/Arabic field values reading right-to-left even though the UI is LTR. */
body.beschool-portal .bs-row-he,
body.beschool-portal .bs-row-de,
body.beschool-portal .bs-edit-title h1,
body.beschool-portal .bs-form-field textarea,
body.beschool-portal .bs-form-field input[type=text],
body.beschool-portal .beschool-student-link,
body.beschool-portal .beschool-chip { unicode-bidi: plaintext; }

a { color: #1d6bd6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Top bar ===== */
.beschool-topbar {
	background: #1f2330;
	color: #fff;
}
.beschool-topbar-inner {
	max-width: 1280px;
	margin: 0 auto;
	padding: 12px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}
.beschool-brand {
	color: #fff;
	font-weight: 700;
	font-size: 1.15rem;
}
.beschool-brand:hover { text-decoration: none; opacity: 0.85; }
.beschool-nav {
	display: flex;
	align-items: center;
	gap: 16px;
}
.beschool-nav a { color: #fff; }
.beschool-user { color: #c9ced9; font-size: 0.9rem; }
.beschool-logout { color: #ffb4b4; }

.beschool-main {
	max-width: 1280px;
	margin: 24px auto;
	padding: 0 24px;
}

/* ===== Login ===== */
.beschool-login-wrap {
	min-height: 80vh;
	display: flex;
	align-items: center;
	justify-content: center;
}
.beschool-login-form {
	background: #fff;
	padding: 36px 32px;
	border-radius: 12px;
	box-shadow: 0 4px 20px rgba(0,0,0,0.06);
	width: 100%;
	max-width: 380px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.beschool-login-form h1 {
	margin: 0 0 8px;
	font-size: 1.4rem;
	text-align: center;
}
.beschool-login-form label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 0.9rem;
}
.beschool-login-form input[type=text],
.beschool-login-form input[type=password] {
	padding: 10px 12px;
	border: 1px solid #d2d6df;
	border-radius: 8px;
	font-size: 1rem;
}
.beschool-login-form input:focus { outline: 2px solid #1d6bd6; outline-offset: 1px; }
.beschool-remember { flex-direction: row !important; align-items: center; gap: 8px !important; }
.beschool-link { text-align: center; font-size: 0.9rem; }

/* ===== Buttons ===== */
.beschool-btn {
	display: inline-block;
	padding: 10px 18px;
	border: 1px solid #1f2330;
	background: #fff;
	color: #1f2330;
	border-radius: 8px;
	font-size: 0.95rem;
	cursor: pointer;
	transition: all 0.15s;
	text-decoration: none;
}
.beschool-btn:hover { background: #1f2330; color: #fff; text-decoration: none; }
.beschool-btn-primary {
	background: #1d6bd6;
	border-color: #1d6bd6;
	color: #fff;
}
.beschool-btn-primary:hover { background: #1656ad; border-color: #1656ad; color: #fff; }
.beschool-btn-ghost {
	background: transparent;
	border-color: #c9ced9;
	color: #1f2330;
}
.beschool-btn-ghost:hover { background: #f0f2f5; color: #1f2330; }
.beschool-btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* ===== Notices ===== */
.beschool-notice {
	padding: 12px 16px;
	background: #eff6ff;
	border-left: 4px solid #1d6bd6;
	border-radius: 6px;
	margin-bottom: 16px;
	font-size: 0.95rem;
}
.beschool-notice-error { background: #fef2f2; border-left-color: #dc2626; }
.beschool-notice-success { background: #ecfdf5; border-left-color: #059669; }

/* ===== Dashboard ===== */
.beschool-dashboard-head {
	display: flex;
	align-items: baseline;
	gap: 16px;
	margin-bottom: 16px;
}
.beschool-dashboard-head h1 { margin: 0; font-size: 1.6rem; }
.beschool-count { color: #6c727f; margin: 0; }

.beschool-filters {
	display: flex;
	gap: 12px;
	align-items: flex-end;
	flex-wrap: wrap;
	background: #fff;
	padding: 16px;
	border-radius: 10px;
	margin-bottom: 16px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.beschool-filter { display: flex; flex-direction: column; gap: 4px; }
.beschool-filter span { font-size: 0.85rem; color: #6c727f; }
.beschool-filter select,
.beschool-filter input {
	padding: 8px 12px;
	border: 1px solid #d2d6df;
	border-radius: 8px;
	font-size: 0.95rem;
	min-width: 140px;
}
.beschool-filter-search input { min-width: 220px; }

.beschool-students {
	width: 100%;
	background: #fff;
	border-collapse: separate;
	border-spacing: 0;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.beschool-students th,
.beschool-students td {
	padding: 12px 16px;
	text-align: left;
	border-bottom: 1px solid #eef0f3;
	font-size: 0.95rem;
}
.beschool-students th {
	background: #f8f9fb;
	font-weight: 600;
	color: #6c727f;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.beschool-students tbody tr:hover { background: #fafbfc; }
.beschool-student-link { font-weight: 600; color: #1f2330; }
.beschool-row-actions { display: flex; gap: 6px; }

.beschool-pagination {
	margin-top: 16px;
	display: flex;
	gap: 6px;
	justify-content: center;
	flex-wrap: wrap;
}
.beschool-pagination a,
.beschool-pagination span {
	padding: 6px 12px;
	border: 1px solid #d2d6df;
	border-radius: 6px;
	color: #1f2330;
	text-decoration: none;
}
.beschool-pagination .current { background: #1d6bd6; color: #fff; border-color: #1d6bd6; }

.beschool-empty {
	padding: 48px 16px;
	text-align: center;
	color: #6c727f;
	background: #fff;
	border-radius: 10px;
}

/* ===== Edit page — new layout ===== */
.bs-edit {
	max-width: 1100px;
	margin: 0 auto;
	padding-bottom: 100px; /* room for sticky bar */
}

.bs-edit-head {
	margin-bottom: 24px;
}
.bs-edit-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
	font-size: 0.9rem;
	color: #6c727f;
}
.bs-back { color: #6c727f; }
.bs-back:hover { color: #1f2330; text-decoration: none; }

.bs-edit-status { font-size: 0.85rem; }
.bs-save-state {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #6c727f;
}
.bs-save-state::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #cbd5e1;
	display: inline-block;
}
.bs-save-state.bs-state-saving::before { background: #f59e0b; animation: bs-pulse 1.2s infinite; }
.bs-save-state.bs-state-saved::before  { background: #10b981; }
.bs-save-state.bs-state-error::before  { background: #ef4444; }
.bs-save-state.bs-state-saving { color: #b45309; }
.bs-save-state.bs-state-saved  { color: #059669; }
.bs-save-state.bs-state-error  { color: #b91c1c; }
@keyframes bs-pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.bs-edit-title {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 16px;
}
.bs-edit-title h1 {
	margin: 0;
	font-size: 2rem;
	font-weight: 700;
}
.bs-edit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bs-chip {
	display: inline-flex;
	align-items: center;
	padding: 4px 12px;
	border-radius: 999px;
	background: #eef2ff;
	color: #4338ca;
	font-size: 0.8rem;
	font-weight: 500;
}
.bs-chip-grade { background: #dbeafe; color: #1e40af; }
.bs-chip-spec  { background: #fef3c7; color: #92400e; }

.bs-edit-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}
.bs-progress {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 320px;
	min-width: 220px;
}
.bs-progress-bar {
	flex: 1 1 auto;
	height: 6px;
	background: #e5e7eb;
	border-radius: 999px;
	overflow: hidden;
	position: relative;
}
.bs-progress-fill {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, #10b981, #059669);
	border-radius: 999px;
	width: 0%;
	transition: width 0.3s;
}
.bs-progress-text { font-size: 0.85rem; color: #6c727f; white-space: nowrap; }
.bs-prevnext { display: flex; gap: 6px; flex-wrap: wrap; }

/* ----- Form / Sections ----- */
.bs-form { display: flex; flex-direction: column; gap: 16px; }

.bs-section {
	background: #fff;
	border-radius: 12px;
	border: 1px solid #e5e7eb;
	overflow: hidden;
}
.bs-section-head {
	padding: 14px 20px;
	background: #fafbfc;
	border-bottom: 1px solid #e5e7eb;
}
.bs-section-head h2 {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
	color: #1f2330;
}

/* ----- Subject grid ----- */
.bs-grid { display: flex; flex-direction: column; }
.bs-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1.2fr);
	gap: 12px;
	align-items: center;
	padding: 10px 20px;
	border-bottom: 1px solid #f3f4f6;
	transition: background 0.1s;
}
.bs-row:last-child { border-bottom: 0; }
.bs-row:hover { background: #fafbfc; }
.bs-row:focus-within { background: #f0f7ff; }

.bs-row-name {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}
.bs-row-de {
	font-size: 1.05rem;
	font-weight: 600;
	color: #1f2330;
	line-height: 1.3;
	order: 1;
}
.bs-row-he {
	font-size: 0.85rem;
	font-weight: 400;
	color: #6c727f;
	line-height: 1.3;
	order: 2;
}

.bs-row-grade input {
	width: 100%;
	padding: 10px 8px;
	border: 1px solid #d2d6df;
	border-radius: 8px;
	font-size: 1.15rem;
	font-weight: 600;
	text-align: center;
	background: #fff;
	font-variant-numeric: tabular-nums;
	font-family: inherit;
}
.bs-row-grade input:focus {
	outline: 2px solid #1d6bd6;
	outline-offset: 1px;
	border-color: #1d6bd6;
}
.bs-row-grade input:placeholder-shown {
	background: #fafbfc;
	color: #9ca3af;
}
/* Grade bands: <50 red, 50–70 yellow, >70 green */
.bs-row[data-grade="low"]  .bs-row-grade input {
	background: #fef2f2;
	border-color: #fca5a5;
	color: #991b1b;
}
.bs-row[data-grade="mid"]  .bs-row-grade input {
	background: #fffbeb;
	border-color: #fcd34d;
	color: #92400e;
}
.bs-row[data-grade="high"] .bs-row-grade input {
	background: #f0fdf4;
	border-color: #86efac;
	color: #166534;
}

.bs-row-remark input {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid transparent;
	border-radius: 8px;
	background: transparent;
	font-size: 0.95rem;
	font-family: inherit;
	color: #4b5160;
}
.bs-row-remark input:hover { background: #f3f4f6; }
.bs-row-remark input:focus {
	background: #fff;
	border-color: #1d6bd6;
	outline: 2px solid rgba(29, 107, 214, 0.15);
	color: #1f2330;
}

/* hide subject rows when ACF conditional says so */
.bs-row[data-conditional][data-conditional-hidden="1"] { display: none; }

/* ----- Compact form section (student details, footer) ----- */
.bs-form-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	padding: 16px 20px;
}
.bs-form-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1 1 calc(var(--w, 100%) - 16px);
	max-width: calc(var(--w, 100%));
	min-width: 200px;
}
.bs-form-label {
	font-size: 0.85rem;
	font-weight: 600;
	color: #4b5160;
}
.bs-form-help { margin: 0; font-size: 0.8rem; color: #6c727f; }
.bs-required { color: #dc2626; }

.bs-form-field input[type=text],
.bs-form-field input[type=number],
.bs-form-field input.beschool-date,
.bs-form-field textarea,
.bs-form-field select {
	padding: 9px 12px;
	border: 1px solid #d2d6df;
	border-radius: 8px;
	font-size: 0.95rem;
	font-family: inherit;
	background: #fff;
}
.bs-form-field input:focus,
.bs-form-field textarea:focus,
.bs-form-field select:focus {
	outline: 2px solid #1d6bd6;
	outline-offset: 1px;
	border-color: #1d6bd6;
}
.bs-form-field input[readonly],
.bs-form-field textarea[readonly] { background: #f5f6f8; color: #6c727f; }
.bs-form-field textarea { min-height: 80px; resize: vertical; }

.bs-form-field .beschool-radio-group { display: flex; flex-wrap: wrap; gap: 6px; }
.bs-form-field .beschool-radio {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 1px solid #d2d6df;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.9rem;
	background: #fff;
}
.bs-form-field .beschool-radio:has(input:checked) {
	background: #eff6ff;
	border-color: #1d6bd6;
	color: #1d6bd6;
	font-weight: 500;
}

.bs-form-field[data-conditional][data-conditional-hidden="1"] { display: none; }

/* ----- Suggestions popover (next to text inputs that have history) ----- */
.bs-input-suggest {
	position: relative;
	display: flex;
	gap: 6px;
	align-items: stretch;
}
.bs-input-suggest > input {
	flex: 1 1 auto;
	min-width: 0;
}
.bs-suggest-btn {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0 12px;
	border: 1px solid #d2d6df;
	background: #fff;
	color: #4b5160;
	border-radius: 8px;
	font-size: 0.85rem;
	font-family: inherit;
	cursor: pointer;
	white-space: nowrap;
	transition: all 0.12s;
}
.bs-suggest-btn:hover {
	background: #eff6ff;
	border-color: #1d6bd6;
	color: #1d6bd6;
}
.bs-suggest-btn[aria-expanded="true"] {
	background: #1d6bd6;
	border-color: #1d6bd6;
	color: #fff;
}
.bs-suggest-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 18px;
	padding: 0 5px;
	background: #f3f4f6;
	color: #4b5160;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 600;
}
.bs-suggest-btn[aria-expanded="true"] .bs-suggest-count {
	background: rgba(255,255,255,0.25);
	color: #fff;
}
.bs-suggest-pop {
	position: absolute;
	top: calc(100% + 4px);
	right: 0;
	min-width: 220px;
	max-width: 360px;
	max-height: 280px;
	overflow-y: auto;
	background: #fff;
	border: 1px solid #d2d6df;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.08);
	z-index: 40;
}
.bs-suggest-list {
	list-style: none;
	margin: 0;
	padding: 4px;
}
.bs-suggest-list li { margin: 0; }
.bs-suggest-item {
	width: 100%;
	text-align: left;
	padding: 8px 10px;
	background: transparent;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.92rem;
	font-family: inherit;
	color: #1f2330;
	unicode-bidi: plaintext;
}
.bs-suggest-item:hover,
.bs-suggest-item:focus {
	background: #eff6ff;
	color: #1d6bd6;
	outline: none;
}
.bs-suggest-item.is-current {
	background: #f0fdf4;
	color: #166534;
}

/* ----- Buttons ----- */
.bs-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 16px;
	border: 1px solid #d2d6df;
	background: #fff;
	color: #1f2330;
	border-radius: 8px;
	font-size: 0.9rem;
	cursor: pointer;
	text-decoration: none;
	font-family: inherit;
	transition: all 0.12s;
}
.bs-btn:hover { background: #f5f6f8; text-decoration: none; }
.bs-btn-primary {
	background: #1d6bd6;
	border-color: #1d6bd6;
	color: #fff;
	font-weight: 500;
}
.bs-btn-primary:hover { background: #1656ad; border-color: #1656ad; color: #fff; }
.bs-btn-ghost { background: transparent; }
.bs-link { color: #6c727f; font-size: 0.9rem; }

/* ----- Sticky save bar ----- */
.bs-stickybar {
	position: fixed;
	inset-inline-start: 0;
	inset-inline-end: 0;
	bottom: 0;
	background: #fff;
	border-top: 1px solid #e5e7eb;
	z-index: 50;
	box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.bs-stickybar-inner {
	max-width: 1100px;
	margin: 0 auto;
	padding: 12px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}
.bs-stickybar-status {
	flex: 1 1 auto;
	display: flex;
	justify-content: center;
	font-size: 0.9rem;
}

@media (max-width: 720px) {
	.bs-row {
		grid-template-columns: 1fr 80px;
		row-gap: 6px;
	}
	.bs-row-remark { grid-column: 1 / -1; }
	.bs-row-remark input { background: #f9fafb; border-color: #e5e7eb; }
	.bs-edit-title h1 { font-size: 1.4rem; }
}

/* ===== Error pages ===== */
.beschool-error-page {
	text-align: center;
	padding: 64px 16px;
}
.beschool-error-page h1 {
	font-size: 4rem;
	margin: 0;
	color: #6c727f;
}

@media (max-width: 720px) {
	.beschool-main { padding: 0 12px; }
	.beschool-students { font-size: 0.85rem; }
	.beschool-students th,
	.beschool-students td { padding: 8px; }
	.beschool-field { min-width: 100%; max-width: 100%; }
}
