/* College student chat tower */

.student-chat {
    --student-chat-primary: var(--ep-primary-color-1, #0037eb);
    --student-chat-accent: var(--ep-primary-color-9, #764ba2);
    --student-chat-soft: var(--ep-primary-color-6, #d6e0ff);
    --student-chat-title: var(--ep-title-color, #1f1c35);
    --student-chat-text: var(--ep-paragraph-color, #4f536c);
    --student-chat-border: var(--ep-border-color, #e7e7eb);
    font-family: var(--ep-font-family, Inter, system-ui, sans-serif);
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 8000;
    width: auto;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

.student-chat.is-open {
    width: 360px;
}

.student-chat:not(.is-open) .student-chat__panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 360px;
}

.student-chat__panel {
    position: relative;
    width: 360px;
    display: flex;
    flex-direction: column;
    height: 480px;
    max-height: calc(100vh - 48px);
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    border: none;
    box-shadow: 0 16px 48px rgba(31, 28, 53, 0.14);
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34, 1.2, 0.64, 1),
                opacity 0.3s ease,
                visibility 0.3s ease;
}

.student-chat.is-open .student-chat__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.student-chat__list-view,
.student-chat__thread {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.student-chat__list-header,
.student-chat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px 14px 16px;
    background: linear-gradient(135deg, var(--student-chat-primary) 0%, var(--student-chat-accent) 100%);
    color: #fff;
    flex-shrink: 0;
}

.student-chat__list-header > div,
.student-chat__header-info {
    min-width: 0;
    flex: 1;
}

.student-chat__list-title,
.student-chat__header-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

.student-chat__list-sub,
.student-chat__header-status {
    margin: 3px 0 0;
    font-size: 12px;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-chat__icon-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.student-chat__icon-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

.student-chat__icon-btn:hover,
.student-chat__icon-btn:focus {
    background: rgba(255, 255, 255, 0.28);
    outline: none;
}

.student-chat__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    background: #fff;
}

.student-chat__row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    border-radius: 14px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.student-chat__row:hover,
.student-chat__row:focus {
    background: #f5f6ff;
    outline: none;
}

.student-chat__row-avatar,
.student-chat__header-avatar,
.student-chat__stack-item {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--student-chat-soft);
    color: var(--student-chat-primary);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.student-chat__row-avatar img,
.student-chat__header-avatar img,
.student-chat__stack-item img,
.student-chat__header-avatar span,
.student-chat__row-avatar span {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.student-chat__header-avatar {
    width: 38px;
    height: 38px;
}

.student-chat__row-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.student-chat__row-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--student-chat-title);
}

.student-chat__row-seen {
    font-size: 12px;
    color: var(--student-chat-text);
}

.student-chat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: var(--ep-offwhite-color, #f5f5f5);
}

.student-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.student-chat__bubble {
    max-width: 86%;
    padding: 10px 14px 8px;
    background: #fff;
    border: 1px solid var(--student-chat-border);
    border-radius: 16px 16px 16px 4px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--student-chat-title);
    align-self: flex-start;
}

.student-chat__bubble--user {
    align-self: flex-end;
    border-color: var(--student-chat-soft);
    background: var(--student-chat-soft);
    border-radius: 16px 16px 4px 16px;
}

.student-chat__time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #8b8fa3;
    text-align: right;
}

.student-chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px 14px;
    background: #fff;
    border-top: 1px solid var(--student-chat-border);
}

.student-chat__input {
    flex: 1;
    min-height: 42px;
    max-height: 96px;
    height: 42px;
    resize: none;
    overflow: hidden;
    border: 1px solid var(--student-chat-border);
    border-radius: 20px;
    padding: 11px 16px;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: var(--student-chat-title);
    background: var(--ep-offwhite-color, #f5f5f5);
}

.student-chat__input:focus {
    outline: none;
    border-color: var(--student-chat-primary);
    background: #fff;
}

.student-chat__send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--student-chat-primary) 0%, var(--student-chat-accent) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.student-chat__send svg {
    width: 18px;
    height: 18px;
    display: block;
}

.student-chat.is-sending .student-chat__send,
.student-chat__send:disabled {
    opacity: 0.45;
    cursor: default;
}

.student-chat__launcher {
    align-self: flex-end;
    margin-top: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    padding: 0;
}

.student-chat.is-open .student-chat__launcher {
    display: none;
}

.student-chat__stack {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.student-chat__stack-item {
    width: 52px;
    height: 52px;
    border: 2px solid #fff;
    box-shadow: 0 8px 20px rgba(31, 28, 53, 0.18);
    margin-top: -14px;
}

.student-chat__stack-item:first-child {
    margin-top: 0;
}

@media (max-width: 991px) {
    .student-chat {
        right: max(16px, env(safe-area-inset-right, 0px));
        bottom: calc(max(24px, env(safe-area-inset-bottom, 0px)) + 56px + 12px);
    }

    .student-chat.is-open {
        width: min(360px, calc(100vw - 32px));
    }

    .student-chat__panel {
        width: min(360px, calc(100vw - 32px));
        height: min(480px, calc(100vh - 120px));
        max-height: calc(100vh - 120px);
    }
}
