/* ==========================================================================
   Hyroscope portal layer: shared by every portal on top of the template CSS
   ========================================================================== */
:root {
	--hy-primary: #f26522;
	--hy-dark: #1f1f3a;
	--hy-muted: #6c757d;
	--hy-border: #e9ecef;
	--hy-radius: 10px;
}

/* Cards and headers */
.card { border-radius: var(--hy-radius); border: 1px solid var(--hy-border); box-shadow: 0 1px 3px rgba(20, 20, 50, .04); }
.card-header.headerGradient { border-radius: var(--hy-radius) var(--hy-radius) 0 0; }
.card-header .card-title { font-size: 1rem; font-weight: 600; }
.page-header .page-title { font-weight: 600; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; background: rgba(242, 101, 34, .12); color: var(--hy-primary); }
.stat-card h3 { font-weight: 700; margin: 0; }
.stat-card .stat-label { color: var(--hy-muted); font-size: .85rem; }
.portal-badge { font-size: .7rem; letter-spacing: .02em; }

/* Tables: never overflow the page */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table td, .table th { vertical-align: middle; }
.table thead th { white-space: nowrap; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: #555; }
th.sortable a { color: inherit; text-decoration: none; }
th.sortable a:hover { color: var(--hy-primary); }

/* Empty / error states */
.empty-state { text-align: center; padding: 32px 16px; color: var(--hy-muted); }
.empty-state i { font-size: 36px; color: #c7c7d6; display: block; margin-bottom: 10px; }
.empty-state p { margin-bottom: 0; }

/* Toasts (flash messages) */
.hy-toast-stack { position: fixed; top: 76px; right: 16px; z-index: 2000; width: min(380px, calc(100vw - 32px)); }
.hy-toast-stack .alert { box-shadow: 0 6px 20px rgba(0, 0, 0, .12); margin-bottom: 10px; }

/* Buttons in loading state */
.btn.is-loading { position: relative; pointer-events: none; opacity: .75; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; margin-left: 8px; display: inline-block; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: hy-spin .7s linear infinite; }
@keyframes hy-spin { to { transform: rotate(360deg); } }

/* Filter bar + pager */
.filter-card .form-group { margin-bottom: .75rem; }
.filter-card label { font-size: .85rem; font-weight: 500; }
.hy-pager .pagination { margin: 0; }
.hy-filter-chips .badge { font-weight: 500; }

/*
 * Stacked tables: below 768px every list table becomes one card per row, each cell labelled
 * with its column header (data-label is filled in by portal.js). Opt out with .no-stack.
 */
@media (max-width: 767.98px) {
	table.table-stack { border: 0; }
	table.table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td { display: block; width: 100%; }
	table.table-stack tr { border: 1px solid var(--hy-border); border-radius: var(--hy-radius); margin-bottom: 12px; padding: 6px 12px; background: #fff; box-shadow: 0 1px 2px rgba(20, 20, 50, .04); }
	table.table-stack > tbody > tr > td { border: 0; border-bottom: 1px dashed var(--hy-border); padding: 7px 0 7px 38%; position: relative; text-align: left !important; white-space: normal !important; min-height: 32px; box-shadow: none; background: transparent; }
	table.table-stack > tbody > tr > td:last-child { border-bottom: 0; }
	table.table-stack > tbody > tr > td::before { content: attr(data-label); position: absolute; left: 0; top: 7px; width: 35%; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--hy-muted); white-space: normal; }
	/* Cells without a header (actions, checkboxes) use the full width */
	table.table-stack > tbody > tr > td.hy-nolabel { padding-left: 0; }
	table.table-stack > tbody > tr > td.hy-nolabel::before { display: none; }
	table.table-stack > tbody > tr > td:empty { display: none; }
	table.table-stack > tbody > tr > td[colspan] { padding-left: 0; text-align: center !important; }
	table.table-stack > tbody > tr > td[colspan]::before { display: none; }
	table.table-stack .btn { margin: 2px 0; }
	table.table-stack form { display: inline-block; }
	.table-responsive > table.table-stack { margin-bottom: 0; }
	.hy-pager { justify-content: center !important; text-align: center; }
}

/* Error page */
.error-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #fff5ef, #eef0ff); padding: 16px; }
.error-card { background: #fff; border-radius: 16px; padding: 40px 28px; max-width: 480px; width: 100%; text-align: center; box-shadow: 0 10px 40px rgba(30, 30, 80, .12); }
.error-logo { max-height: 48px; margin-bottom: 18px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--hy-primary); line-height: 1; }
.error-card h1 { font-size: 1.5rem; margin: 10px 0; }
.error-card p { color: var(--hy-muted); }

/* Responsive fixes */
@media (max-width: 991.98px) {
	.page-wrapper > .content { padding: 20px 14px; }
	.page-header .col-auto { margin-top: 10px; }
	.card-header.d-flex { flex-wrap: wrap; gap: 8px; }
	.user-menu .top-nav-search { display: none; }
}
@media (max-width: 575.98px) {
	.page-header .page-title { font-size: 1.25rem; }
	.table { font-size: .85rem; }
	.modal-dialog { margin: .5rem; }
	.btn-group-responsive > .btn, .btn-group-responsive > form { width: 100%; margin-bottom: 6px; }
	.account-box { width: calc(100vw - 24px); }
	.error-code { font-size: 48px; }
	.hy-toast-stack { top: 64px; }
}
img, video, canvas, iframe { max-width: 100%; }
body { overflow-x: hidden; }

/* Role & Permission Matrix (create-role-access.php, edit-role-access.php) */
.perm-wrap { max-height: 72vh; overflow: auto; }
.perm-matrix { font-size: .85rem; border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.perm-matrix .perm-mod-col > .d-flex > div:first-child { min-width: 0; flex: 1; }
.perm-matrix thead th { position: sticky; top: 0; z-index: 3; background: #fff; vertical-align: top; min-width: 132px; box-shadow: inset 0 -1px 0 var(--hy-border); }
.perm-matrix .perm-mod-col { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 280px; max-width: 340px; box-shadow: inset -1px 0 0 var(--hy-border); }
.perm-matrix thead th.perm-mod-col { z-index: 4; }
.perm-matrix .perm-group td { background: #f6f7fb; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; color: var(--hy-muted); position: sticky; left: 0; }
.perm-matrix .perm-row-set { width: auto; min-width: 74px; flex-shrink: 0; }
.perm-matrix td.perm-changed { background: #fff8e6; box-shadow: inset 0 0 0 2px #ffc107; }
.perm-sel { min-width: 84px; font-weight: 600; }
.perm-sel.perm-yes, .perm-badge.perm-yes { background-color: #e7f6ec; color: #146c2e; border-color: #9fd8b1; }
.perm-sel.perm-view, .perm-badge.perm-view { background-color: #e7f1fb; color: #0b5394; border-color: #9cc3ea; }
.perm-sel.perm-no, .perm-badge.perm-no { background-color: #f4f4f6; color: #6c757d; }
.perm-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, .1); }
.perm-dot.perm-yes { background: #b7e4c7; } .perm-dot.perm-view { background: #b6d4f2; } .perm-dot.perm-no { background: #e2e3e5; }
.perm-na { color: #c3c6cc; }
.perm-savebar { position: sticky; bottom: 12px; z-index: 20; margin: 12px auto 0; width: fit-content; max-width: 100%; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
	background: var(--hy-dark); color: #fff; padding: 10px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(20, 20, 50, .25); }
.perm-choice .btn { min-width: 76px; }
@media (max-width: 767.98px) {
	.perm-matrix .perm-mod-col { min-width: 190px; }
	.perm-savebar { border-radius: 12px; }
}

/* Sidebar: scroll the menu when it is taller than the screen (all portals).
   The template's slimScroll is disabled in app.js, so native scrolling is used. */
.sidebar .sidebar-inner {
	height: 100%;
	overflow-y: auto;
	overflow-x: hidden;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .28) transparent;
}
.sidebar .sidebar-menu { padding-bottom: 24px; }
.sidebar .sidebar-inner::-webkit-scrollbar { width: 6px; }
.sidebar .sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.sidebar .sidebar-inner::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .25); border-radius: 6px; }
.sidebar .sidebar-inner:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .45); }

/* Required field marker (portal.js hyMarkRequired) */
.hy-req, .mandatory { color: #dc3545 !important; font-weight: 700; margin-left: 3px; }
