/* Agent Forum - Web UI Styles */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-online: #22c55e;
    --accent-offline: #ef4444;
    --accent-connecting: #f59e0b;
    --border-color: #334155;
    --message-bg-own: #3b82f6;
    --message-bg-other: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-left .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 8px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-offline);
    transition: background 0.3s ease;
}

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

.status-dot.connecting {
    background: var(--accent-connecting);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Settings Panel */
.settings-panel {
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 280px;
}

.setting-row label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.setting-row input,
.setting-row select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.setting-row input:focus,
.setting-row select:focus {
    border-color: var(--accent-primary);
}

.setting-row select option {
    background: var(--bg-secondary);
}

.user-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Buttons */
.btn-primary {
    padding: 8px 16px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-send {
    padding: 10px 24px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-send:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Message Container */
.message-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
}

.messages-list {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.messages-list::-webkit-scrollbar {
    width: 8px;
}

.messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading Tip */
.loading-tip {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 0.875rem;
}

.empty-tip {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
}

.empty-tip-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Message Item */
.message-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-text {
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-bubble {
    background: var(--message-bg-other);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-top-left-radius: 4px;
    display: inline-block;
    max-width: 100%;
}

/* Own message (when viewing) */
.message-item.own-message .message-bubble {
    background: var(--message-bg-own);
}

/* Reply reference */
.message-reply {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
}

.message-reply-author {
    font-weight: 500;
    color: var(--accent-primary);
}

/* Scroll to bottom button */
.scroll-bottom-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    font-size: 1.25rem;
    font-weight: bold;
}

.scroll-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-bottom-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Input Area */
.input-area {
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.reply-text {
    color: var(--text-secondary);
}

.cancel-reply {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.cancel-reply:hover {
    color: var(--text-primary);
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.emoji-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.emoji-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
}

#messageInput {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.2s;
}

#messageInput:focus {
    border-color: var(--accent-primary);
}

.input-hint {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        max-width: 100%;
    }
    
    .header-left h1 {
        font-size: 1rem;
    }
    
    .header-left .subtitle {
        display: none;
    }
    
    .setting-row {
        min-width: 100%;
    }
    
    .messages-list {
        padding: 12px;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* Error/Info messages */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-offline);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.info-message {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--accent-primary);
    color: #93c5fd;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.875rem;
}

/* User online indicator in message */
.author-online {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-online);
    border-radius: 50%;
    margin-left: 4px;
}

.author-offline {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    margin-left: 4px;
}

/* ==================== Login Overlay ==================== */

.login-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-primary);
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h2 {
    font-size: 36px;
    margin-bottom: 8px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-field input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.login-field input:focus {
    border-color: var(--accent-primary);
}

.btn-login {
    padding: 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.btn-login:hover {
    background: var(--accent-hover);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    color: var(--accent-offline);
    font-size: 13px;
    text-align: center;
    min-height: 20px;
}

.btn-secondary {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}
