/* OpenClaw Chat - Main Styles */

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-light: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --error: #ef4444;
    --user-msg: #3b82f6;
    --assistant-msg: #334155;
}

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

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

/* Screens */
.screen {
    display: none;
    height: 100vh;
}

.screen.active {
    display: flex;
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-darker), var(--bg-dark));
}

.login-container {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-container > p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary,
#login-btn,
#send-btn {
    background: var(--primary);
    color: white;
}

.btn-primary:hover,
#login-btn:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--bg-darker);
}

.error-msg {
    color: var(--error);
    text-align: center;
    font-size: 0.875rem;
    min-height: 1.25rem;
}

/* App Screen */
#app-screen {
    flex-direction: column;
}

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

.app-header h2 {
    flex: 1;
    text-align: center;
    font-size: 1.25rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-dark);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: var(--bg-light);
    border-right: 1px solid var(--border);
    transition: left 0.3s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

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

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.session-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-dark);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.session-item.active {
    background: var(--primary);
}

.session-item h4 {
    margin-bottom: 0.25rem;
}

.session-item p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

#logout-btn {
    width: 100%;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: slideIn 0.3s;
}

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

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

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

.message.assistant .message-avatar {
    background: var(--assistant-msg);
}

.message-content {
    background: var(--bg-light);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--user-msg);
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    border-bottom-left-radius: 0.25rem;
}

.message-content pre {
    background: var(--bg-darker);
    padding: 0.5rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content code {
    background: var(--bg-darker);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

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

/* Input Area */
.input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-light);
    border-top: 1px solid var(--border);
}

#message-input {
    flex: 1;
    min-height: 44px;
    max-height: 150px;
    resize: none;
    padding: 0.75rem;
}

#send-btn {
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.modal-actions button {
    flex: 1;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 1rem;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

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

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