/* Enforce HTML hidden attribute — author flex/grid rules can override UA display:none */
[hidden] { display: none !important; }

#app {
    display: flex;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-app);
}

/* ── Sidebar ──────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    z-index: var(--z-sidebar);
}

/* ── Main chat area ───────────────────────── */
#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ── Empty state ──────────────────────────── */
#empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
    user-select: none;
}
#empty-state svg { opacity: .35; }
#empty-state p { font-size: 15px; }

/* ── Chat window ──────────────────────────── */
#chat-window {
    display: none;
    flex-direction: column;
    height: 100%;
}
#chat-window.active { display: flex; }

/* ── Message list ─────────────────────────── */
#message-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 8%;
    background: var(--bg-chat);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ccircle cx='40' cy='40' r='1' fill='%23ccc' fill-opacity='.08'/%3E%3C/svg%3E");
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#message-list::-webkit-scrollbar { width: 5px; }
#message-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 4px; }

/* ── Scroll to bottom button ─────────────── */
#scroll-btn {
    position: absolute;
    bottom: 90px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-sidebar);
    box-shadow: var(--shadow-md);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    color: var(--text-secondary);
    font-size: 18px;
    transition: var(--transition);
}
#scroll-btn.show { display: flex; }
#scroll-btn:hover { background: var(--bg-hover); }
#scroll-btn .unread-dot {
    position: absolute;
    top: -2px; right: -2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}
#scroll-btn.has-unread .unread-dot { display: flex; }

/* ── Modal ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 1000);
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--surface-1, #fff);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    max-height: 88vh;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, #e0e0e0);
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal-body label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary, #666);
}
.modal-body input[type=text] {
    padding: 10px 12px;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
    background: var(--surface-2, #f5f5f5);
    color: var(--text-primary, #111);
    outline: none;
}
.modal-body input[type=text]:focus {
    border-color: var(--color-primary, #2980b9);
}
.modal-footer {
    padding: 12px 20px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--border, #e0e0e0);
}
.btn-primary {
    padding: 10px 24px;
    background: var(--color-primary, #2980b9);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
