/* agent-webbridge — Modern Chat UI */

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-input: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #333333;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-secondary);
}

/* Status Bar */
#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.status-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

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

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

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

.status.disconnected .status-dot {
    background: var(--text-muted);
}

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

.agent-name {
    font-weight: 600;
    font-size: 14px;
}

.status-right {
    display: flex;
    gap: 8px;
}

/* Icon Buttons */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Chat Container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

#welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

#welcome-message.hidden {
    display: none;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

#welcome-message h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

#welcome-message p {
    font-size: 14px;
}

/* Messages */
.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
}

.message.agent {
    align-self: flex-start;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.message-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.message.user .message-avatar {
    background: var(--accent);
}

.message.agent .message-avatar {
    background: var(--bg-tertiary);
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.agent .message-content {
    background: var(--bg-tertiary);
    border-bottom-left-radius: 4px;
}

.message-content pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
}

.message-content code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.message.user .message-time {
    text-align: right;
}

/* File Preview */
.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.file-preview.hidden {
    display: none;
}

.file-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
}

.file-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

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

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 8px 12px;
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    max-height: 150px;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
}

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

.send-btn {
    background: var(--accent);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

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

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

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

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

/* Responsive */
@media (max-width: 600px) {
    #app {
        max-width: 100%;
    }
    
    .message {
        max-width: 90%;
    }
}
