/* ==========================================================================
   SubPanel — modern admin theme
   Dark navy sidebar + light content, soft cards, gradient stat tiles.
   All custom styling lives here; pages only use Bootstrap 5 utilities.
   ========================================================================== */

:root {
    --sp-bg:            #f2f4fa;
    --sp-ink:           #1e2438;
    --sp-muted:         #6b7390;
    --sp-card:          #ffffff;
    --sp-radius:        1rem;
    --sp-radius-sm:     .65rem;
    --sp-shadow:        0 .5rem 1.5rem rgba(23, 32, 68, .07);
    --sp-shadow-lg:     0 1rem 2.5rem rgba(23, 32, 68, .12);
    --sp-accent:        #6366f1;
    --sp-accent-2:      #8b5cf6;
    --sp-sidebar-1:     #1c2444;
    --sp-sidebar-2:     #121830;
    --sp-nav-ink:       #aab2d8;
    --sp-line:          #e9edf6;
    --sp-font:          "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                        Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--sp-bg);
    color: var(--sp-ink);
    font-family: var(--sp-font);
    font-size: .9375rem;
}

::selection { background: rgba(99, 102, 241, .22); }

:focus-visible {
    outline: 2px solid var(--sp-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ==========================================================================
   App shell: fixed sidebar + main column
   ========================================================================== */
.sp-layout { min-height: 100vh; }

.sp-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--sp-sidebar-1) 0%, var(--sp-sidebar-2) 100%);
    color: #fff;
}

.sp-main {
    margin-left: 264px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sp-content {
    flex: 1 0 auto;
    padding: 1.5rem;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
}

.sp-footer {
    padding: 1rem 1.5rem 1.5rem;
    color: var(--sp-muted);
    font-size: .8rem;
    text-align: center;
}

/* Brand block */
.sp-brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1.35rem 1.35rem 1.1rem;
    text-decoration: none;
}
.sp-brand:hover { text-decoration: none; }
.sp-brand-mark {
    width: 2.6rem;
    height: 2.6rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .85rem;
    background: linear-gradient(135deg, var(--sp-accent), #a855f7);
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 .5rem 1.1rem rgba(99, 102, 241, .45);
}
.sp-brand-name {
    display: block;
    color: #fff;
    font-weight: 700;
    font-size: 1.02rem;
    line-height: 1.25;
    letter-spacing: -.01em;
}
.sp-brand-sub {
    display: block;
    color: #8b93c4;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-top: .15rem;
}

/* Sidebar navigation */
.sp-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: .25rem 0 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.sp-nav-label {
    padding: 1rem 1.6rem .4rem;
    color: #7c85b3;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.sp-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 2px .8rem;
    padding: .62rem .9rem;
    border-radius: .7rem;
    color: var(--sp-nav-ink);
    text-decoration: none;
    font-weight: 500;
    font-size: .92rem;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sp-nav-link i {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .6rem;
    background: rgba(255, 255, 255, .07);
    font-size: 1rem;
}
.sp-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .07);
    text-decoration: none;
}
.sp-nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
    box-shadow: 0 .5rem 1.1rem rgba(99, 102, 241, .4);
    font-weight: 600;
}
.sp-nav-link.active i { background: rgba(255, 255, 255, .22); }

.sp-sidebar-foot {
    padding: 1rem 1.35rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    color: #7c85b3;
    font-size: .75rem;
}

/* Mobile offcanvas variant of the sidebar */
.sp-offcanvas {
    background: linear-gradient(180deg, var(--sp-sidebar-1) 0%, var(--sp-sidebar-2) 100%);
    color: #fff;
    width: 290px !important;
}
.sp-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sp-offcanvas .sp-nav { padding-top: .5rem; }

/* ==========================================================================
   Topbar
   ========================================================================== */
.sp-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: .9rem;
    min-height: 68px;
    padding: .6rem 1.5rem;
    background: rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--sp-line);
}
.sp-page-title {
    margin: 0;
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .7rem;
    border: 1px solid var(--sp-line);
    background: #fff;
    color: var(--sp-ink);
    font-size: 1.15rem;
}
.sp-icon-btn:hover { background: #f4f6fc; }

.sp-search { flex: 1 1 auto; max-width: 430px; }
.sp-search .form-control {
    border-radius: .7rem 0 0 .7rem;
    border-color: var(--sp-line);
    background: #f7f9fd;
}
.sp-search .btn {
    border-radius: 0 .7rem .7rem 0;
    border-color: var(--sp-line);
    background: #fff;
    color: var(--sp-muted);
}
.sp-search .btn:hover { color: var(--sp-accent); }

.sp-user-btn {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    border: 1px solid var(--sp-line);
    background: #fff;
    border-radius: .8rem;
    padding: .35rem .7rem .35rem .35rem;
}
.sp-user-btn:hover { background: #f7f9fd; }
.sp-user-btn::after { color: var(--sp-muted); }
.sp-avatar {
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .65rem;
    background: linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
    color: #fff;
    font-size: 1.05rem;
}
.sp-user-name { display: block; font-weight: 600; font-size: .85rem; line-height: 1.2; }
.sp-user-role {
    display: block;
    font-size: .68rem;
    color: var(--sp-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ==========================================================================
   Page headings
   ========================================================================== */
.sp-content h2,
.sp-page-head h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -.02em;
}
.sp-content > h2 { font-size: 1.45rem; margin-bottom: .25rem; }
.sp-page-sub { color: var(--sp-muted); font-size: .9rem; margin-bottom: 1.25rem; }

/* ==========================================================================
   Cards
   ========================================================================== */
.sp-content .card {
    border: 0;
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    overflow: hidden;
}
.sp-content .card-header {
    background: transparent;
    border-bottom: 1px solid var(--sp-line);
    padding: .95rem 1.25rem;
}
.sp-content .card-header strong { font-weight: 650; }
.sp-content .card-body { padding: 1.25rem; }

/* ==========================================================================
   Stat tiles (dashboard)
   ========================================================================== */
.sp-stat {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.3rem;
    border-radius: var(--sp-radius);
    color: #fff;
    box-shadow: var(--sp-shadow);
    overflow: hidden;
    min-height: 7.5rem;
    transition: transform .15s ease, box-shadow .15s ease;
}
.sp-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--sp-shadow-lg);
}
.sp-stat-body { position: relative; z-index: 1; min-width: 0; }
.sp-stat-value {
    font-size: 1.55rem;
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.15;
    white-space: nowrap;
}
.sp-stat-label {
    font-size: .78rem;
    font-weight: 500;
    opacity: .88;
    margin-top: .3rem;
}
.sp-stat-icon {
    position: relative;
    z-index: 1;
    font-size: 2.6rem;
    line-height: 1;
    opacity: .32;
}
.sp-stat::after {
    content: "";
    position: absolute;
    right: -2.2rem;
    top: -2.2rem;
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
}
.sp-stat::before {
    content: "";
    position: absolute;
    right: 1.4rem;
    bottom: -2.6rem;
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
/* gradient variants */
.sp-g-indigo { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.sp-g-green  { background: linear-gradient(135deg, #10b981, #34d399); }
.sp-g-amber  { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.sp-g-rose   { background: linear-gradient(135deg, #f43f5e, #fb7185); }
.sp-g-sky    { background: linear-gradient(135deg, #0ea5e9, #38bdf8); }
.sp-g-slate  { background: linear-gradient(135deg, #475569, #94a3b8); }

/* ==========================================================================
   Tables
   ========================================================================== */
.sp-content .table {
    font-size: .9rem;
    margin-bottom: 0;
    --bs-table-hover-bg: #f5f7fd;
}
.sp-content .table thead th {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--sp-muted);
    border-bottom: 2px solid var(--sp-line);
    padding: .8rem .75rem;
    white-space: nowrap;
}
.sp-content .table tbody td {
    padding: .75rem;
    vertical-align: middle;
    border-color: #f0f3f9;
}
.sp-content .table-responsive { border-radius: 0 0 var(--sp-radius) var(--sp-radius); }

/* ==========================================================================
   Buttons, badges, alerts, forms
   ========================================================================== */
.sp-content .btn,
.sp-topbar .btn {
    border-radius: var(--sp-radius-sm);
    font-weight: 550;
}
.btn-primary {
    background: linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
    border: 0;
    box-shadow: 0 .35rem .9rem rgba(99, 102, 241, .35);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #5457ee, #7c4dff);
    box-shadow: 0 .5rem 1.1rem rgba(99, 102, 241, .45);
}
.btn-outline-primary { border-color: #c7cbfb; color: #4f46e5; }
.btn-outline-primary:hover { background: var(--sp-accent); border-color: var(--sp-accent); }

.sp-content .badge { font-weight: 600; letter-spacing: .01em; padding: .35em .65em; }

.sp-content .alert {
    border: 0;
    border-radius: .8rem;
    box-shadow: var(--sp-shadow);
}

.sp-content .form-control,
.sp-content .form-select,
.sp-topbar .form-control {
    border-radius: var(--sp-radius-sm);
    border-color: #dfe4f0;
    padding: .55rem .85rem;
}
.sp-content .form-control:focus,
.sp-content .form-select:focus {
    border-color: var(--sp-accent);
    box-shadow: 0 0 0 .22rem rgba(99, 102, 241, .16);
}
.sp-content .form-label { font-weight: 600; font-size: .85rem; }
.sp-content .input-group .btn { border-radius: 0 var(--sp-radius-sm) var(--sp-radius-sm) 0; }

.sp-content .list-group-item { border-color: #f0f3f9; }
.sp-content .pagination .page-link { border-radius: .5rem; margin: 0 .1rem; border-color: var(--sp-line); }

/* Definition lists / detail views */
.sp-content dl.row dt { color: var(--sp-muted); font-weight: 600; font-size: .85rem; }
.sp-content pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #f7f9fd;
    border: 1px solid var(--sp-line);
    border-radius: var(--sp-radius-sm);
    padding: .9rem 1rem;
}

/* Accordion */
.sp-content .accordion-item { border: 0; box-shadow: var(--sp-shadow); border-radius: var(--sp-radius) !important; overflow: hidden; }
.sp-content .accordion-button:not(.collapsed) { background: #eef0fe; color: #4338ca; box-shadow: none; }
.sp-content .accordion-button:focus { box-shadow: 0 0 0 .22rem rgba(99, 102, 241, .16); }

/* ==========================================================================
   Login page
   ========================================================================== */
body.sp-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1100px 550px at 15% -10%, rgba(99, 102, 241, .5) 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(168, 85, 247, .35) 0%, transparent 55%),
        linear-gradient(160deg, #131a35 0%, #1c2444 55%, #251b4e 100%);
}
.sp-login-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border-radius: 1.35rem;
    box-shadow: 0 2.5rem 5rem rgba(0, 0, 0, .4);
    overflow: hidden;
}
.sp-login-head { text-align: center; padding: 2.2rem 2rem 0; }
.sp-login-mark {
    width: 3.6rem;
    height: 3.6rem;
    margin: 0 auto 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.1rem;
    background: linear-gradient(135deg, var(--sp-accent), #a855f7);
    color: #fff;
    font-size: 1.7rem;
    box-shadow: 0 .8rem 1.6rem rgba(99, 102, 241, .45);
}
.sp-login-title { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; margin-bottom: .25rem; }
.sp-login-sub { color: var(--sp-muted); font-size: .85rem; margin-bottom: 0; }
.sp-login-body { padding: 1.75rem 2rem 2.25rem; }
.sp-login-body .form-control { padding: .7rem .95rem; border-radius: .8rem; }
.sp-login-body .btn-primary { padding: .7rem; border-radius: .8rem; font-size: 1rem; }
.sp-login-foot {
    text-align: center;
    color: rgba(255, 255, 255, .65);
    font-size: .78rem;
    margin-top: 1.25rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 991.98px) {
    .sp-main { margin-left: 0; }
    .sp-content { padding: 1rem .9rem; }
    .sp-topbar { padding: .6rem .9rem; gap: .6rem; }
    .sp-page-title { font-size: 1.05rem; }
    .sp-stat { min-height: 6.75rem; padding: 1rem 1.1rem; }
    .sp-stat-value { font-size: 1.3rem; }
    .sp-stat-icon { font-size: 2rem; }
    .sp-user-name { display: none; }
}

@media (min-width: 992px) {
    .sp-offcanvas { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Version tag at the bottom of the sidebar */
.sp-version {
    margin-top: auto;
    padding: 0.75rem 1.25rem;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.4);
}
