/* ===========================================================================
   NextGen Trading Academy — Student Portal
   ---------------------------------------------------------------------------
   Everything lives in this file on purpose. The student realm enforces
       style-src 'self'
   with NO 'unsafe-inline', so an inline <style> block or a style="" attribute
   in the markup is silently dropped by the browser. Utility classes at the
   bottom exist so templates never need one.
   =========================================================================== */

:root {
    --ng-ink:      #101828;
    --ng-body:     #344054;
    --ng-muted:    #667085;
    --ng-faint:    #98a2b3;

    --ng-line:     #e4e7ec;
    --ng-line-2:   #d0d5dd;
    --ng-surface:  #ffffff;
    --ng-bg:       #f6f8fb;

    --ng-accent:       #0b5cab;
    --ng-accent-dark:  #084a8c;
    --ng-accent-soft:  #e8f1fb;

    --ng-success: #12b76a;
    --ng-danger:  #f04438;
    --ng-warning: #f79009;
    --ng-info:    #2e90fa;

    --ng-side-bg:     #0f1b2d;
    --ng-side-ink:    #c7d2e0;
    --ng-side-muted:  #7c8ba1;
    --ng-side-active: rgba(46, 144, 250, .16);

    --sp-side-w:   258px;
    --sp-top-h:    64px;
    --sp-radius:   10px;
    --sp-radius-sm: 7px;
    --sp-shadow:   0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --sp-shadow-lg: 0 20px 48px rgba(16, 24, 40, .22);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--ng-bg);
    color: var(--ng-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--ng-accent); }

/* ===========================================================================
   1. Shell — sidebar + topbar + content
   =========================================================================== */

.sp-shell { display: flex; min-height: 100vh; }

/* ---- sidebar ---------------------------------------------------------- */
.sp-sidebar {
    width: var(--sp-side-w); flex: 0 0 var(--sp-side-w);
    background: var(--ng-side-bg); color: var(--ng-side-ink);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}

.sp-sidebar-brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.05rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sp-sidebar-mark {
    width: 2.1rem; height: 2.1rem; border-radius: 8px; flex: 0 0 auto;
    background: var(--ng-accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .82rem; letter-spacing: .5px;
}
.sp-sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sp-sidebar-brand-text strong { color: #fff; font-size: .95rem; }
.sp-sidebar-brand-text small { color: var(--ng-side-muted); font-size: .72rem; }

.sp-nav { flex: 1 1 auto; overflow-y: auto; padding: .75rem .6rem; }
.sp-nav ul { list-style: none; margin: 0; padding: 0; }
.sp-nav li + li { margin-top: .15rem; }

.sp-nav-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .7rem; border-radius: var(--sp-radius-sm);
    color: var(--ng-side-ink); text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.sp-nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sp-nav-link.is-active { background: var(--ng-side-active); color: #fff; }
.sp-nav-link.is-active .sp-nav-icon { color: #fff; }

.sp-nav-icon {
    width: 1.5rem; flex: 0 0 auto; text-align: center;
    font-size: .95rem; color: var(--ng-side-muted);
}
.sp-nav-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.sp-nav-label { font-size: .88rem; font-weight: 500; }
.sp-nav-desc  { font-size: .7rem; color: var(--ng-side-muted); }
.sp-nav-link.is-active .sp-nav-desc { color: rgba(255, 255, 255, .6); }

.sp-nav-badge {
    flex: 0 0 auto; min-width: 1.25rem; padding: 0 .35rem;
    border-radius: 999px; background: var(--ng-danger); color: #fff;
    font-size: .68rem; font-weight: 700; line-height: 1.25rem; text-align: center;
}

.sp-sidebar-foot { padding: .6rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.sp-nav-link--muted { color: var(--ng-side-muted); }

/* ---- main column ------------------------------------------------------ */
.sp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.sp-topbar {
    height: var(--sp-top-h);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.25rem;
    background: var(--ng-surface); border-bottom: 1px solid var(--ng-line);
    position: sticky; top: 0; z-index: 20;
}
.sp-topbar-title { flex: 1 1 auto; min-width: 0; }
.sp-topbar-title h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.sp-topbar-title p  { margin: 0; font-size: .78rem; color: var(--ng-muted); }

.sp-topbar-user { display: flex; align-items: center; gap: .7rem; }
.sp-user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.sp-user-name { font-size: .82rem; font-weight: 600; }
.sp-user-id {
    font-size: .7rem; color: var(--ng-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.sp-user-avatar {
    width: 2.1rem; height: 2.1rem; border-radius: 50%; flex: 0 0 auto;
    background: var(--ng-accent-soft); color: var(--ng-accent-dark);
    border: 1px solid #cfe0f5;
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700;
}
.sp-signout {
    border: 1px solid var(--ng-line-2); background: var(--ng-surface);
    color: var(--ng-body); border-radius: var(--sp-radius-sm);
    padding: .35rem .7rem; font-size: .8rem; cursor: pointer;
}
.sp-signout:hover { background: #f2f4f7; color: var(--ng-ink); }

.sp-nav-toggle {
    display: none; flex-direction: column; gap: 4px;
    width: 2.2rem; height: 2.2rem; padding: .45rem;
    background: none; border: 1px solid var(--ng-line-2);
    border-radius: var(--sp-radius-sm); cursor: pointer;
}
.sp-nav-toggle span { display: block; height: 2px; background: var(--ng-body); border-radius: 2px; }

.sp-content { flex: 1 1 auto; padding: 1.5rem 1.25rem; max-width: 1280px; width: 100%; }

.sp-scrim {
    display: none; position: fixed; inset: 0; z-index: 30;
    background: rgba(16, 24, 40, .45);
}

/* ---- plain (sign-in) layout ------------------------------------------- */
.sp-plain-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.sp-plain-main {
    flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
    padding: 2.5rem 1rem;
}
.sp-plain-main > * { width: 100%; max-width: 26rem; }

/* ===========================================================================
   2. Footer
   =========================================================================== */

.sp-footer { margin-top: auto; background: var(--ng-surface); border-top: 1px solid var(--ng-line); }
.sp-footer-inner {
    max-width: 1280px; padding: 1.5rem 1.25rem 1.1rem;
    display: grid; gap: .75rem;
}
.sp-footer-brand { display: flex; flex-direction: column; line-height: 1.3; }
.sp-footer-brand strong { font-size: .92rem; }
.sp-footer-brand span   { font-size: .78rem; color: var(--ng-muted); }

.sp-footer-links { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; }
.sp-footer-links a { font-size: .82rem; text-decoration: none; color: var(--ng-body); }
.sp-footer-links a:hover { color: var(--ng-accent); text-decoration: underline; }

.sp-footer-note { margin: 0; font-size: .78rem; color: var(--ng-muted); max-width: 46rem; }

.sp-footer-bar {
    border-top: 1px solid var(--ng-line);
    padding: .8rem 1.25rem;
    display: flex; flex-wrap: wrap; gap: .4rem 1rem;
    justify-content: space-between; align-items: center;
    font-size: .78rem; color: var(--ng-muted);
}
.sp-credit a { color: var(--ng-accent); font-weight: 600; text-decoration: none; }
.sp-credit a:hover { text-decoration: underline; }
.sp-credit-url { color: var(--ng-faint); }

/* ===========================================================================
   3. Cards and content primitives
   =========================================================================== */

.sp-card { background: var(--ng-surface); border: 1px solid var(--ng-line); border-radius: var(--sp-radius); }
.sp-card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--ng-line); }
.sp-card-title  { font-size: 1rem; font-weight: 600; margin: 0; }
.sp-card-body   { padding: 1.25rem; }
.sp-card-body.is-flush { padding: 0; }

.sp-label {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .6px;
    color: var(--ng-muted); margin-bottom: .15rem;
}
.sp-value    { font-size: .98rem; font-weight: 500; word-break: break-word; }
.sp-readonly { background: #f2f4f7 !important; }
.sp-number   { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px; }

/* ---- greeting ---------------------------------------------------------- */
.sp-hero {
    display: flex; flex-wrap: wrap; gap: 1rem;
    justify-content: space-between; align-items: flex-end;
    background: var(--ng-surface); border: 1px solid var(--ng-line);
    border-radius: var(--sp-radius); padding: 1.25rem 1.4rem;
}
.sp-hero-eyebrow {
    margin: 0 0 .15rem; font-size: .72rem; letter-spacing: .8px;
    text-transform: uppercase; color: var(--ng-muted);
}
.sp-hero-title { margin: 0 0 .2rem; font-size: 1.3rem; font-weight: 600; }
.sp-hero-sub   { margin: 0; font-size: .9rem; color: var(--ng-muted); }
.sp-hero-id    { text-align: right; }

/* ---- stat strip -------------------------------------------------------- */
.sp-stat {
    background: var(--ng-surface); border: 1px solid var(--ng-line);
    border-radius: var(--sp-radius); padding: .9rem 1rem; height: 100%;
}
.sp-stat-label {
    font-size: .7rem; letter-spacing: .6px; text-transform: uppercase;
    color: var(--ng-muted); margin-bottom: .3rem;
}
.sp-stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.sp-stat-value--sm { font-size: .95rem; font-weight: 500; }

/* ---- enrolment card ---------------------------------------------------- */
.sp-enrol { border: 1px solid var(--ng-line); border-radius: 9px; padding: 1rem 1.1rem; }
.sp-enrol + .sp-enrol { margin-top: .85rem; }
.sp-enrol-head {
    display: flex; flex-wrap: wrap; gap: .5rem;
    align-items: center; justify-content: space-between; margin-bottom: .75rem;
}
.sp-enrol-title { margin: 0; font-size: 1rem; font-weight: 600; }
.sp-enrol-meta {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: .75rem; margin: 0;
}
.sp-enrol-meta dt {
    font-size: .7rem; letter-spacing: .5px; text-transform: uppercase;
    color: var(--ng-muted); font-weight: 400; margin-bottom: .1rem;
}
.sp-enrol-meta dd { margin: 0; font-size: .92rem; font-weight: 500; }
.sp-enrol-link {
    display: inline-block; margin-top: .8rem;
    font-size: .85rem; font-weight: 500; color: var(--ng-accent); text-decoration: none;
}
.sp-enrol-link:hover { text-decoration: underline; }

.sp-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- activity feed ----------------------------------------------------- */
.sp-activity { list-style: none; margin: 0; padding: 0; }
.sp-activity li {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem 1.25rem; border-top: 1px solid var(--ng-line); font-size: .88rem;
}
.sp-activity li:first-child { border-top: 0; }
.sp-activity-label { flex: 1 1 auto; }
.sp-activity-time  { color: var(--ng-muted); font-size: .78rem; white-space: nowrap; }
.sp-dot { width: .5rem; height: .5rem; border-radius: 50%; flex: 0 0 auto; background: var(--ng-faint); }
.sp-dot--success   { background: var(--ng-success); }
.sp-dot--danger    { background: var(--ng-danger); }
.sp-dot--info      { background: var(--ng-info); }
.sp-dot--warning   { background: var(--ng-warning); }
.sp-dot--secondary { background: var(--ng-faint); }

.sp-badge-count {
    display: inline-block; min-width: 1.15rem; padding: 0 .35rem;
    border-radius: 999px; background: var(--ng-danger); color: #fff;
    font-size: .68rem; line-height: 1.15rem; text-align: center; font-weight: 600;
}

/* ---- message thread ---------------------------------------------------- */
.sp-thread-scroll { max-height: 28rem; overflow-y: auto; padding: 1rem 1.25rem; }
.sp-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.sp-msg { max-width: 88%; border-radius: var(--sp-radius); padding: .7rem .9rem; border: 1px solid var(--ng-line); }
.sp-msg--them { align-self: flex-start; background: #f2f4f7; }
.sp-msg--mine { align-self: flex-end;   background: var(--ng-accent-soft); border-color: #cfe0f5; }
.sp-msg-meta {
    display: flex; gap: .6rem; align-items: baseline;
    justify-content: space-between; margin-bottom: .3rem;
}
.sp-msg-who  { font-size: .78rem; font-weight: 600; }
.sp-msg-time { font-size: .72rem; color: var(--ng-muted); white-space: nowrap; }
.sp-msg-body { font-size: .92rem; line-height: 1.5; word-break: break-word; }
.sp-count-warn { color: var(--ng-danger); font-weight: 600; }

/* ===========================================================================
   4. Dialogs and toasts  (the SweetAlert-style layer)
   =========================================================================== */

body.sp-modal-open { overflow: hidden; }

.sp-modal {
    position: fixed; inset: 0; z-index: 1080;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: rgba(16, 24, 40, .55);
    opacity: 0; transition: opacity .18s ease;
}
.sp-modal.is-open { opacity: 1; }

.sp-modal-box {
    width: 100%; max-width: 24rem;
    background: var(--ng-surface); border-radius: 14px;
    box-shadow: var(--sp-shadow-lg);
    padding: 1.6rem 1.5rem 1.35rem;
    text-align: center;
    transform: translateY(10px) scale(.97);
    transition: transform .18s cubic-bezier(.2, .8, .3, 1);
}
.sp-modal.is-open .sp-modal-box { transform: translateY(0) scale(1); }

.sp-modal-icon {
    width: 3.6rem; height: 3.6rem; margin: 0 auto .9rem;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem; font-weight: 700; line-height: 1;
    border: 3px solid currentColor;
}
.sp-modal--success .sp-modal-icon { color: var(--ng-success); background: #ecfdf3; }
.sp-modal--error   .sp-modal-icon { color: var(--ng-danger);  background: #fef3f2; }
.sp-modal--warning .sp-modal-icon { color: var(--ng-warning); background: #fffaeb; }
.sp-modal--info    .sp-modal-icon { color: var(--ng-info);    background: #eff8ff; }

.sp-modal-title { margin: 0 0 .35rem; font-size: 1.12rem; font-weight: 600; }
.sp-modal-text  { margin: 0 0 1.25rem; font-size: .92rem; color: var(--ng-body); line-height: 1.55; }

.sp-modal-btn {
    min-width: 6.5rem; padding: .5rem 1.1rem; margin: 0 .2rem;
    border: 0; border-radius: var(--sp-radius-sm);
    background: var(--ng-accent); color: #fff;
    font-size: .9rem; font-weight: 500; cursor: pointer;
}
.sp-modal-btn:hover { background: var(--ng-accent-dark); }
.sp-modal-btn--danger { background: var(--ng-danger); }
.sp-modal-btn--danger:hover { background: #b42318; }

/* ---- toasts ------------------------------------------------------------ */
.sp-toasts {
    position: fixed; z-index: 1090; right: 1rem; bottom: 1rem;
    display: flex; flex-direction: column; gap: .5rem; max-width: 22rem;
}
.sp-toast {
    display: flex; align-items: flex-start; gap: .6rem;
    background: var(--ng-surface); border: 1px solid var(--ng-line);
    border-left: 4px solid var(--ng-faint);
    border-radius: var(--sp-radius-sm); box-shadow: var(--sp-shadow);
    padding: .7rem .9rem; font-size: .88rem;
    opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.sp-toast.is-open { opacity: 1; transform: translateY(0); }
.sp-toast-icon { font-weight: 700; line-height: 1.4; }
.sp-toast--success { border-left-color: var(--ng-success); }
.sp-toast--success .sp-toast-icon { color: var(--ng-success); }
.sp-toast--error   { border-left-color: var(--ng-danger); }
.sp-toast--error   .sp-toast-icon { color: var(--ng-danger); }
.sp-toast--warning { border-left-color: var(--ng-warning); }
.sp-toast--warning .sp-toast-icon { color: var(--ng-warning); }
.sp-toast--info    { border-left-color: var(--ng-info); }
.sp-toast--info    .sp-toast-icon { color: var(--ng-info); }

/* ===========================================================================
   5. Utilities — replacements for style="" attributes, which the strict CSP
      would silently drop.
   =========================================================================== */

.sp-fs-xs { font-size: .75rem; }
.sp-fs-sm { font-size: .78rem; }
.sp-fs-md { font-size: .82rem; }
.sp-fs-lg { font-size: .9rem; }
.sp-fs-xl { font-size: .92rem; }

/* ===========================================================================
   6. Responsive
   =========================================================================== */

@media (max-width: 991.98px) {
    .sp-sidebar {
        position: fixed; top: 0; left: 0; z-index: 40;
        transform: translateX(-100%); transition: transform .22s ease;
    }
    .sp-sidebar.is-open { transform: translateX(0); }
    .sp-scrim.is-open { display: block; }
    .sp-nav-toggle { display: flex; }
    body.sp-nav-open { overflow: hidden; }
}

@media (max-width: 767.98px) {
    .sp-user-meta { display: none; }
    .sp-topbar { padding: 0 .9rem; }
    .sp-content { padding: 1.1rem .9rem; }
    .sp-hero-id { text-align: left; }
    .sp-stat-value { font-size: 1.35rem; }
    .sp-msg { max-width: 100%; }
    .sp-footer-bar { flex-direction: column; align-items: flex-start; }
    .sp-toasts { left: 1rem; right: 1rem; max-width: none; }
}
