/* Prom Chat — dark, Telegram-style two-pane. Built fresh. */
:root {
    --bg: #0e1621;
    --bg-sidebar: #17212b;
    --bg-thread: #0e1621;
    --bg-header: #17212b;
    --bg-hover: #202b36;
    --bg-active: #2b5278;
    --bubble-in: #182533;
    --bubble-out: #2b5278;
    --accent: #5288c1;
    --accent-strong: #6ab3f3;
    --text: #ffffff;
    --text-dim: #7d8e9b;
    --text-muted: #6d7f8c;
    --border: #101921;
    --badge: #4fae4e;
    --danger: #e06c6c;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --chat-pattern: radial-gradient(circle at 50% 50%, rgba(255,255,255,.02) 0 1px, transparent 1px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

/* ───────── Login ───────── */
.login-view {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    width: min(360px, 90vw);
    background: var(--bg-sidebar);
    border-radius: 16px;
    padding: 40px 32px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-logo { font-size: 56px; line-height: 1; }
.login-title { margin: 16px 0 4px; font-size: 24px; }
.login-sub { margin: 0 0 28px; color: var(--text-dim); }
.login-btn {
    width: 100%;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 16px;
    background: var(--accent);
    color: #fff; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600;
    transition: background .15s;
}
.login-btn:hover { background: var(--accent-strong); }
.g-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff; color: #4285f4; font-weight: 800;
}
.login-error { margin: 16px 0 0; color: var(--danger); font-size: 13px; }

/* ───────── App shell ───────── */
.app {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    height: 100%;
}
.app.embed { grid-template-columns: 1fr; }

/* ───────── Sidebar ───────── */
.sidebar {
    display: flex; flex-direction: column;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    min-width: 0;
}
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.sidebar-title { font-size: 17px; font-weight: 600; }
.sidebar-me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-name {
    color: var(--text-dim); font-size: 12px; max-width: 120px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conn-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); flex: none;
    transition: background .2s;
}
.conn-dot.online { background: var(--badge); }
.icon-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 16px; padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.search-wrap { padding: 8px 10px; }
.search-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 18px;
    padding: 8px 14px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

.room-list { flex: 1; overflow-y: auto; }
.room-list-empty, .room-list .room-list-empty {
    padding: 24px 16px; color: var(--text-muted); text-align: center; font-size: 13px;
}

.room-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,.02);
    min-width: 0;
}
.room-item:hover { background: var(--bg-hover); }
.room-item.active { background: var(--bg-active); }
.room-item.active .room-preview,
.room-item.active .room-time { color: rgba(255,255,255,.7); }

.room-thumb {
    width: 48px; height: 48px; border-radius: 50%; flex: none;
    overflow: hidden; background: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.room-thumb img { width: 100%; height: 100%; object-fit: cover; }
.avatar-initial { font-size: 20px; font-weight: 600; color: #fff; }

.room-main { flex: 1; min-width: 0; }
.room-top, .room-bottom {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.room-name {
    font-weight: 600; font-size: 15px; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room-time { color: var(--text-muted); font-size: 12px; flex: none; }
.room-preview {
    color: var(--text-dim); font-size: 13px; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-top: 2px;
}
.badge {
    background: var(--badge); color: #fff;
    font-size: 12px; font-weight: 600;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    flex: none;
}

/* ───────── Thread ───────── */
.thread {
    display: flex; flex-direction: column;
    background: var(--bg-thread);
    background-image: var(--chat-pattern);
    background-size: 24px 24px;
    min-width: 0; position: relative;
}
.thread-header {
    display: flex; align-items: center;
    padding: 10px 18px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    min-height: 56px;
    z-index: 2;
}
.thread-title {
    font-weight: 600; font-size: 16px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.load-more {
    align-self: center;
    margin: 8px auto 0;
    background: var(--bg-header); color: var(--text-dim);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 5px 14px; font-size: 12px;
    position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
    z-index: 3;
}
.load-more:hover { background: var(--bg-hover); color: var(--text); }
.load-more:disabled { opacity: .5; cursor: default; }

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

.thread-empty {
    position: absolute; inset: 56px 0 0 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted); pointer-events: none;
}
.empty-illustration { font-size: 64px; opacity: .4; }
.empty-text { margin-top: 12px; font-size: 14px; }

.date-sep { display: flex; justify-content: center; margin: 10px 0; }
.date-sep-label {
    background: rgba(0,0,0,.35); color: var(--text-dim);
    font-size: 12px; padding: 4px 12px; border-radius: 12px;
}

.msg-row { display: flex; margin: 2px 0; max-width: 100%; }
.msg-row.in { justify-content: flex-start; }
.msg-row.out { justify-content: flex-end; }

.bubble {
    max-width: min(560px, 75%);
    padding: 7px 10px 6px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    word-wrap: break-word; overflow-wrap: anywhere;
}
.msg-row.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg-row.out .bubble { background: var(--bubble-out); border-bottom-right-radius: 4px; }
.bubble.pending { opacity: .75; }
.bubble.failed { outline: 1px solid var(--danger); }

.msg-body { white-space: pre-wrap; line-height: 1.35; font-size: 14px; }
.msg-meta {
    display: flex; align-items: center; justify-content: flex-end; gap: 4px;
    margin-top: 2px; font-size: 11px; color: var(--text-dim);
    user-select: none;
}
.msg-row.out .msg-meta { color: rgba(255,255,255,.6); }
.msg-status { font-size: 11px; }

/* attachments */
.attachment { margin-bottom: 4px; }
.att-image-link { display: block; }
.att-image {
    max-width: 100%; max-height: 320px; border-radius: 8px; display: block;
}
.att-file {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; background: rgba(0,0,0,.2);
    border-radius: 8px; text-decoration: none; color: var(--accent-strong);
}
.att-file:hover { background: rgba(0,0,0,.3); }
.att-file-icon { font-size: 18px; }
.att-file-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
    color: var(--text);
}

.thread-error { color: var(--danger); text-align: center; margin: 24px auto; }

/* ───────── Composer ───────── */
.composer {
    background: var(--bg-header);
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    z-index: 2;
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.attach-btn { font-size: 20px; padding: 8px; }
.composer-input {
    flex: 1;
    resize: none;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 18px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px; line-height: 1.35;
    max-height: 140px; outline: none;
}
.composer-input:focus { border-color: var(--accent); }
.composer-input::placeholder { color: var(--text-muted); }
.composer-input:disabled { opacity: .6; }
.send-btn {
    flex: none;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--accent); color: #fff; border: none;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.send-btn:hover { background: var(--accent-strong); }
.send-btn:disabled { opacity: .5; cursor: default; }

.attach-preview { padding: 0 0 8px; }
.attach-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg); border-radius: 14px; padding: 6px 10px; max-width: 100%;
}
.attach-chip-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px;
    font-size: 13px;
}
.attach-chip-remove {
    background: transparent; border: none; color: var(--text-dim); font-size: 13px; padding: 0 2px;
}
.attach-chip-remove:hover { color: var(--danger); }

/* ───────── Responsive / embed ───────── */
@media (max-width: 720px) {
    .app:not(.embed) { grid-template-columns: 1fr; }
    .app:not(.embed) .thread { display: none; }
    .app:not(.embed) .thread.open { display: flex; position: fixed; inset: 0; z-index: 10; }
}

/* scrollbars */
.room-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 8px; }
.room-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12); border-radius: 4px;
}
