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

:root {
    --primary: #7AC141;
    --primary-dark: #5A9E2F;
    --blue: #0055A5;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --accent: #7AC141;
    --accent-dark: #5A9E2F;
    --accent-light: #edf7e2;
    --accent-glow: rgba(122, 193, 65, 0.15);
    --user-bg: #f0f9e6;
    --assistant-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --sidebar-width: 280px;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
}

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

/* ===== Auth Screen ===== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #5A9E2F 0%, #3d6e1f 50%, #0055A5 100%);
    position: relative;
    overflow: hidden;
}

.auth-screen::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    border-radius: 50%;
}

.auth-screen::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(122,193,65,0.2) 0%, transparent 70%);
    bottom: -100px;
    left: -50px;
    border-radius: 50%;
}

.auth-card {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px 44px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
    max-width: 420px;
    width: 90%;
    position: relative;
    z-index: 1;
}

.auth-logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.auth-form {
    text-align: left;
}

.auth-form .form-row {
    margin-bottom: 14px;
}

.auth-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.auth-form input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafbfc;
}

.auth-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: white;
}

.auth-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
    min-height: 20px;
}

.btn-login-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #7AC141, #5A9E2F);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-login-submit:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(122,193,65,0.4);
    transform: translateY(-1px);
}

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

/* ===== App Container ===== */
.app-container {
    display: flex;
    height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #7AC141, #5A9E2F);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
}

.btn-new {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.btn-new:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 16px 6px;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: all 0.15s;
}

.conversation-item:hover { background: #f3f4f6; }

.conversation-item.active {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
}

.conv-title {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    font-weight: 450;
}

.conv-time {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: 8px;
    flex-shrink: 0;
}

.btn-delete {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.conversation-item:hover .btn-delete { opacity: 0.6; }
.btn-delete:hover {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
    opacity: 1 !important;
}

.skeleton-item {
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(90deg, #f3f4f6 25%, #fafafa 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sidebar-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 40px 20px;
    line-height: 1.6;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    background: #fafbfc;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.user-info-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-name {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: color 0.15s;
}

.btn-logout:hover { color: var(--danger); }

/* ===== Chat Main ===== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
    position: relative;
}

.btn-hamburger {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
}

/* ===== Welcome Screen ===== */
.welcome {
    text-align: center;
    padding: 60px 24px 40px;
    max-width: 680px;
    margin: 0 auto;
}

.welcome-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #7AC141 0%, #5A9E2F 100%);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(122,193,65,0.3);
    font-size: 36px;
}

.welcome h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.welcome .welcome-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 540px;
    margin: 0 auto;
}

.suggestion {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    line-height: 1.4;
}

.suggestion:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(122,193,65,0.15);
    transform: translateY(-2px);
}

.suggestion-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.suggestion-icon.green { background: #edf7e2; }
.suggestion-icon.blue { background: #dbeafe; }
.suggestion-icon.purple { background: #ede9fe; }
.suggestion-icon.amber { background: #fef3c7; }

.suggestion-label {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    font-size: 13px;
}

.suggestion-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Messages ===== */
.message {
    display: flex;
    gap: 12px;
    padding: 18px 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message.user {
    background: var(--user-bg);
    border-bottom: 1px solid rgba(122,193,65,0.1);
}

.message.assistant {
    background: white;
    border-bottom: 1px solid var(--border);
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    font-weight: 600;
    color: white;
}

.agent-avatar {
    background: linear-gradient(135deg, #7AC141, #5A9E2F);
}

.user-avatar {
    background: var(--blue);
    border-radius: 50%;
}

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

.message-sender {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-time { opacity: 1; }

.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
}

.message:hover .btn-copy { opacity: 0.5; }
.btn-copy:hover {
    opacity: 1 !important;
    color: var(--accent);
    background: var(--accent-light);
}

.message-content {
    flex: 1;
    line-height: 1.65;
    font-size: 14.5px;
    overflow-wrap: break-word;
}

.message-content pre {
    background: #1e1e2e;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content code {
    font-family: 'SF Mono', 'Fira Code', Monaco, monospace;
    font-size: 13px;
}

.message-content p:not(:last-child) { margin-bottom: 12px; }

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.message-content th, .message-content td {
    border: 1px solid var(--border);
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
}

.message-content th {
    background: #f8fafc;
    font-weight: 600;
}

.message-content ul, .message-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.message-content li { margin-bottom: 4px; }

/* ===== Tool Activity ===== */
.tool-activity {
    margin-bottom: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
}

.tool-activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.tool-activity-item:not(:last-child) {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    margin-bottom: 3px;
}

.tool-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

.tool-check {
    width: 16px;
    height: 16px;
    color: var(--accent);
    flex-shrink: 0;
}

.tool-result-badge {
    font-size: 11px;
    color: var(--accent-dark);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: 500;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 14px;
}

.typing-indicator::after {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

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

/* ===== Input Area ===== */
.input-area {
    padding: 16px 24px 20px;
    background: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.03);
}

.input-form {
    display: flex;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
    align-items: flex-end;
}

.input-form textarea {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 12px 18px;
    font-size: 14.5px;
    font-family: inherit;
    resize: none;
    min-height: 48px;
    max-height: 200px;
    overflow: hidden;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafbfc;
}

.input-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: white;
}

.btn-send, .btn-stop {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-send {
    background: linear-gradient(135deg, #7AC141, #5A9E2F);
    box-shadow: 0 2px 8px rgba(122,193,65,0.35);
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(122,193,65,0.45);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-stop {
    background: var(--danger);
    box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}

.btn-stop:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease-out;
    max-width: 360px;
}

.toast.success { background: linear-gradient(135deg, #7AC141, #5A9E2F); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.info { background: linear-gradient(135deg, #0055A5, #003d7a); }

@keyframes toast-in {
    from { transform: translateX(100%) scale(0.8); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

[x-cloak] { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.sidebar-open { left: 0; }

    .sidebar-backdrop.visible { display: block; }

    .btn-hamburger { display: block; }

    .message { padding: 14px 16px; }

    .input-area { padding: 12px 16px 16px; }

    .suggestions { grid-template-columns: 1fr; }
}
