/* Dashboard UI design system */
:root {
    --dui-font-base: 15px;
    --dui-font-sm: 0.875rem;
    --dui-font-lg: 1.125rem;
    --dui-font-xl: 1.35rem;
    --dui-radius: 0.75rem;

    /* Theme tokens (light) */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-muted: #fafbfc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --grid-line: rgba(79, 70, 229, 0.06);
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-soft: #eef2ff;

    /* Back-compat DUI aliases */
    --dui-color-muted: var(--text-secondary);
    --dui-color-border: var(--border-color);
    --dui-color-brand: var(--brand);
}

html[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #111827;
    --bg-elevated: #1e293b;
    --bg-card: #1e293b;
    --bg-muted: #162032;
    /* Soft gray instead of near-white for less glare */
    --text-primary: #cbd5e1;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-strong: #475569;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
    --grid-line: rgba(129, 140, 248, 0.08);
    --brand: #818cf8;
    --brand-hover: #a5b4fc;
    --brand-soft: rgba(129, 140, 248, 0.15);

    --dui-color-muted: var(--text-secondary);
    --dui-color-border: var(--border-color);
    --dui-color-brand: var(--brand);
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

body.rtl {
    font-size: var(--dui-font-base);
}

.main-content h1 { font-size: 1.5rem; font-weight: 800; }
.main-content h2 { font-size: 1.25rem; font-weight: 700; }
.main-content h3 { font-size: 1.1rem; font-weight: 700; }
.main-content h4, .main-content h5 { font-size: 1rem; font-weight: 700; }

.table.mTable td,
.table.mTable th {
    padding: 0.65rem 0.85rem !important;
    font-size: var(--dui-font-base);
}

/* Filter bar */
.dui-filter-bar {
    padding: 1rem;
    border-bottom: 1px solid var(--dui-color-border);
    background: #fafbfc;
}
.dui-filter-bar .form-label {
    font-size: var(--dui-font-sm);
    font-weight: 600;
    color: var(--dui-color-muted);
    margin-bottom: 0.25rem;
}

/* Table action icons */
.dui-table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.dui-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    font-size: 0.95rem;
    line-height: 1;
    transition: background-color .15s, border-color .15s, color .15s;
}
.dui-action-btn:hover { opacity: 0.92; }
.dui-action-btn--edit { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.dui-action-btn--view { background: #e0e7ff; color: #4338ca; border-color: #c7d2fe; }
.dui-action-btn--delete { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.dui-action-btn--chat { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.dui-action-btn--custom { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

/* Empty / loading states */
.dui-empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--dui-color-muted);
}
.dui-empty-state i {
    font-size: 2.5rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 0.75rem;
}
.dui-empty-state h6 {
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.35rem;
}
.dui-loading-row td {
    padding: 2rem !important;
    text-align: center;
    color: var(--dui-color-muted);
}

/* Status chips */
.dui-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}
.dui-chip--paid { background: #dcfce7; color: #166534; }
.dui-chip--partial { background: #fef3c7; color: #92400e; }
.dui-chip--overdue { background: #fee2e2; color: #991b1b; }
.dui-chip--pending { background: #e0e7ff; color: #3730a3; }

/* Sidebar — main links (with icon) */
#sidenav-main .dui-nav-main-link {
    display: flex !important;
    align-items: center !important;
    gap: 0.875rem !important;
    padding: 0.75rem 0.875rem !important;
    border-radius: 0.85rem !important;
    font-size: 0.98rem !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    text-decoration: none !important;
}
#sidenav-main .dui-nav-main-link .nav-link-text {
    font-weight: 500 !important;
}
#sidenav-main .dui-nav-main-link:hover {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
#sidenav-main .dui-nav-main-link.is-active {
    background: #4f46e5 !important;
    color: #fff !important;
}
#sidenav-main .dui-nav-main-link .nav-icon {
    width: 2.5rem !important;
    height: 2.5rem !important;
    min-width: 2.5rem !important;
    font-size: 1.15rem !important;
}

/* Sidebar — collapsible section headers (big + icon) */
.dui-nav-section { margin-bottom: 0.35rem; }
#sidenav-main .dui-nav-section-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding: 0.75rem 0.875rem !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0.85rem !important;
    font-size: 0.98rem !important;
    font-weight: 500 !important;
    color: #334155 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    cursor: pointer !important;
    transition: background-color .15s, color .15s !important;
}
#sidenav-main .dui-nav-section-toggle .dui-nav-section-label {
    font-weight: 500 !important;
}
.dui-nav-section-toggle:hover { background: var(--bg-secondary); color: var(--text-primary); }
#sidenav-main .dui-nav-section.has-active .dui-nav-section-toggle {
    background: var(--brand-soft) !important;
    color: var(--brand) !important;
}
#sidenav-main .dui-nav-section.has-active .dui-nav-section-toggle .dui-nav-section-label {
    font-weight: 700 !important;
}
#sidenav-main .dui-nav-section.has-active .dui-nav-section-toggle .nav-icon {
    background: #4f46e5 !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(79, 70, 229, .3);
}
#sidenav-main .dui-nav-section.has-active .dui-nav-section-toggle i.chevron {
    color: #818cf8 !important;
}
.dui-nav-section-head {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}
.dui-nav-section-label {
    text-align: start;
    line-height: 1.35;
}
.dui-nav-section-toggle .nav-icon {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    font-size: 1.15rem;
}
.dui-nav-section-toggle i.chevron {
    transition: transform .2s;
    font-size: 0.75rem;
    color: #94a3b8;
    flex-shrink: 0;
}
.dui-nav-section.is-open .dui-nav-section-toggle i.chevron { transform: rotate(-90deg); }

/* Sidebar — nested items (no icon) */
.dui-nav-section-items {
    display: none;
    padding: 0.25rem 0.5rem 0.35rem 0;
    margin-right: 1.25rem;
    border-right: 2px solid #e2e8f0;
}
.dui-nav-section.is-open .dui-nav-section-items { display: block; }
#sidenav-main .dui-nav-section.has-active .dui-nav-section-items { border-right-color: #c7d2fe; }
#sidenav-main .dui-nav-sub-link {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.6rem !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
}
#sidenav-main .dui-nav-sub-link:hover {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
#sidenav-main .dui-nav-sub-link.is-active {
    background: #4f46e5 !important;
    color: #fff !important;
    font-weight: 600 !important;
}
#sidenav-main .dui-nav-sub-link.is-active .dui-nav-sub-arrow {
    display: none !important;
}
.dui-nav-sub-text {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}
.dui-nav-sub-arrow {
    font-size: 1.1rem;
    line-height: 1;
    color: #94a3b8;
    flex-shrink: 0;
}
#sidenav-main .dui-nav-sub-link:hover .dui-nav-sub-arrow { color: #64748b; }
#sidenav-main .dui-nav-sub-link.is-active .dui-nav-sub-arrow { color: rgba(255, 255, 255, .85); }
.dui-nav-sub-badge {
    min-width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #ef4444;
}

#sidenav-main .sidebar-brand-name {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Shortcut cards on dashboard */
.dui-shortcut-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.15rem;
    border-radius: 1rem;
    border: 1px solid var(--dui-color-border);
    background: var(--bg-card);
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s;
}
.dui-shortcut-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
    color: inherit;
}

/* Chats layout */
.dui-chats-wrap {
    display: grid;
    grid-template-columns: minmax(300px, 360px) 1fr;
    gap: 0;
    height: calc(100vh - 220px);
    min-height: 480px;
    max-height: calc(100vh - 180px);
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 24px rgba(15, 23, 42, .06);
}
.dui-chats-list {
    border-left: 1px solid #e2e8f0;
    overflow: hidden;
    background: #fafbfc;
}
.dui-chats-thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #fff;
}
.dui-chats-messages {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 0;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
    padding-block: 0.65rem;
    padding-inline: 0.4rem 0.65rem;
    background:
        linear-gradient(180deg, #f8fafc 0%, #fff 120px),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%234f46e5' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.dui-chats-messages::-webkit-scrollbar {
    width: 8px;
}
.dui-chats-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 999px;
}
.dui-chats-messages::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 999px;
}
.dui-chats-messages::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}
#messages-list {
    direction: rtl;
}
.dui-msg-unread-sep {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.85rem 0 1rem;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 700;
}
.dui-msg-unread-sep::before,
.dui-msg-unread-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #fecaca;
}
.dui-msg-unread-sep span {
    white-space: nowrap;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
}
.dui-chats-composer {
    border-top: 1px solid #e2e8f0;
    padding: 0.85rem 1rem 1rem;
    background: #fff;
    position: sticky;
    bottom: 0;
}
.dui-composer-form { margin: 0; }
.dui-composer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.35rem 0.35rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    transition: border-color .15s, box-shadow .15s;
}
.dui-composer:focus-within {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
    background: #fff;
}
.dui-composer-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.925rem;
    color: #1e293b;
    min-width: 0;
    padding: 0.5rem 0;
}
.dui-composer-input::placeholder { color: #94a3b8; }
.dui-composer-btn {
    width: 2.35rem;
    height: 2.35rem;
    min-width: 2.35rem;
    border: none;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: transform .12s, background .12s;
}
.dui-composer-btn:hover { transform: scale(1.05); }
.dui-composer-btn--mic {
    background: transparent;
    color: #64748b;
}
.dui-composer-btn--mic:hover { background: #fee2e2; color: #dc2626; }
.dui-composer-btn--mic.is-recording {
    background: #ef4444;
    color: #fff;
    animation: chat-mic-pulse 1s ease-in-out infinite;
}
@keyframes chat-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .4); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}
.dui-composer-btn--send {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .3);
}
.dui-composer-btn--send:hover { background: #4338ca; }
.dui-composer-hint {
    font-size: 0.78rem;
    color: #64748b;
    padding: 0.35rem 0.75rem 0;
}
.dui-composer-error {
    font-size: 0.78rem;
    color: #dc2626;
    padding: 0.25rem 0.75rem 0;
}

/* Messages */
.dui-chat-no-msgs {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.dui-chat-no-msgs i { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; opacity: 0.5; }
.dui-msg-date {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}
.dui-msg-date span {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.dui-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
    width: fit-content;
    max-width: min(420px, 88%);
}
.dui-msg-row--in {
    flex-direction: row;
    margin-inline-end: auto;
    margin-inline-start: 0;
}
.dui-msg-row--out {
    flex-direction: row-reverse;
    margin-inline-start: auto;
    margin-inline-end: 0;
}
.dui-msg-avatar {
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.72rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}
.dui-msg-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1 1 auto;
}
.dui-msg-row--in .dui-msg-content { align-items: flex-start; }
.dui-msg-row--out .dui-msg-content { align-items: flex-end; }
.dui-msg-meta {
    display: inline-flex;
    align-items: center;
    flex-direction: row;
    gap: 0.35rem;
    padding: 0 0.1rem;
    line-height: 1.3;
    text-align: right;
}
.dui-msg-meta-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
}
.dui-msg-meta-role {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}
.dui-msg-meta-role.dui-chat-type--admin { background: #eef2ff; color: #4338ca; }
.dui-msg-meta-role.dui-chat-type--parent { background: #ccfbf1; color: #0f766e; }
.dui-msg-meta-role.dui-chat-type--student { background: #eef2ff; color: #4338ca; }
.dui-msg-meta-role.dui-chat-type--teacher { background: #ffedd5; color: #c2410c; }
.dui-msg-bubble {
    display: flex;
    flex-direction: column;
    direction: rtl;
    text-align: right;
    width: fit-content;
    max-width: 100%;
    padding: 0.45rem 0.7rem;
    border-radius: 0.85rem;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.dui-msg-bubble--out {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    border-bottom-left-radius: 0.25rem;
}
.dui-msg-bubble--in {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-right-radius: 0.25rem;
}
.dui-msg-bubble--audio {
    padding: 0.4rem 0.55rem 0.35rem;
    gap: 0.2rem;
}
.dui-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.925rem;
    line-height: 1.5;
    width: 100%;
}
.dui-msg-foot {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.15rem;
}
.dui-msg-bubble:not(.dui-msg-bubble--audio) .dui-msg-foot {
    margin-top: 0.05rem;
}
.dui-msg-time {
    font-size: 0.68rem;
    opacity: 0.7;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
}
.dui-msg-delete {
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.45;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    font-size: 0.72rem;
    transition: opacity .12s, color .12s, transform .12s;
}
.dui-msg-delete:hover {
    opacity: 1;
    color: #dc2626;
    transform: scale(1.08);
}
.dui-msg-bubble--out .dui-msg-delete:hover {
    color: #fecaca;
}
.dui-chat-type--admin { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.dui-chat-type--parent { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.dui-chat-type--student { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.dui-chat-type--teacher { background: linear-gradient(135deg, #ea580c, #f97316); }

/* Chat audio — wave player */
.chat-audio-player {
    display: flex;
    align-items: center;
    flex-direction: row;
    direction: rtl;
    gap: 0.4rem;
    min-width: 10rem;
    max-width: 15rem;
    width: 100%;
}
.chat-audio-play {
    width: 1.85rem;
    height: 1.85rem;
    min-width: 1.85rem;
    border: none;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: transform .15s, opacity .15s;
    flex-shrink: 0;
}
.chat-audio-play:hover { transform: scale(1.05); }
.chat-audio-play:disabled { opacity: 0.6; cursor: wait; }
.chat-audio-player--out .chat-audio-play {
    background: rgba(255, 255, 255, .22);
    color: #fff;
}
.chat-audio-player--in .chat-audio-play {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 4px 10px rgba(79, 70, 229, .25);
}
.chat-audio-wave-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 32px;
}
.chat-wave-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
    padding: 0 2px;
    transition: opacity .2s;
}
.chat-wave-placeholder.is-hidden {
    opacity: 0;
    pointer-events: none;
}
.chat-wave-bar {
    flex: 1;
    min-width: 2px;
    max-width: 4px;
    height: var(--bar-h, 50%);
    border-radius: 999px;
    background: currentColor;
    opacity: 0.55;
    transition: opacity .15s;
}
.chat-audio-player--out .chat-wave-placeholder { color: #fff; }
.chat-audio-player--in .chat-wave-placeholder { color: #94a3b8; }
.chat-audio-player.is-playing .chat-wave-bar { opacity: 0.85; }
.chat-wave-placeholder.has-progress .chat-wave-bar { opacity: 0.95; }
.chat-wave {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}
.chat-wave.is-ready {
    opacity: 1;
    pointer-events: auto;
}
.chat-audio-duration {
    font-size: 0.68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 2rem;
    text-align: left;
    direction: ltr;
    unicode-bidi: isolate;
    flex-shrink: 0;
}
.chat-audio-player--out .chat-audio-duration { color: rgba(255, 255, 255, .75); }
.chat-audio-player--in .chat-audio-duration { color: #64748b; }
.chat-audio-player.is-loading .chat-wave-placeholder {
    animation: chat-wave-pulse 1s ease-in-out infinite;
}
@keyframes chat-wave-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (max-width: 991px) {
    .dui-chats-wrap {
        grid-template-columns: 1fr;
        height: calc(100vh - 160px);
        min-height: 70vh;
        max-height: none;
    }
    .dui-chats-wrap.show-thread .dui-chats-list { display: none; }
    .dui-chats-wrap:not(.show-thread) .dui-chats-thread { display: none; }
}

/* Chats page — modern layout */
.dui-chats-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.dui-chats-page-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}
.dui-chats-page-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: #eef2ff;
    color: #4f46e5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}
.dui-chats-page-sub {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.9rem;
}
.dui-chats-tabs {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.25rem;
    background: #f1f5f9;
    border-radius: 999px;
}
.dui-chats-tab {
    padding: 0.45rem 1rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.dui-chats-tab:hover { color: #334155; background: #e2e8f0; }
.dui-chats-tab.is-active {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .25);
}

.dui-chats-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.dui-chats-search-wrap {
    position: relative;
    padding: 0.85rem;
    border-bottom: 1px solid var(--dui-color-border);
    background: #fafbfc;
}
.dui-chats-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    transition: border-color .15s, box-shadow .15s;
}
.dui-chats-search:focus-within {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.dui-chats-search > i { color: #94a3b8; font-size: 1rem; }
.dui-chats-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    color: #1e293b;
    min-width: 0;
}
.dui-chats-search-input::placeholder { color: #94a3b8; }
.dui-chats-search-clear {
    border: none;
    background: #f1f5f9;
    color: #64748b;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.65rem;
}
.dui-chats-role-filters {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.65rem;
    flex-wrap: wrap;
}
.dui-chats-role-btn {
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s;
}
.dui-chats-role-btn:hover { border-color: #cbd5e1; color: #334155; }
.dui-chats-role-btn.is-active {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4338ca;
}

.dui-chats-search-results {
    position: absolute;
    top: calc(100% - 0.35rem);
    right: 0.85rem;
    left: 0.85rem;
    z-index: 30;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .12);
    max-height: 320px;
    overflow-y: auto;
    padding: 0.35rem;
}
.dui-chats-search-empty {
    padding: 1rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.875rem;
}
.dui-chat-search-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border-radius: 0.65rem;
    transition: background .12s;
}
.dui-chat-search-item:hover { background: #f8fafc; }
.dui-chat-search-item-body { flex: 1; min-width: 0; }
.dui-chat-search-item-name {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
}
.dui-chat-search-item-sub {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dui-chat-search-action {
    border: none;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.dui-chat-search-action:hover { background: #e0e7ff; color: #3730a3; }

.dui-chats-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 0;
}

.dui-chat-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem;
    border-radius: 1rem;
    text-decoration: none;
    color: inherit;
    transition: background .12s, box-shadow .12s;
    margin-bottom: 0.35rem;
    background: #fff;
    border: 1px solid transparent;
}
.dui-chat-item:hover {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
}
.dui-chat-item.is-active {
    background: #fff;
    border-color: #c7d2fe;
    box-shadow: 0 4px 16px rgba(79, 70, 229, .12);
}
.dui-chat-avatar {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}
.dui-chat-type--parent { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.dui-chat-type--student { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.dui-chat-type--teacher { background: linear-gradient(135deg, #ea580c, #f97316); }
.dui-chat-flow {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin: 0.35rem 0 0.25rem;
    flex-wrap: wrap;
}
.dui-chat-flow > i {
    color: #cbd5e1;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.dui-chat-flow-chip {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dui-chat-flow-chip.dui-chat-type--admin { background: #eef2ff; color: #4338ca; }
.dui-chat-flow-chip.dui-chat-type--parent { background: #ccfbf1; color: #0f766e; }
.dui-chat-flow-chip.dui-chat-type--student { background: #dbeafe; color: #1d4ed8; }
.dui-chat-flow-chip.dui-chat-type--teacher { background: #ffedd5; color: #c2410c; }
.dui-chat-item-body { flex: 1; min-width: 0; }
.dui-chat-item-top,
.dui-chat-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.dui-chat-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dui-chat-item-time {
    font-size: 0.72rem;
    color: #94a3b8;
    white-space: nowrap;
}
.dui-chat-item-preview {
    font-size: 0.8rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.dui-chat-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}
.dui-chat-type-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
}
.dui-chat-type-badge.dui-chat-type--parent { background: #ccfbf1; color: #0f766e; }
.dui-chat-type-badge.dui-chat-type--student { background: #eef2ff; color: #4338ca; }
.dui-chat-type-badge.dui-chat-type--teacher { background: #ffedd5; color: #c2410c; }
.dui-chat-unread {
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dui-chats-empty-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: #64748b;
    min-height: 100%;
}
.dui-chats-empty-icon {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 1.25rem;
    background: #f1f5f9;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1rem;
}
.dui-chats-empty-pane h3 {
    margin: 0 0 0.35rem;
    color: #1e293b;
    font-size: 1.1rem;
    font-weight: 700;
}
.dui-chats-empty-pane p {
    margin: 0;
    font-size: 0.9rem;
}
.dui-chats-monitor-badge {
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 600;
}
.dui-chats-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
}
.dui-chats-back-link:hover { color: #4f46e5; }
.dui-chats-thread-head {
    padding: 1rem 1.15rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #fff, #fafbfc);
}
.dui-chats-thread-head-inner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
}
.dui-chat-context {
    flex: 1;
    min-width: 0;
}
.dui-chat-context-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.55rem;
}
.dui-chat-context-parties {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.dui-chat-context-card {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.75rem 0.45rem 0.45rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    min-width: 0;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .04);
}
.dui-chat-context-card.dui-chat-type--admin { border-color: #c7d2fe; background: #fafaff; }
.dui-chat-context-card.dui-chat-type--parent { border-color: #99f6e4; background: #f0fdfa; }
.dui-chat-context-card.dui-chat-type--student { border-color: #bfdbfe; background: #eff6ff; }
.dui-chat-context-card.dui-chat-type--teacher { border-color: #fed7aa; background: #fff7ed; }
.dui-chat-context-avatar {
    width: 2.1rem;
    height: 2.1rem;
    min-width: 2.1rem;
    border-radius: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.95rem;
}
.dui-chat-context-card.dui-chat-type--admin .dui-chat-context-avatar { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.dui-chat-context-card.dui-chat-type--parent .dui-chat-context-avatar { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.dui-chat-context-card.dui-chat-type--student .dui-chat-context-avatar { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.dui-chat-context-card.dui-chat-type--teacher .dui-chat-context-avatar { background: linear-gradient(135deg, #ea580c, #f97316); }
.dui-chat-context-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.dui-chat-context-info strong {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}
.dui-chat-context-info small {
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
}
.dui-chat-context-divider {
    color: #cbd5e1;
    font-size: 1rem;
    flex-shrink: 0;
}
.dui-chats-readonly-banner {
    padding: 0.65rem 1rem;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 1px solid #fde68a;
}

@media (max-width: 991px) {
    .dui-chats-page-head { flex-direction: column; }
    .dui-chats-tabs { width: 100%; justify-content: center; }
}
