/* Spjall - Retro Terminal Chat */

:root {
    --bg: #0a0a0f;
    --bg-secondary: #101018;
    --bg-hover: #18181f;
    --text: #b0b0b0;
    --text-bright: #e0e0e0;
    --text-dim: #505050;
    --accent: #5a9;
    --accent-dim: #486;
    --border: #252530;
    --online: #5a5;
    --offline: #555;
    --error: #a55;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Source Code Pro', 'IBM Plex Mono', 'Cascadia Code', 'Consolas', 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.5;
}

#app {
    height: 100%;
}

/* States */
.state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status {
    color: var(--text-dim);
}

.status.error {
    color: var(--error);
}

/* Main Container */
.container {
    display: flex;
    height: 100%;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.chat-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-bright);
    font-weight: 500;
}

.chat-header:empty {
    display: none;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    /* Subtle noise texture to break the flat void */
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.01) 2px,
            rgba(255, 255, 255, 0.01) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.01) 2px,
            rgba(255, 255, 255, 0.01) 4px
        );
    background-size: 4px 4px;
    position: relative;
}

.messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.4;
}

.message {
    word-wrap: break-word;
    line-height: 1.6;
    margin-bottom: 6px;
}

/* Consecutive messages from same user - tighter spacing */
.message-consecutive {
    margin-top: 2px !important;
    margin-bottom: 6px;
}

/* New sender - more space before */
.message-new-sender {
    margin-top: 8px !important;
    margin-bottom: 6px;
}

.message .nick {
    color: var(--accent);
    font-weight: 500;
    margin: 0 2px;
}

.message .nick.self {
    color: var(--text-bright);
    font-weight: 500;
    margin: 0 2px;
}

.message .time {
    color: #353535;
    font-size: 10px;
    margin-right: 4px;
    opacity: 0.7;
}

.message .text {
    color: var(--text);
    margin-left: 2px;
}

.message-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(90, 170, 153, 0.4);
    text-underline-offset: 2px;
    transition: color 0.2s, text-decoration-color 0.2s;
}

.message-link:hover {
    color: var(--accent-dim);
    text-decoration-color: rgba(90, 170, 153, 0.6);
}

.message.system {
    color: var(--text-dim);
    font-style: italic;
    text-align: center;
    padding: 8px 0;
    font-size: 11px;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

.message-divider {
    height: 1px;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 20%,
        rgba(255, 255, 255, 0.08) 80%,
        transparent 100%
    );
    margin: 12px 0;
    position: relative;
}

.message-divider::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.input-area {
    padding: 12px;
    background: #0f0f18;
    position: relative;
    border-top: none;
    /* Warm glow from top - gentle surface lighting */
    box-shadow: 
        inset 0 1px 0 rgba(255, 180, 100, 0.15),
        inset 0 2px 4px rgba(255, 140, 0, 0.08);
    background-image: 
        /* Reflected firelight at top edge - very faint */
        linear-gradient(to bottom, 
            rgba(255, 180, 100, 0.04) 0%,
            rgba(255, 180, 100, 0.02) 1px,
            transparent 3px
        ),
        /* Warm ambient glow */
        linear-gradient(to bottom, 
            rgba(255, 180, 100, 0.06) 0%,
            rgba(255, 140, 0, 0.03) 20%,
            transparent 40%
        ),
        /* Base dark background */
        #0f0f18;
}

/* Stone lip - grounded hearth rim */
.input-area::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #08080d;
    opacity: 0.8;
}

#message-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-bright);
    font-family: inherit;
    font-size: inherit;
    outline: none;
    /* Cursor as flame - warm accent, slightly thicker */
    caret-color: rgba(255, 180, 100, 0.9);
    caret-width: 2px;
    /* Warm inner glow - gentle surface lighting */
    box-shadow: 
        inset 0 1px 0 rgba(255, 180, 100, 0.12),
        inset 0 -1px 0 rgba(255, 140, 0, 0.05);
    /* Very faint reflected firelight at top edge */
    background-image: 
        linear-gradient(to bottom,
            rgba(255, 180, 100, 0.03) 0%,
            rgba(255, 180, 100, 0.015) 1px,
            transparent 2px
        ),
        var(--bg-secondary);
}

#message-input:focus {
    background: #12121a;
    /* Slightly warmer glow when active */
    box-shadow: 
        inset 0 1px 0 rgba(255, 180, 100, 0.18),
        inset 0 -1px 0 rgba(255, 140, 0, 0.08),
        inset 0 2px 4px rgba(255, 180, 100, 0.06);
}

#message-input::placeholder {
    color: var(--text-dim);
}

/* Sidebar */
.sidebar {
    width: 200px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

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

.sidebar-header .logo {
    width: 180px;
    height: 180px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.3),
        0 0 1px rgba(255, 255, 255, 0.05);
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

.sidebar-header .app-name {
    color: var(--text-bright);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-align: center;
    margin-top: 4px;
}

.sidebar-section {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.section-header {
    padding: 4px 12px 2px 12px;
    color: #2a2a2a;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    opacity: 0.5;
}

.conversation-item {
    padding: 4px 12px;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--bg-hover);
    color: var(--text-bright);
}

.conversation-item .unread-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.conversation-item.active .unread-badge {
    display: none;
}

.user-item {
    padding: 1px 12px 1px 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.user-item:hover {
    background: var(--bg-hover);
}

.user-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--online);
}

.user-dot.user-dot-self {
    background: #6c9;
}

.user-dot.offline {
    background: var(--offline);
}

.user-name {
    color: var(--text);
    font-size: 12px;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 12px !important;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-info {
    color: var(--text-bright);
    font-size: 12px;
    margin-bottom: 4px;
}

.btn-small {
    padding: 3px 6px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-small:hover {
    opacity: 1;
    color: var(--text);
}

/* Make + Roundtable button more visible */
#group-btn {
    color: var(--text);
    opacity: 0.9;
    font-weight: 500;
}

#group-btn:hover {
    opacity: 1;
    color: var(--text-bright);
}

.btn-dim {
    color: var(--text-dim);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 16px;
    min-width: 300px;
}

.modal-header {
    color: var(--text-bright);
    margin-bottom: 12px;
}

.modal-body {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.modal-body input {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-bright);
    font-family: inherit;
    font-size: 12px;
}

.modal-footer {
    text-align: right;
}

/* Group user selection */
.group-user-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    cursor: pointer;
}

.group-user-option:hover {
    background: var(--bg-hover);
}

.group-user-option input[type="checkbox"] {
    accent-color: var(--accent);
}

.group-user-option label {
    cursor: pointer;
    flex: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Loading history indicator */
.loading-history {
    text-align: center;
    padding: 8px;
    color: var(--text-dim);
    font-size: 11px;
}

