/*
 * HyperPro shared UI layer. Loaded after Bootstrap by all four layouts
 * (public, admin, center, student). Brand colours stay per-layout; this file
 * only adds shared shape, motion and reusable component classes (hp-*).
 */

:root {
    --hp-ease: cubic-bezier(.2, .7, .2, 1);
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img { max-width: 100%; }

/* Buttons: consistent weight, lift and press feedback. */
.btn {
    font-weight: 600;
    letter-spacing: .005em;
    border-radius: var(--radius-sm, 10px);
    transition: transform .18s var(--hp-ease), box-shadow .18s var(--hp-ease), background-color .18s, border-color .18s, color .18s;
}
.btn:not(:disabled):not(.disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):not(.disabled):active { transform: translateY(0); }
.btn-sm { border-radius: 8px; }
.btn-lg { border-radius: var(--radius-md, 14px); }

/* Cards: softer border, lift only for interactive ones. */
.card {
    border: 1px solid var(--line, #e2e8f0);
    border-radius: var(--radius-md, 14px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, .05));
}
.card-header { background: transparent; border-bottom: 1px solid var(--line, #e2e8f0); font-weight: 600; }
.card-footer { background: transparent; border-top: 1px solid var(--line, #e2e8f0); }
.hover-lift { transition: transform .2s var(--hp-ease), box-shadow .2s var(--hp-ease), border-color .2s; }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md, 0 12px 28px -10px rgba(15, 23, 42, .16)); }

/* Tables: quiet header, subtle row hover. */
.table { --bs-table-hover-bg: color-mix(in srgb, var(--ink-900, #0f172a) 3%, transparent); }
.table > :not(caption) > * > * { padding: .8rem 1rem; }
.table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-500, #6b7785);
    font-weight: 700;
    border-bottom: 1px solid var(--line, #e2e8f0);
    white-space: nowrap;
}
.table tbody td { vertical-align: middle; border-color: var(--line, #e2e8f0); }

/* Form controls: larger touch target, clearer labels. */
.form-control, .form-select { padding: .6rem .85rem; transition: border-color .15s, box-shadow .15s; }
.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-700, #3c4a56); margin-bottom: .35rem; }
.form-text, .invalid-feedback { font-size: .78rem; }

/* Alerts, modals, dropdowns, pagination. */
.alert { border: 0; border-left: 4px solid currentColor; box-shadow: var(--shadow-sm, none); }
.modal-content { border: 0; box-shadow: var(--shadow-md, 0 20px 40px -12px rgba(15, 23, 42, .3)); }
.modal-header, .modal-footer { border-color: var(--line, #e2e8f0); }
.dropdown-menu { border: 1px solid var(--line, #e2e8f0); box-shadow: var(--shadow-md, 0 12px 28px -10px rgba(15, 23, 42, .16)); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; font-size: .9rem; }
.pagination { gap: .25rem; flex-wrap: wrap; }
.page-link { border-radius: 8px !important; border-color: var(--line, #e2e8f0); }

/* ---- Reusable components ------------------------------------------------ */

/* Panel page header: title + subtitle left, actions right. */
.hp-page-header {
    display: flex; flex-wrap: wrap; gap: .75rem 1rem;
    align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem;
}
.hp-page-header h1, .hp-page-header .h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.hp-page-header p { margin: .15rem 0 0; color: var(--ink-500, #6b7785); font-size: .88rem; }

/* Stat tile: icon, big number, label. Set --hp-accent per tile. */
.hp-stat {
    display: flex; align-items: center; gap: .9rem;
    background: var(--paper-1, #fff);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: var(--radius-md, 14px);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm, none);
    transition: transform .2s var(--hp-ease), box-shadow .2s var(--hp-ease);
}
.hp-stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md, none); }
.hp-stat__icon {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.15rem;
    background: color-mix(in srgb, var(--hp-accent, #2563eb) 12%, white);
    color: var(--hp-accent, #2563eb);
}
.hp-stat__value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--ink-900, #0f172a); font-variant-numeric: tabular-nums; }
.hp-stat__label { font-size: .78rem; color: var(--ink-500, #6b7785); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

/* Empty state. */
.hp-empty { text-align: center; padding: 3rem 1rem; color: var(--ink-500, #6b7785); }
.hp-empty i { font-size: 2.2rem; opacity: .45; margin-bottom: .75rem; display: block; }

/* Horizontally scrollable chip row (replaces wrapping pill piles). */
.hp-chip-row {
    display: flex; gap: .5rem; align-items: center;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding: .15rem .1rem; scroll-snap-type: x proximity;
}
.hp-chip-row::-webkit-scrollbar { display: none; }
.hp-chip {
    flex: 0 0 auto; scroll-snap-align: start;
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .42rem .85rem; border-radius: 999px;
    border: 1px solid var(--line, #e2e8f0);
    background: var(--paper-1, #fff);
    color: var(--ink-700, #3c4a56);
    font-size: .82rem; font-weight: 600; text-decoration: none; white-space: nowrap;
    transition: border-color .15s, background-color .15s, transform .15s var(--hp-ease);
}
.hp-chip:hover { border-color: var(--primary-color, #2563eb); transform: translateY(-1px); color: var(--ink-900, #0f172a); }
.hp-chip__count {
    font-size: .7rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color, #2563eb) 12%, white);
    color: var(--primary-color, #2563eb);
}

/* Section heading used on public pages. */
.hp-section-title { font-weight: 800; letter-spacing: -.01em; }
.hp-eyebrow {
    display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--secondary-color, #720f0e); margin-bottom: .4rem;
}

/* Skeleton shimmer for loading states. */
.hp-skeleton {
    background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 37%, #eef1f5 63%);
    background-size: 400% 100%; animation: hp-shimmer 1.4s ease infinite; border-radius: 8px;
}
@keyframes hp-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 575.98px) {
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .hp-page-header h1, .hp-page-header .h1 { font-size: 1.2rem; }
    .modal-dialog { margin: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
    .btn, .hp-chip-row, .pwa-mobile-bottom-bar, .floating-whatsapp-btn { display: none !important; }
}

/* News ticker: CSS replacement for the obsolete <marquee>. Pauses on hover/focus. */
.hp-ticker { overflow: hidden; white-space: nowrap; width: 100%; }
.hp-ticker__track { display: inline-block; padding-left: 100%; animation: hp-ticker 40s linear infinite; }
.hp-ticker:hover .hp-ticker__track, .hp-ticker:focus-within .hp-ticker__track { animation-play-state: paused; }
@keyframes hp-ticker { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .hp-ticker__track { padding-left: 0; white-space: normal; animation: none !important; } }

/* Headings on dark/brand surfaces inherit the surface's text colour instead
   of the layout's global dark heading colour (was unreadable dark-on-dark). */
:is(.bg-dark, .bg-primary, .bg-secondary, .bg-success, .bg-danger, .text-white) :is(h1, h2, h3, h4, h5, h6) { color: inherit; }

/* ---- Eduwise theme -------------------------------------------------------
   Typography and shape taken from the Eduwise education template: Rubik
   headings over Poppins body, #333146 ink, #6a7a83 body text, flat 6-8px
   corners, uppercase-tracked eyebrow labels. Brand colours stay per-tenant
   (layouts supply --primary-color etc.; Eduwise blue/orange are the fallbacks). */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6,
.hp-page-header h1, .hp-stat__value, .navbar-brand, .modal-title, .card-header {
    font-family: 'Rubik', 'Poppins', sans-serif;
    color: var(--ink-900, #333146);
    letter-spacing: 0;
}
h1, h2, .hp-section-title { font-weight: 700; }
body { color: var(--ink-500, #6a7a83); line-height: 1.7; }
.table thead th { font-family: 'Rubik', 'Poppins', sans-serif; letter-spacing: .04em; color: var(--ink-900, #333146); }

.btn { font-family: 'Rubik', 'Poppins', sans-serif; text-transform: none; border-radius: 5px; padding: .55rem 1.3rem; }
.btn-sm { padding: .35rem .85rem; border-radius: 4px; }
.btn-lg { padding: .8rem 2rem; border-radius: 6px; }
.btn-warning, .btn-accent { background: #ff5a2c; border-color: #ff5a2c; color: #fff; }
.btn-warning:hover, .btn-accent:hover { background: #e04a1f; border-color: #e04a1f; color: #fff; }

.card, .hp-stat, .modal-content { border-radius: 8px; }
.card { border-color: #eceef3; box-shadow: 0 2px 14px rgba(51, 49, 70, .06); }
.hover-lift:hover, .hp-stat:hover { box-shadow: 0 10px 30px rgba(51, 49, 70, .12); }
.hp-stat__icon { border-radius: 8px; }

.hp-eyebrow { color: #ff5a2c; font-family: 'Rubik', 'Poppins', sans-serif; letter-spacing: .14em; }
.hp-chip { border-radius: 5px; font-family: 'Rubik', 'Poppins', sans-serif; }
.hp-chip:hover { border-color: #ff5a2c; color: #ff5a2c; }

.form-control, .form-select { border-radius: 5px; border-color: #dfe3ea; }
.form-control:focus, .form-select:focus { border-color: #092ace; box-shadow: 0 0 0 .2rem rgba(9, 42, 206, .12); }
.form-label { font-family: 'Rubik', 'Poppins', sans-serif; color: var(--ink-900, #333146); }
.page-link { border-radius: 5px !important; }
.dropdown-menu { border-radius: 8px; }
.dropdown-item { border-radius: 5px; }


/* ---- Dock (theme toggle + search) and search palette ---------------------- */
.hp-dock { position: fixed; right: 14px; bottom: 84px; z-index: 1040; display: flex; gap: .4rem; }
body:has(.floating-whatsapp-btn) .hp-dock { right: auto; left: 14px; bottom: 14px; }
.hp-dock__btn {
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line, #e2e8f0);
    background: var(--paper-1, #fff); color: var(--ink-700, #4f5468); box-shadow: 0 4px 14px rgba(15, 23, 42, .15);
    display: grid; place-items: center; cursor: pointer;
}
.hp-dock__btn:hover { color: var(--primary-color, #092ace); }
@media print { .hp-dock { display: none !important; } }
.hp-search { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .55); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 1rem 1rem; }
.hp-search[hidden] { display: none; }
.hp-search__box { width: 100%; max-width: 560px; background: var(--paper-1, #fff); border-radius: 12px; padding: .75rem; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.hp-search__results { max-height: 50vh; overflow-y: auto; margin-top: .5rem; }
.hp-search__row { display: flex; gap: .75rem; align-items: center; padding: .55rem .6rem; border-radius: 8px; color: inherit; text-decoration: none; }
.hp-search__row:hover, .hp-search__row:focus { background: color-mix(in srgb, var(--primary-color, #092ace) 10%, transparent); }
.hp-search__empty { padding: 1rem; text-align: center; color: var(--ink-500, #6a7a83); }

/* ---- Dark mode: tokens first, then the hard-coded light surfaces ------------ */
:root[data-bs-theme="dark"] {
    --paper-0: #0f1424;
    --paper-1: #171d33;
    --line: #2a3250;
    --ink-900: #eef0f8;
    --ink-700: #c3c8dc;
    --ink-500: #9aa3bd;
    color-scheme: dark;
}
[data-bs-theme="dark"] body { background-color: var(--paper-0); color: var(--ink-700); }
[data-bs-theme="dark"] :is(.card, .data-card, .modal-content, .dropdown-menu, .list-group-item, .main-header, .hp-stat, .hp-chip, .hp-dock__btn, .pwa-install-banner) {
    background-color: var(--paper-1);
    color: var(--ink-700);
    border-color: var(--line);
}
[data-bs-theme="dark"] :is(.bg-white, .bg-light, .table-light, .card-header, .card-footer, .data-card-header) { background-color: var(--paper-1) !important; color: var(--ink-700); }
[data-bs-theme="dark"] :is(.text-dark, .text-body, .text-black) { color: var(--ink-900) !important; }
[data-bs-theme="dark"] :is(.text-muted, .text-secondary) { color: var(--ink-500) !important; }
[data-bs-theme="dark"] :is(.table) { --bs-table-color: var(--ink-700); --bs-table-bg: transparent; --bs-table-hover-bg: rgba(255, 255, 255, .04); border-color: var(--line); }
[data-bs-theme="dark"] .table thead th { color: var(--ink-900); }
[data-bs-theme="dark"] :is(.form-control, .form-select, .input-group-text) { background-color: #1d2440; color: var(--ink-900); border-color: var(--line); }
[data-bs-theme="dark"] .form-control::placeholder { color: var(--ink-500); }
[data-bs-theme="dark"] .hp-skeleton { background: linear-gradient(90deg, #1d2440 25%, #263056 37%, #1d2440 63%); background-size: 400% 100%; }
[data-bs-theme="dark"] .hp-search__box { background: var(--paper-1); }

/* ---- Phones: keep panels inside the viewport ------------------------------ */
@media (max-width: 767.98px) {
    /* Admin top bar: icons only, so tenant switcher + user menu fit beside the title. */
    .admin-header { gap: .5rem; padding-left: .75rem; padding-right: .75rem; }
    .admin-header h5 { font-size: 1rem; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .admin-header > div { min-width: 0; gap: .5rem !important; }
    .admin-header .dropdown > .btn > span:not(.badge),
    .admin-header a.btn-outline-primary,
    .admin-header a.btn-outline-success span { display: none; }

    /* Center top bar: shorter title, user name hidden beside the avatar. */
    .center-header { gap: .5rem; padding-left: .75rem; padding-right: .75rem; }
    .center-header h5 { font-size: 1rem; max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .center-header > div { min-width: 0; }
    .center-header > div:last-child { gap: .25rem !important; flex: 0 0 auto; }
    .center-header { padding-right: .5rem; }
    .center-header .wallet-badge { padding: .25rem .5rem; font-size: .75rem; }
    .center-header .wallet-badge i { display: none; }
    .center-header .btn-light.dropdown-toggle { padding: .25rem .4rem; }
    .center-header .dropdown > .dropdown-toggle > span:not(.badge),
    .center-header .dropdown > .dropdown-toggle > div { display: none; }

    /* Stat tiles: smaller type and wrapping labels so values never clip. */
    .hp-stat { padding: .75rem; gap: .6rem; }
    .hp-stat__icon { width: 36px; height: 36px; font-size: .95rem; }
    .hp-stat__value { font-size: 1.15rem; }
    .hp-stat__label { font-size: .68rem; letter-spacing: .02em; overflow-wrap: anywhere; }

    /* Headers: the title column yields space to the action buttons. */
    .center-header > div:first-child, .admin-header > div:first-child { flex: 1 1 auto; min-width: 0; overflow: hidden; }
    .center-header h5, .admin-header h5 { max-width: 100%; }

    /* Tables that were not wrapped in .table-responsive scroll inside their card. */
    :not(.table-responsive) > .table { display: block; overflow-x: auto; max-width: 100%; white-space: nowrap; }
}
