/* Copyright (c) 2026 Student First, LLC
   All rights reserved.
   Proprietary and confidential.

   ── Student Messages Redesign (PBI 23227 / shared across Admin + Student Portal)
   Split-view inbox — toolbar + segmented filter + two-pane layout. Used by:
     - Admin Communications MessageCenter.razor   (/messages, /communications/messages)
     - Admin Student-detail StudentMessagesWrapper.razor (/students/{id}/messages)
     - Student Portal Messages.razor              (/messages)

   File also carries a few shared primitives that the inbox depends on
   (`.sf-page-title*`, `.sf-section-title`, `.sf-loader-*`, `.sf-enroll-switch__*`)
   so a single <link> on each host serves the whole feature. */
.sf-msg-page {
    padding: 16px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1680px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Toolbar */
.sf-msg-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.sf-msg-toolbar__title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
/* sf-page-title — canonical page-header typography. Spec sourced from
   .sf-msg-detail__subject (Messages conversation header);
   migrate other student-section page titles onto this class to align them. */
.sf-page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--sf-color-dark);
    letter-spacing: -0.3px;
    line-height: 1.25;
    margin: 0;
}

/* Modifier: page title not wrapped in a CardHeader (or other chrome that
   manages spacing). Adds bottom margin so the title isn't visually glued
   to the content below it (e.g., a TabStrip on Bank Deposits). Opt-in —
   pages where the title sits inside a Telerik CardHeader keep the bare
   .sf-page-title and get spacing from the card. */
.sf-page-title--standalone {
    margin-bottom: 1rem;
}

/* sf-subpage-title — sub-context page title typography (student-menu pages,
   detail screens within a parent context, etc.). Smaller and lighter than
   .sf-page-title because the page is already nested under a larger context
   (e.g. inside a student profile). Spec sourced from the Career Services
   Certifications page (Bootstrap .h6: 16px / 500). Apply via the StickyFormLayout
   TitleClass parameter, or directly to a heading element. */
.sf-subpage-title {
    font-size: 16px ;
    font-weight: 500;
    color: var(--sf-color-dark);
    line-height: 1.2;
    margin: 0;
}

/* When .sf-page-title is rendered inside the StudentLayout wrapper (.sf-student-page),
   downgrade its typography to subpage spec. Avoids threading TitleClass parameters
   through shared components (GridSettingsComponent, etc.) just to differentiate
   main-menu from student-menu rendering — same h1 ends up looking right in both. */
.sf-student-page .sf-page-title {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0;
}

/* sf-section-title — sub-section heading typography. Use under .sf-page-title
   (e.g., headings inside a tab body). Smaller and lighter than the page title
   but the same color/family, so the visual hierarchy is unmistakable. Pair
   with the appropriate semantic level (typically <h3> when the page title
   is <h2>). margin-bottom builds in breathing room before the content the
   heading introduces — sub-sections almost always need this gap. */
.sf-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--sf-color-dark);
    letter-spacing: -0.2px;
    line-height: 1.3;
    margin: 0 0 0.75rem 0;
}

/* Keep the toolbar h2 layout reset for any callers not yet migrated to
   .sf-page-title — only retains the margin reset; typography is now owned
   by .sf-page-title. */
.sf-msg-toolbar__title h2 {
    margin: 0;
}
.sf-msg-toolbar__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f1f5f9;
    color: var(--sf-color-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}
.sf-msg-toolbar__spacer { flex: 1; min-width: 20px; }
.sf-msg-unread-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--sf-color-destructive);
    color: var(--sf-color-white);
}

.sf-msg-search {
    position: relative;
    display: flex;
    align-items: center;
}
.sf-msg-search i {
    position: absolute;
    left: 10px;
    color: var(--sf-color-accent);
    pointer-events: none;
    font-size: 12px;
}
.sf-msg-search input {
    height: 30px;
    width: 280px;
    padding: 0 10px 0 30px;
    border: 1px solid var(--sf-color-border);
    border-radius: 8px;
    font: inherit;
    font-size: 12px;
    background: #f8fafc;
    color: var(--sf-color-text);
}
.sf-msg-search input:focus {
    outline: 2px solid var(--sf-color-accent);
    outline-offset: 1px;
    background: var(--sf-color-white);
}

/* Segmented filter tabs */
.sf-msg-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 2px 0;
}
.sf-msg-segment {
    display: inline-flex;
    background: #f1f5f9;
    border: 1px solid var(--sf-color-border);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}
.sf-msg-segment button {
    height: 26px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--sf-color-accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s, color 0.12s;
}
.sf-msg-segment button:hover:not(.is-active) { color: var(--sf-color-dark); }
.sf-msg-segment button.is-active {
    background: var(--sf-color-primary);
    color: var(--sf-color-white);
    box-shadow: var(--sf-shadow-sm);
}
.sf-msg-segment button:focus-visible {
    outline: 2px solid var(--sf-color-accent);
    outline-offset: 1px;
}
.sf-msg-segment .count {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--sf-color-accent-light);
    color: var(--sf-color-dark);
}
.sf-msg-segment .is-active .count {
    background: rgba(255, 255, 255, 0.2);
    color: var(--sf-color-white);
}

/* Inline compose host — wraps the shared PostNewMessageComponent. */
.sf-msg-compose-host {
    background: var(--sf-color-white);
    border: 1px solid var(--sf-color-border);
    border-radius: 12px;
    box-shadow: var(--sf-shadow-header);
    padding: 14px 16px;
}

/* Split view */
.sf-msg-split {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
    min-height: 560px;
}
@media (max-width: 960px) {
    .sf-msg-split { grid-template-columns: 1fr; }
}

/* List pane */
.sf-msg-list-pane {
    background: var(--sf-color-white);
    border: 1px solid var(--sf-color-border);
    border-radius: 12px;
    box-shadow: var(--sf-shadow-header);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.sf-msg-list-pane__head {
    padding: 10px 14px;
    border-bottom: 1px solid #eef2f7;
    font-size: 11px;
    color: var(--sf-color-accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sf-msg-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: calc(100vh - 340px);
}
.sf-msg-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--sf-color-accent);
    font-size: 13px;
}

/* Message row — clickable button spanning a 2-row grid:
     [avatar  sender+time]
     [-       subject+preview  (count)] */
.sf-msg-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        "avatar head   count"
        "avatar body   count";
    gap: 4px 10px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    transition: background 0.12s;
    align-items: start;
}
.sf-msg-row:last-child { border-bottom: none; }
.sf-msg-row:hover { background: #f8fafc; }
.sf-msg-row:focus-visible {
    outline: 2px solid var(--sf-color-accent);
    outline-offset: -2px;
}
.sf-msg-row.is-selected { background: #f1f5f9; }
.sf-msg-row.is-unread .sf-msg-row__subject { font-weight: 700; color: var(--sf-color-dark); }
.sf-msg-row.is-unread .sf-msg-row__sender { color: var(--sf-color-dark); font-weight: 700; }

.sf-msg-row__avatar {
    grid-area: avatar;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    color: var(--sf-color-white);
    font-weight: 700;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.2px;
    flex-shrink: 0;
    position: relative;
}
.sf-msg-row__unread-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--sf-color-destructive);
    border: 2px solid var(--sf-color-white);
}

.sf-msg-row__head {
    grid-area: head;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.sf-msg-row__sender {
    font-size: 13px;
    font-weight: 500;
    color: var(--sf-color-dark);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.sf-msg-row__time {
    font-size: 11px;
    color: var(--sf-color-accent);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.sf-msg-row__body {
    grid-area: body;
    min-width: 0;
}
.sf-msg-row__subject {
    font-size: 12.5px;
    color: var(--sf-color-text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}
.sf-msg-row__preview {
    font-size: 11.5px;
    color: var(--sf-color-accent);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sf-msg-row.is-selected .sf-msg-row__preview { color: #475569; }

.sf-msg-row__thread-count {
    grid-area: count;
    align-self: start;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--sf-color-accent-light);
    color: var(--sf-color-dark);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

/* Detail pane */
.sf-msg-detail-pane {
    background: var(--sf-color-white);
    border: 1px solid var(--sf-color-border);
    border-radius: 12px;
    box-shadow: var(--sf-shadow-header);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.sf-msg-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--sf-color-accent);
}
.sf-msg-detail-empty i {
    font-size: 36px;
    color: #cbd5e1;
    margin-bottom: 14px;
}
.sf-msg-detail-empty__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--sf-color-dark);
    margin-bottom: 4px;
}
.sf-msg-detail-empty__sub {
    font-size: 12px;
    color: var(--sf-color-accent);
}

.sf-msg-detail__header {
    padding: 18px 20px 12px;
    border-bottom: 1px solid #eef2f7;
}
.sf-msg-detail__subject {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--sf-color-dark);
    letter-spacing: -0.3px;
    line-height: 1.25;
    margin-bottom: 6px;
}
.sf-msg-detail__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--sf-color-accent);
}
.sf-msg-detail__meta b { color: var(--sf-color-dark); font-weight: 700; }

.sf-msg-detail__body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 420px);
}

/* Message bubble */
.sf-msg-bubble {
    display: flex;
    gap: 10px;
    max-width: 82%;
}
.sf-msg-bubble--me { flex-direction: row-reverse; margin-left: auto; }
.sf-msg-bubble__avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    color: var(--sf-color-white);
    font-weight: 700;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sf-msg-bubble__body {
    background: var(--sf-color-white);
    border: 1px solid var(--sf-color-border);
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 0;
    box-shadow: var(--sf-shadow-sm);
}
.sf-msg-bubble--me .sf-msg-bubble__body {
    background: var(--sf-color-primary);
    color: var(--sf-color-white);
    border-color: var(--sf-color-primary);
}
.sf-msg-bubble__head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}
.sf-msg-bubble__sender {
    font-size: 12px;
    font-weight: 700;
    color: var(--sf-color-dark);
}
.sf-msg-bubble--me .sf-msg-bubble__sender { color: var(--sf-color-white); }
.sf-msg-bubble__time {
    margin-left: auto;
    font-size: 10.5px;
    color: var(--sf-color-accent);
    white-space: nowrap;
}
.sf-msg-bubble--me .sf-msg-bubble__time { color: rgba(255, 255, 255, 0.75); }
.sf-msg-bubble__content {
    font-size: 13px;
    line-height: 1.5;
    color: var(--sf-color-text);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.sf-msg-bubble--me .sf-msg-bubble__content { color: var(--sf-color-white); }

/* Inline reply composer */
.sf-msg-reply {
    padding: 14px 20px 18px;
    border-top: 1px solid #eef2f7;
    background: var(--sf-color-white);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sf-msg-reply__head {
    font-size: 11px;
    color: var(--sf-color-accent);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}
.sf-msg-reply__head b {
    color: var(--sf-color-dark);
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 4px;
}
.sf-msg-reply__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}
.sf-msg-reply__shortcut {
    margin-right: auto;
    font-size: 11px;
    color: var(--sf-color-accent);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sf-msg-reply__shortcut kbd {
    background: var(--sf-color-accent-light);
    border: 1px solid var(--sf-color-border);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: var(--sf-font-family);
    font-variant-numeric: tabular-nums;
    font-size: 10px;
    color: var(--sf-color-dark);
}

/* Admin Communications — jump-to-student-record button in detail header meta. */
.sf-msg-detail__jump {
    background: transparent;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: 11px;
    color: var(--sf-color-primary);
    font-weight: 600;
    cursor: pointer;
}
.sf-msg-detail__jump:hover { text-decoration: underline; }
.sf-msg-detail__jump:focus-visible { outline: 2px solid var(--sf-color-accent); outline-offset: 2px; }

/* Enrollment tile — list of other enrollments for this person with a
   clickable row per enrollment. Clicking navigates to /students/{id}/home
   for the chosen enrollment so the whole context (student rail, overview,
   balances, etc.) swaps to it. */
.sf-enroll-switch {
    border-top: 1px dashed var(--sf-color-border);
    margin-top: 14px;
    padding-top: 12px;
}
.sf-enroll-switch__label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--sf-color-text-muted);
    margin-bottom: 8px;
}
.sf-enroll-switch__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sf-enroll-switch__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--sf-color-surface, #ffffff);
    border: 1px solid var(--sf-color-border);
    border-radius: 8px;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}
.sf-enroll-switch__item:hover {
    border-color: var(--sf-color-accent);
    background: var(--sf-color-accent-light);
}
.sf-enroll-switch__item:focus-visible {
    outline: var(--sf-focus-inner-width) solid var(--sf-focus-ring-inner);
    outline-offset: var(--sf-focus-offset);
    box-shadow: 0 0 0 var(--sf-focus-width) var(--sf-focus-ring-outer);
}
.sf-enroll-switch__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sf-enroll-switch__program {
    font-size: 13px;
    font-weight: 600;
    color: var(--sf-color-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sf-enroll-switch__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11.5px;
    color: var(--sf-color-text-muted);
}
.sf-enroll-switch__chev {
    font-size: 11px;
    color: var(--sf-color-accent);
    flex-shrink: 0;
}

/* SF loader — replaces Telerik's Kendo-blue loader with a primary-slate
   spinning ring that matches the rest of the design system. */
.sf-loader-ring {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 3px solid var(--sf-color-accent-light);
    border-top-color: var(--sf-color-primary);
    animation: sf-loader-spin 0.9s linear infinite;
    vertical-align: middle;
}
@keyframes sf-loader-spin {
    to { transform: rotate(360deg); }
}

/* Full-page overlay loader used by StudentLayout while the viewed
   student record boots. Dark translucent scrim + centered card so the
   spinner reads against any background. */
.sf-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    animation: sf-loader-fadein 120ms ease-out both;
}
.sf-loader-card {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: var(--sf-color-surface, #ffffff);
    border: 1px solid var(--sf-color-border);
    border-radius: 12px;
    box-shadow: var(--sf-shadow-md, 0 4px 12px rgba(15, 23, 42, 0.18));
    font-size: 13px;
    font-weight: 600;
    color: var(--sf-color-dark);
}
.sf-loader-card .sf-loader-ring {
    width: 22px;
    height: 22px;
    border-width: 2.5px;
}
.sf-loader-text { letter-spacing: -0.2px; }
@keyframes sf-loader-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Message bubble — linked sender (student), per-message mark-read, and
   a subtle unread state so readers can still tell which messages haven't
   been marked read yet. */
.sf-msg-bubble__sender--link {
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    cursor: pointer;
}
.sf-msg-bubble__sender--link:hover { color: var(--sf-color-primary); }
.sf-msg-bubble--me .sf-msg-bubble__sender--link:hover { color: rgba(255,255,255,0.8); }
.sf-msg-bubble__sender--link:focus-visible {
    outline: 2px solid var(--sf-color-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.sf-msg-bubble__mark-read {
    margin-left: 8px;
    background: transparent;
    border: 1px solid var(--sf-color-border);
    border-radius: 6px;
    padding: 2px 6px;
    color: var(--sf-color-accent);
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sf-msg-bubble__mark-read:hover {
    background: var(--sf-color-accent-light);
    color: var(--sf-color-dark);
    border-color: var(--sf-color-accent);
}
.sf-msg-bubble__mark-read:focus-visible {
    outline: 2px solid var(--sf-color-accent);
    outline-offset: 1px;
}

.sf-msg-bubble.is-unread .sf-msg-bubble__body {
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.12), var(--sf-shadow-sm);
}
.sf-msg-bubble.is-unread.sf-msg-bubble--them .sf-msg-bubble__body {
    border-color: var(--sf-color-accent);
}

/* Plain <textarea> used by the message reply composer — Telerik's wrapper
   swallowed the @onkeydown event, so we go native here. Styled to match
   the surrounding tile. */
.sf-msg-reply__textarea {
    width: 100%;
    min-height: 88px;
    padding: 10px 12px;
    font-family: var(--sf-font-family);
    font-size: 13px;
    line-height: 1.5;
    color: var(--sf-color-text);
    background: var(--sf-color-surface, #ffffff);
    border: 1px solid var(--sf-color-border);
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.sf-msg-reply__textarea:focus {
    outline: none;
    border-color: var(--sf-color-accent);
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.18);
}
.sf-msg-reply__textarea::placeholder { color: var(--sf-color-accent); }
