/* style.css — Chat App (3 themes) */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── THEMES ─────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg: #020810;
    --panel: #0d1117;
    --panel-2: #161b22;
    --border: rgba(48, 54, 61, .8);
    --text: #e6edf3;
    --muted: #7d8590;
    --accent: #18e1d2;
    --accent-glow: rgba(24, 225, 210, .15);
    --danger: #f85149;
    --online: #3fb950;
    --busy: #d29922;
    --radius: 12px;
    --msg-hover: rgba(255, 255, 255, .03);
    --scrollbar: #30363d;
}

[data-theme="neon"] {
    --bg: #0a0014;
    --panel: #120020;
    --panel-2: #1a0030;
    --border: rgba(180, 80, 240, .25);
    --text: #f5eeff;
    --muted: #a07db8;
    --accent: #d946ef;
    --accent-glow: rgba(217, 70, 239, .18);
    --danger: #f87171;
    --online: #4ade80;
    --busy: #fbbf24;
    --radius: 12px;
    --msg-hover: rgba(217, 70, 239, .04);
    --scrollbar: #3d1060;
}

[data-theme="light"] {
    --bg: #f0f4f3;
    --panel: #ffffff;
    --panel-2: #f4f8f7;
    --border: rgba(0, 0, 0, .09);
    --text: #1a2420;
    --muted: #5a6e6a;
    --accent: #0d9488;
    --accent-glow: rgba(13, 148, 136, .12);
    --danger: #dc2626;
    --online: #16a34a;
    --busy: #d97706;
    --radius: 12px;
    --msg-hover: rgba(0, 0, 0, .02);
    --scrollbar: #cddad8;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    transition: background .35s, color .35s;
}

/* ── APP LAYOUT ─────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
    width: 256px;
    min-width: 256px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background .35s, border .35s;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px 16px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.82rem;
    color: #000;
    flex-shrink: 0;
}

.user-name {
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.72rem;
    color: var(--accent);
    text-transform: capitalize;
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.icon-btn:hover {
    background: var(--panel-2);
    color: var(--text);
}

.icon-btn#logout-btn:hover {
    color: var(--danger);
}

.sidebar-section {
    padding: 12px 0;
    overflow-y: auto;
}

.section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding: 4px 16px 8px;
}

.rooms-list {
    list-style: none;
}

.rooms-list li {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 16px;
    cursor: pointer;
    border-radius: 7px;
    margin: 0 6px;
    font-size: 0.875rem;
    color: var(--muted);
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rooms-list li:hover {
    background: var(--panel-2);
    color: var(--text);
}

.rooms-list li.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.room-hash {
    color: var(--muted);
    font-weight: 400;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--muted);
}

.status-dot.online {
    background: var(--online);
    box-shadow: 0 0 6px var(--online);
}

.status-dot.busy {
    background: var(--busy);
}

.unread-badge {
    background-color: var(--danger, #ff4444);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    box-shadow: 0 0 5px var(--danger, #ff4444);
}

/* ── CHAT AREA ──────────────────────────────────────────── */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
    transition: background .35s;
}

.no-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    gap: 12px;
}

.no-room-icon {
    font-size: 3rem;
    opacity: .25;
}

.no-room p {
    font-size: 0.9rem;
}

#chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    transition: background .35s, border .35s;
}

.chat-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.chat-subtitle {
    font-size: 0.76rem;
    color: var(--muted);
    margin-top: 2px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scroll-behavior: smooth;
}

.date-divider {
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted);
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── MESSAGES (WHATSAPP STYLE) ── */
.msg {
    display: flex;
    margin-bottom: 8px;
    width: 100%;
    animation: msgIn .18s ease both;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-body.bubble {
    max-width: 65%;
    padding: 6px 8px 8px 10px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.msg-sender {
    font-weight: 600;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 2px;
}

.msg-content {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}

.msg-text {
    font-size: 14.5px;
    line-height: 1.4;
    word-wrap: break-word;
    color: var(--text);
    padding-bottom: 4px;
}

.msg-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-left: auto;
    white-space: nowrap;
    margin-bottom: -4px;
}

/* Received (Left) */
.msg-other {
    justify-content: flex-start;
}

.msg-other .msg-body.bubble {
    background: #202c33;
    border-top-left-radius: 0;
}

/* Sent (Right) */
.msg-self {
    justify-content: flex-end;
}

.msg-self .msg-body.bubble {
    background: #005c4b;
    border-top-right-radius: 0;
}

.msg-self .msg-time {
    color: rgba(255, 255, 255, 0.7);
}

.msg-deleted {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.message-input-wrap {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--panel);
    display: flex;
    gap: 10px;
    align-items: center;
    transition: background .35s, border .35s;
}

.attach-btn {
    background: transparent;
    color: var(--muted);
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: color .2s, background .2s;
}

.attach-btn:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

/* File Attachments — WhatsApp Style */
.file-attachment {
    margin-top: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    display: block;
}

.attachment-img {
    max-width: 220px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    margin-bottom: 4px;
}

.attachment-name {
    font-size: 11px;
    opacity: 0.8;
    word-break: break-all;
}

.file-attachment.doc {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 10px;
    padding: 8px 12px 8px 8px;
    width: 230px;
    max-width: 230px;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.file-attachment.doc:hover {
    background: rgba(0, 0, 0, 0.38);
}

/* Colored circle icon */
.doc-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    background: #6c757d;
}

.doc-icon.ft-pdf {
    background: #e53935;
}

.doc-icon.ft-xls,
.doc-icon.ft-xlsx,
.doc-icon.ft-csv {
    background: #2e7d32;
}

.doc-icon.ft-doc,
.doc-icon.ft-docx {
    background: #1565c0;
}

.doc-icon.ft-py {
    background: #0277bd;
}

.doc-icon.ft-txt {
    background: #546e7a;
}

.doc-icon.ft-json {
    background: #f57f17;
}

.doc-icon.ft-exe {
    background: #4a148c;
}

.doc-icon.ft-png,
.doc-icon.ft-jpg,
.doc-icon.ft-jpeg {
    background: #00838f;
}

/* Text info — constrained so it never overflows */
.doc-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.doc-name {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-bottom: 2px;
}

.doc-meta {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.doc-download {
    display: none;
}

#msg-input {
    flex: 1;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 10px 14px;
    outline: none;
    resize: none;
    max-height: 120px;
    transition: border .2s;
    line-height: 1.5;
}

#msg-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.send-btn {
    background: var(--accent);
    color: #000;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity .2s, transform .15s;
}

.send-btn:hover {
    opacity: .85;
    transform: scale(1.06);
}

.send-btn:active {
    transform: scale(.96);
}

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border-radius: 99px;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }

    .user-name {
        display: none;
    }
}









/* Override browser autofill styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--panel-2) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ── TOAST NOTIFICATIONS ────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: max-content;
    max-width: 400px;
    pointer-events: auto;
    animation: toast-slide-down 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toast.fade-out {
    animation: toast-fade-out 0.3s ease forwards;
}

.toast-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.toast-body {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes toast-slide-down {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toast-fade-out {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-20px);
        opacity: 0;
    }
}

/* ── Message Delete Button ───────────────────────────────── */
.msg-delete-btn {
    display: none;
    position: absolute;
    top: 4px;
    left: -30px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    padding: 2px 4px;
    border-radius: 4px;
    transition: opacity 0.2s, background 0.2s;
    color: var(--danger);
}

.msg-delete-btn:hover {
    opacity: 1;
    background: rgba(248, 81, 73, 0.12);
}

.msg-self .msg-body {
    position: relative;
}

.msg-self:hover .msg-delete-btn {
    display: block;
}