/* ═══════════════════════════════════════════════════════════════
   Enterprise Messenger — Professional Dark Navy Theme
   Palette: Navy #0f172a · Blue #1d4ed8 · Slate · Clean whites
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── ROOT ─────────────────────────────────────────────────────── */
.ms-root {
    display: flex;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: #f1f5f9;
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.ms-sidebar {
    width: 290px;
    min-width: 290px;
    max-width: 290px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    display: flex;
    flex-direction: column;
    color: #fff;
    border-right: 1px solid rgba(255,255,255,0.05);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
}

/* Header */
.ms-sidebar-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.ms-sidebar-title {
    font-size: 15px;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ms-sidebar-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

/* Search */
.ms-search-wrap {
    display: flex;
    align-items: center;
    gap: 9px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 9px 13px;
    margin-top: 12px;
    transition: all 0.2s;
}
.ms-search-wrap:focus-within {
    background: rgba(255,255,255,0.11);
    border-color: rgba(99,131,255,0.5);
    box-shadow: 0 0 0 3px rgba(99,131,255,0.1);
}
.ms-search-input {
    background: none;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-size: 13px;
    font-family: inherit;
    flex: 1;
    width: 100%;
}
.ms-search-input::placeholder { color: #4b5563; }

/* Section headers */
.ms-section-hdr {
    padding: 16px 18px 5px;
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ms-section-add-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s;
}
.ms-section-add-btn:hover {
    background: rgba(99,131,255,0.2);
    color: #818cf8;
    border-color: rgba(99,131,255,0.3);
}

/* Sidebar scroll */
.ms-sidebar-scroll { flex: 1; overflow-y: auto; }
.ms-sidebar-scroll::-webkit-scrollbar { width: 4px; }
.ms-sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.ms-sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Contact / Group items */
.ms-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 18px;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 0;
    position: relative;
    border-left: 3px solid transparent;
}
.ms-item:hover {
    background: rgba(255,255,255,0.05);
}
.ms-item.active {
    background: rgba(29,78,216,0.18);
    border-left-color: #3b82f6;
}
.ms-item.active .ms-item-name { color: #93c5fd; }
.ms-item.disabled-user { opacity: 0.5; }

/* Avatars */
.ms-av-wrap { position: relative; flex-shrink: 0; }
.ms-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 100%);
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

/* Presence dots */
.ms-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #0f172a;
}
.ms-dot.online  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.ms-dot.offline { background: #374151; }
.ms-dot.disabled { background: #ef4444; }

/* Item info */
.ms-item-info { flex: 1; min-width: 0; }
.ms-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s;
}
.ms-item:hover .ms-item-name { color: #f1f5f9; }
.ms-item-sub {
    font-size: 11px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    font-weight: 500;
}
.ms-item-sub.red { color: #f87171; }

/* Item right side */
.ms-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.ms-item-time { font-size: 10px; color: #374151; font-weight: 500; }
.ms-badge {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 10px;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 0 8px rgba(239,68,68,0.4);
}

/* Footer */
.ms-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   CHAT AREA
══════════════════════════════════════════════════════════════ */
.ms-chat-area {
    flex: 1;
    min-width: 0;
    display: flex;
    overflow: hidden;
    background: #f8fafc;
}
.ms-chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat header */
.ms-chat-hdr {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(15,23,42,0.06);
}
.ms-hdr-info { display: flex; align-items: center; gap: 13px; min-width: 0; }
.ms-hdr-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.2px;
}
.ms-hdr-sub { font-size: 12px; color: #64748b; margin-top: 2px; font-weight: 500; }
.ms-hdr-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ms-hdr-btn {
    padding: 7px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.ms-hdr-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1d4ed8;
}

/* ── Messages area ──────────────────────────────────────────── */
.ms-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #f8fafc;
    scroll-behavior: smooth;
}
.ms-messages::-webkit-scrollbar { width: 5px; }
.ms-messages::-webkit-scrollbar-track { background: transparent; }
.ms-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Date divider */
.ms-msg-date {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    margin: 16px 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.3px;
}
.ms-msg-date::before, .ms-msg-date::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
}

/* Message bubbles */
.ms-msg-bubble {
    display: inline-block;
    max-width: 100%;
    padding: 10px 15px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Typing indicator */
.ms-typing {
    height: 24px;
    padding: 0 24px;
    font-size: 12px;
    color: #64748b;
    font-style: italic;
    font-weight: 500;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* Disabled banner */
.ms-disabled-banner {
    padding: 13px 24px;
    background: linear-gradient(135deg, #fff7ed, #fef3c7);
    border-top: 2px solid #fbbf24;
    font-size: 13px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    font-weight: 500;
}

/* ── Input area ─────────────────────────────────────────────── */
.ms-input-area {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}
.ms-input-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8fafc;
    border-radius: 14px;
    border: 1.5px solid #e2e8f0;
    padding: 10px 12px;
    transition: all 0.2s;
    position: relative;
}
.ms-input-box:focus-within {
    border-color: #1d4ed8;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(29,78,216,0.08);
}
.ms-text-input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    font-size: 14px;
    color: #0f172a;
    resize: none;
    font-family: inherit;
    line-height: 1.55;
    max-height: 120px;
    min-height: 23px;
}
.ms-text-input::placeholder { color: #94a3b8; }
.ms-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 6px;
    font-size: 18px;
    border-radius: 8px;
    transition: all 0.15s;
    line-height: 1;
    flex-shrink: 0;
    color: #64748b;
}
.ms-icon-btn:hover { background: #f1f5f9; transform: scale(1.1); }
.ms-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(29,78,216,0.3);
}
.ms-send-btn:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 6px 16px rgba(29,78,216,0.4);
}
.ms-send-btn:active { transform: scale(0.97); }
.ms-send-btn:disabled { background: #e2e8f0; box-shadow: none; cursor: not-allowed; color: #94a3b8; }

/* Emoji picker */
.ms-emoji-picker {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 12px 40px rgba(15,23,42,0.15);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 280px;
    z-index: 1000;
    animation: emojiIn 0.15s ease;
}
@keyframes emojiIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.ms-emoji { font-size: 22px; cursor: pointer; padding: 5px; border-radius: 8px; line-height: 1; transition: 0.1s; }
.ms-emoji:hover { background: #f1f5f9; transform: scale(1.2); }

/* ── Group Panel ─────────────────────────────────────────────── */
.ms-group-panel {
    width: 260px;
    min-width: 260px;
    border-left: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.ms-gp-header {
    padding: 18px 18px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}
.ms-gp-member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.15s;
}
.ms-gp-member:hover { background: #f8fafc; }
.ms-role-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ms-role-badge.admin { background: rgba(29,78,216,0.1); color: #1d4ed8; }
.ms-role-badge.member { background: #f1f5f9; color: #64748b; }

/* ── Empty State ─────────────────────────────────────────────── */
.ms-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-align: center;
    padding: 40px;
    background: #f8fafc;
}

/* ── Modal ────────────────────────────────────────────────────── */
.ms-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ms-modal {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(15,23,42,0.25), 0 0 0 1px rgba(255,255,255,0.1);
    animation: msModalIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes msModalIn { from { transform: scale(0.9) translateY(10px); opacity:0; } to { transform: scale(1) translateY(0); opacity:1; } }
.ms-modal-hdr {
    padding: 24px 26px 18px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ms-modal-title { font-size: 17px; font-weight: 800; color: #0f172a; letter-spacing: -0.3px; }
.ms-modal-body { padding: 20px 26px; display: flex; flex-direction: column; gap: 18px; }
.ms-modal-footer {
    padding: 16px 26px 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.ms-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 7px;
}
.ms-field input, .ms-field textarea, .ms-field select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    color: #0f172a;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}
.ms-field input:focus, .ms-field textarea:focus {
    border-color: #1d4ed8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

/* Buttons */
.ms-btn {
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.ms-btn-primary {
    background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(29,78,216,0.3);
}
.ms-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(29,78,216,0.4); }
.ms-btn-ghost { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.ms-btn-ghost:hover { background: #e2e8f0; color: #1e293b; }
.ms-btn-danger { background: #fef2f2; color: #ef4444; border: 1px solid #fecaca; }
.ms-btn-danger:hover { background: #fee2e2; }

/* Member checkbox items */
.ms-member-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.ms-member-check:hover { background: #f1f5f9; }
.ms-member-check input[type=checkbox] { accent-color: #1d4ed8; width: 16px; height: 16px; cursor: pointer; }

/* ── Toast ────────────────────────────────────────────────────── */
.ms-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #f1f5f9;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    z-index: 99999;
    box-shadow: 0 10px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.06);
    animation: msToastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
    max-width: 360px;
    text-align: center;
}
@keyframes msToastIn { from { opacity:0; transform:translateX(-50%) translateY(12px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .ms-group-panel { display: none; }
}
@media (max-width: 640px) {
    .ms-sidebar { width: 100%; position: absolute; z-index: 10; height: 100%; }
}
