/* ── Chat Module ─────────────────────────────────────────────────────────
   Admin side uses: .wlsm-chat-wrap (flexbox, fills content area)
   Student side uses: .wlsm-st-chat-wrap (inside .wlsm-content-area)
   Both share the sidebar, panel, bubble, and input-bar rules.
   ───────────────────────────────────────────────────────────────────── */

/* ── 1. Admin chat wrap ─────────────────────────────────────────────── */
.wlsm-chat-wrap {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 520px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    margin-top: 1.4rem;
    margin-bottom: 2rem;
}

/* ── 2. Student chat wrap (inside .wlsm-registration-section-content) ─ */
.wlsm-st-chat-wrap {
    display: flex;
    height: 550px;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

/* ── 3. Shared: Sidebar ─────────────────────────────────────────────── */
.wlsm-chat-sidebar-col {
    width: 260px;
    min-width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    background: #f8f9fa;
}

/* Admin sidebar header uses --primary (#007bff).
   Student sidebar header uses --color-gray-800 / nav-primary (#525252). */
.wlsm-chat-sidebar-header {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background-color: #007bff; /* admin default; student overrides below */
}

.wlsm-st-chat-wrap .wlsm-chat-sidebar-col {
    background: #fff;
    border-right: 1px solid #eaeaea;
}

.wlsm-st-chat-wrap .wlsm-chat-sidebar-header {
    background-color: #fff;
    color: #333;
    border-bottom: 1px solid #eaeaea;
}

.wlsm-st-chat-wrap .wlsm-chat-search-bar {
    background: #fff !important;
    border-bottom: 1px solid #eaeaea !important;
    padding: 10px 15px !important;
}

.wlsm-st-chat-wrap #wlsm-chat-search {
    border-radius: 20px;
    border: 1px solid #e0e0e0;
    background: #f9f9f9;
    padding: 0.3rem 1rem;
    box-shadow: none;
}
.wlsm-st-chat-wrap #wlsm-chat-search:focus {
    background: #fff;
    border-color: #cbd5e1;
}

.wlsm-chat-sidebar-header .btn {
    padding: 0.18rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-color: rgba(255,255,255,0.55);
    color: #fff;
    line-height: 1.4;
}
.wlsm-chat-sidebar-header .btn:hover {
    background: rgba(255,255,255,0.18);
}

#wlsm-conversations-list {
    flex: 1;
    overflow-y: auto;
}
#wlsm-conversations-list::-webkit-scrollbar { width: 5px; }
#wlsm-conversations-list::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 3px; }

.wlsm-conversation-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}
.wlsm-conversation-item:hover { background: #f8f9fa; }
.wlsm-conversation-item.active {
    background: #e7f1ff;
    border-left-color: #007bff;
}
.wlsm-st-chat-wrap .wlsm-conversation-item.active {
    background: #f8fafc;
    border-left-color: #475569;
}
.wlsm-conv-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 2px;
}
.wlsm-conv-preview {
    font-size: 0.76rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wlsm-chat-unread-badge {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 5px;
    vertical-align: middle;
}

/* ── 4. Shared: Main column ─────────────────────────────────────────── */
.wlsm-chat-main-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.wlsm-chat-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}
.wlsm-chat-panel.wlsm-panel-active { display: flex; }

/* Empty state */
#wlsm-chat-empty-state {
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6c757d;
    background: #f8f9fa;
}
#wlsm-chat-empty-state .dashicons {
    font-size: 54px;
    width: 54px;
    height: 54px;
    color: #ced4da;
    margin-bottom: 0.75rem;
}
#wlsm-chat-empty-state p { margin: 0; font-size: 0.9rem; color: #6c757d; }

/* Chat window header */
.wlsm-chat-win-header {
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #eaeaea;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
}

/* Messages area */
#wlsm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
}
#wlsm-chat-messages::-webkit-scrollbar { width: 5px; }
#wlsm-chat-messages::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 3px; }

.wlsm-msg-row { display: flex; flex-direction: column; }
.wlsm-msg-row.wlsm-sent  { align-items: flex-end; }
.wlsm-msg-row.wlsm-received { align-items: flex-start; }

.wlsm-msg-sender {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 2px;
    padding: 0 4px;
}

.wlsm-message-bubble {
    max-width: 70%;
    padding: 0.6rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.wlsm-msg-row.wlsm-sent .wlsm-message-bubble {
    background: #007bff;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.wlsm-st-chat-wrap .wlsm-msg-row.wlsm-sent .wlsm-message-bubble {
    background: #475569; /* sleek slate grey */
    color: #fff;
}
.wlsm-msg-row.wlsm-received .wlsm-message-bubble {
    background: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.wlsm-msg-time {
    font-size: 0.67rem;
    color: #adb5bd;
    margin-top: 2px;
    padding: 0 4px;
}

/* Input bar */
.wlsm-chat-input-bar {
    padding: 0.75rem 1rem;
    border-top: 1px solid #eaeaea;
    background: #fff;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
#wlsm-chat-input {
    flex: 1;
    resize: none;
    border-radius: 20px;
    min-height: 40px;
    max-height: 120px;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    box-shadow: none;
    transition: border-color 0.2s, background 0.2s;
}
#wlsm-chat-input:focus {
    background: #fff;
    border-color: #cbd5e1;
    outline: none;
}
#wlsm-send-btn {
    height: 40px;
    padding: 0 16px;
    font-size: 0.9rem;
    flex-shrink: 0;
    white-space: nowrap;
    border-radius: 20px;
    font-weight: 600;
}
.wlsm-st-chat-wrap #wlsm-send-btn {
    background-color: #475569;
    color: #fff;
    transition: background 0.2s;
}
.wlsm-st-chat-wrap #wlsm-send-btn:hover {
    background-color: #334155;
}

/* New chat form panel */
#wlsm-new-chat-form-container {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    background: #fff;
}

/* Responsive */
@media (max-width: 767px) {
    .wlsm-chat-wrap,
    .wlsm-st-chat-wrap {
        flex-direction: column;
        height: auto;
        min-height: unset;
    }
    .wlsm-chat-sidebar-col {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.08);
        max-height: 220px;
    }
}
