/* StudentPower theme for the admin panel.

   Loaded after Tabler, so it only sets Tabler's own CSS variables plus a few
   components of ours (sp-*). Dark is the default; the toggle in the top bar
   stores the choice in localStorage ("sp-theme"). */

:root,
[data-bs-theme=light] {
    --sp-violet: #6a5ae0;
    --sp-violet-rgb: 106, 90, 224;
    --sp-violet-dark: #5646cc;
    --sp-sidebar: #11141c;
    --sp-sidebar-border: #1f2430;
    --sp-sidebar-text: #b4bccb;
    --sp-sidebar-hover: #1a1f2a;

    --tblr-primary: var(--sp-violet);
    --tblr-primary-rgb: var(--sp-violet-rgb);
    --tblr-primary-darken: var(--sp-violet-dark);
    --tblr-primary-fg: #ffffff;
    --tblr-primary-lt: #efedfc;
    --tblr-primary-lt-rgb: 239, 237, 252;
    --tblr-primary-text-emphasis: #4a3bb8;
    --tblr-link-color: #5646cc;
    --tblr-link-color-rgb: 86, 70, 204;
    --tblr-link-hover-color: #3f31a8;
    --tblr-link-hover-color-rgb: 63, 49, 168;
    --tblr-border-radius: 8px;
    --tblr-border-radius-lg: 12px;
    --tblr-card-border-radius: 12px;
    --tblr-body-bg: #f4f5f8;
}

[data-bs-theme=dark],
body[data-bs-theme=dark] [data-bs-theme=light] {
    --tblr-body-bg: #0d1017;
    --tblr-body-bg-rgb: 13, 16, 23;
    --tblr-body-color: #e7eaf0;
    --tblr-body-color-rgb: 231, 234, 240;
    --tblr-bg-surface: #161a23;
    --tblr-bg-surface-dark: #11141c;
    --tblr-bg-surface-secondary: #1c212c;
    --tblr-bg-surface-tertiary: #12161e;
    --tblr-bg-forms: #12161e;
    --tblr-secondary-bg: #1c212c;
    --tblr-tertiary-bg: #12161e;
    --tblr-active-bg: #1f2430;
    --tblr-border-color: #262c39;
    --tblr-border-color-translucent: rgba(140, 150, 170, .14);
    --tblr-secondary: #98a1b0;
    --tblr-secondary-color: #98a1b0;
    --tblr-muted: #98a1b0;
    --tblr-code-bg: #1f2430;
    --tblr-primary-lt: #231f3f;
    --tblr-primary-lt-rgb: 35, 31, 63;
    --tblr-primary-text-emphasis: #c4bbff;
    --tblr-link-color: #a99cf9;
    --tblr-link-color-rgb: 169, 156, 249;
    --tblr-link-hover-color: #c8bfff;
    --tblr-link-hover-color-rgb: 200, 191, 255;
}

body {
    background: var(--tblr-body-bg);
}

/* Sidebar */
.navbar-vertical.navbar-expand-lg {
    background: var(--sp-sidebar);
    box-shadow: inset -1px 0 0 0 var(--sp-sidebar-border);
}
.navbar-vertical .navbar-brand {
    padding: .25rem 0 .5rem;
}
.navbar-vertical .navbar-logo {
    height: 2.25rem;
}
.navbar-vertical .navbar-nav .nav-link {
    color: var(--sp-sidebar-text);
    border-radius: 8px;
    margin: 1px .5rem;
    padding: .55rem .75rem;
    font-weight: 500;
}
.navbar-vertical .navbar-nav .nav-link:hover {
    background: var(--sp-sidebar-hover);
    color: #ffffff;
}
.navbar-vertical .navbar-nav .nav-item.active > .nav-link,
.navbar-vertical .navbar-nav .nav-link.active {
    background: rgba(var(--sp-violet-rgb), .22);
    color: #ffffff;
}
.navbar-vertical .navbar-nav .nav-item.active::after,
.navbar-vertical .navbar-nav .nav-link.active::after {
    display: none;
}
.navbar-vertical .nav-link-icon {
    color: inherit;
    opacity: .9;
}

/* Top bar */
.sp-topbar {
    background: var(--tblr-bg-surface);
    border-bottom: 1px solid var(--tblr-border-color);
    min-height: 3.75rem;
}
.sp-topbar .sp-search {
    max-width: 32rem;
    flex: 1 1 18rem;
}
.sp-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(var(--sp-violet-rgb), .2);
    color: var(--tblr-primary-text-emphasis);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex: none;
}
.sp-avatar-lg {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.15rem;
}
.sp-icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
[data-bs-theme=dark] .sp-show-light,
[data-bs-theme=light] .sp-show-dark,
:root:not([data-bs-theme]) .sp-show-dark {
    display: none !important;
}

/* Page */
.page-header h1,
.page-header .page-title {
    font-weight: 700;
    letter-spacing: -.015em;
}
.card {
    border-radius: var(--tblr-card-border-radius);
}
.card-table thead th,
.table thead th {
    font-size: .72rem;
    letter-spacing: .04em;
    color: var(--tblr-secondary);
}

/* Badges: a tinted pill whose text passes 4.5:1 in both themes. */
.sp-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.2rem;
    white-space: nowrap;
}
.sp-badge::before {
    content: "";
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.sp-badge.sp-plain::before {
    display: none;
}
.sp-ok { background: rgba(22, 163, 74, .12); color: #15803d; }
.sp-warn { background: rgba(217, 119, 6, .14); color: #a15c07; }
.sp-err { background: rgba(220, 38, 38, .12); color: #b91c1c; }
.sp-info { background: rgba(37, 99, 235, .12); color: #1d4ed8; }
.sp-run { background: rgba(8, 145, 178, .13); color: #0e7490; }
.sp-mute { background: rgba(100, 116, 139, .14); color: #475569; }
.sp-acc { background: rgba(var(--sp-violet-rgb), .14); color: #4a3bb8; }
[data-bs-theme=dark] .sp-ok { background: rgba(74, 222, 128, .12); color: #6ee7a0; }
[data-bs-theme=dark] .sp-warn { background: rgba(251, 191, 36, .13); color: #fcd34d; }
[data-bs-theme=dark] .sp-err { background: rgba(248, 113, 113, .13); color: #fca5a5; }
[data-bs-theme=dark] .sp-info { background: rgba(96, 165, 250, .13); color: #93c5fd; }
[data-bs-theme=dark] .sp-run { background: rgba(34, 211, 238, .12); color: #67e8f9; }
[data-bs-theme=dark] .sp-mute { background: #232936; color: #b4bccb; }
[data-bs-theme=dark] .sp-acc { background: rgba(123, 108, 246, .2); color: #c4bbff; }

.sp-ok-text { color: #15803d; }
.sp-warn-text { color: #a15c07; }
.sp-err-text { color: #b91c1c; }
[data-bs-theme=dark] .sp-ok-text { color: #6ee7a0; }
[data-bs-theme=dark] .sp-warn-text { color: #fcd34d; }
[data-bs-theme=dark] .sp-err-text { color: #fca5a5; }

/* Stat cards */
.sp-stat {
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    height: 100%;
}
.sp-stat-label {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--tblr-secondary);
}
.sp-stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.1;
}
.sp-stat-value small {
    font-size: .95rem;
    font-weight: 600;
    color: var(--tblr-secondary);
}
.sp-stat-note {
    font-size: .82rem;
    color: var(--tblr-secondary);
}
.sp-stat-icon {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
}
.sp-stat-icon::before { display: none; }

.sp-bar {
    height: .4rem;
    border-radius: 999px;
    background: var(--tblr-border-color);
    overflow: hidden;
}
.sp-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--tblr-primary);
}

/* Lists of events (dashboard feed, order timeline) */
.sp-feed-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-size: .8rem;
}
.sp-feed-icon::before { display: none; }

.sp-dl dt {
    font-weight: 500;
    color: var(--tblr-secondary);
}
.sp-dl dd {
    margin-bottom: .6rem;
}

.sp-mono {
    font-family: var(--tblr-font-monospace);
    font-size: .85em;
}

.sp-file {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: 10px;
    background: var(--tblr-bg-surface-secondary);
    color: inherit;
    min-width: 12rem;
    text-align: left;
}
.sp-file:hover {
    border-color: rgba(var(--sp-violet-rgb), .6);
    color: inherit;
    text-decoration: none;
}
.sp-file i {
    font-size: 1.3rem;
    color: var(--tblr-primary-text-emphasis);
}

/* Flash messages float in the corner and fade out (support/_base.html). */
.sp-toasts {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: min(28rem, calc(100vw - 2rem));
}
.sp-toasts .alert {
    margin: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    transition: opacity .4s;
}

.sp-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--tblr-secondary);
}
.sp-empty i {
    display: block;
    font-size: 1.6rem;
    margin-bottom: .5rem;
    opacity: .6;
}

@media (max-width: 575.98px) {
    .page-body .container-fluid,
    .page-wrapper > .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .sp-stat-value {
        font-size: 1.5rem;
    }
}

/* Grids: no button column (sp-render.js); the ID is the link. */
#dt > thead > tr > th:nth-child(2),
#dt > tbody > tr > td:nth-child(2) {
    display: none;
}
#dt .sp-open {
    font-weight: 600;
    text-decoration: none;
}
#dt .sp-open:hover {
    text-decoration: underline;
}
#dt > tbody > tr:hover > td {
    background: var(--tblr-active-bg);
}

/* The filter panel beside a grid (templates/list.html). */
.sp-filters .sp-filter-group {
    padding: .85rem 1rem;
    border-top: 1px solid var(--tblr-border-color);
}
.sp-filters .collapse > .sp-filter-group:first-child {
    border-top: 0;
}
.sp-filter-link {
    display: block;
    padding: .3rem .6rem;
    margin: 0 -.6rem;
    border-radius: 6px;
    color: var(--tblr-body-color);
    text-decoration: none;
}
.sp-filter-link:hover {
    background: var(--tblr-active-bg);
    color: var(--tblr-body-color);
    text-decoration: none;
}
.sp-filter-link.active {
    background: rgba(var(--sp-violet-rgb), .18);
    color: var(--tblr-primary-text-emphasis);
    font-weight: 600;
}

/* DataTables' own buttons and menus (Export, Show/Hide columns, rows per
   page) ship light-only styles; these follow the theme instead. */
#btn_container .dt-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0;
}
#btn_container .dt-buttons > .btn,
#btn_container .dt-buttons > .btn-group > .btn,
.dt-buttons .btn-secondary {
    background: var(--tblr-bg-surface-secondary);
    border: 1px solid var(--tblr-border-color);
    border-radius: 8px !important;
    color: var(--tblr-body-color);
    box-shadow: none;
}
#btn_container .dt-buttons .btn:hover,
.dt-buttons .btn-secondary:hover,
.dt-buttons .btn-secondary[aria-expanded=true] {
    border-color: rgba(var(--sp-violet-rgb), .6);
    background: var(--tblr-active-bg);
    color: var(--tblr-body-color);
}
body div.dt-button-collection {
    background-color: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
    padding: .35rem;
    width: auto;
    min-width: 13rem;
    margin-top: .35rem;
}
body div.dt-button-collection div.dropdown-menu {
    background: transparent;
    padding: 0;
}
body div.dt-button-collection .dt-button,
body div.dt-button-collection .dropdown-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .5rem .75rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--tblr-body-color);
    opacity: 1;
    text-align: left;
}
body div.dt-button-collection .dt-button:hover,
body div.dt-button-collection .dropdown-item:hover {
    background: var(--tblr-active-bg);
    color: var(--tblr-body-color);
}
/* Show/Hide columns: a shown column is ticked, a hidden one is greyed. */
body div.dt-button-collection .buttons-columnVisibility::before {
    content: "";
    width: 1rem;
    flex: none;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: .8rem;
}
body div.dt-button-collection .buttons-columnVisibility.active::before {
    content: "\f00c";
    color: var(--tblr-primary-text-emphasis);
}
body div.dt-button-collection .buttons-columnVisibility:not(.active) {
    color: var(--tblr-secondary);
}
body div.dt-button-collection .buttons-columnVisibility.active {
    background: transparent;
}
body div.dt-button-background {
    background: transparent;
}
/* The package's grid brings its own padded container; beside the filter
   panel it would push the table off the page title's line. */
.sp-list-main > .container-fluid {
    padding-left: 0;
    padding-right: 0;
}
body div.dt-button-collection.fixed {
    background-color: var(--tblr-bg-surface);
}
