:root {
    --bg-sidebar: #0f0f11;
    --bg-main: #18181b;
    --bg-input: #27272a;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.2);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: #3f3f46 transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

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

.sidebar-header {
    padding: 16px;
}

.new-chat-btn {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
}

.new-chat-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 14px;
}

.icon-wrapper {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-wrapper i { width: 14px; height: 14px; }

.shortcut {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
}

.history-group h4 {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin: 16px 0 8px 8px;
}

.chat-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 14px;
}

.chat-item i { width: 16px; height: 16px; }

.chat-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.chat-item.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-weight: 500;
}

.chat-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

.user-profile:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar i { width: 18px; height: 18px; color: white; }

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.user-name { font-weight: 600; font-size: 14px; }
.user-plan { font-size: 12px; color: var(--primary); font-weight: 500; }

.settings-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}
.settings-btn:hover { color: var(--text-primary); }
.settings-btn i { width: 18px; height: 18px; }

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid transparent; /* Removed solid border for a cleaner look */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: linear-gradient(to bottom, var(--bg-main) 40%, transparent);
}

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

/* Segmented Control Mode Switch */
.mode-switch {
    display: flex;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 100px;
    padding: 4px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) inset;
}

.mode-switch-bg {
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    width: calc(50% - 4px);
    background: var(--primary);
    border-radius: 100px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s ease;
    z-index: 1;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.mode-switch[data-active="pro"] .mode-switch-bg {
    transform: translateX(100%);
    background: linear-gradient(135deg, #a855f7, #6366f1);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.mode-btn {
    position: relative;
    z-index: 2;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    cursor: pointer;
    border-radius: 100px;
    transition: color 0.3s ease;
}

.mode-btn.active {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.mode-btn i {
    width: 14px;
    height: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Webhook Toggle */
.webhook-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 100px;
    border: 1px solid var(--border-color);
}
.toggle-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s;
}
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}
.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--primary);
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #f59e0b; /* Amber for Test mode */
}
input:checked + .slider:before {
    transform: translateX(14px);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.icon-btn i { width: 18px; height: 18px; }

.share-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.share-btn:hover { background: rgba(255, 255, 255, 0.05); }
.share-btn i { width: 14px; height: 14px; }

/* Chat Container */
.chat-scroll-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    padding-top: 64px; /* Space for absolute header */
}

.scroll-spacer {
    height: 140px; /* Spacing for floating input */
    flex-shrink: 0;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.8s ease-out;
}

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

.welcome-text {
    text-align: center;
    margin-bottom: 48px;
}

.gradient-text {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 38px;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.welcome-text p {
    color: var(--text-secondary);
    font-size: 16px;
}

#current-mode-label {
    color: var(--primary);
    font-weight: 600;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.suggestion-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.suggestion-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.sugg-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: var(--transition);
}

.suggestion-card:hover .sugg-icon {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.sugg-icon i { width: 20px; height: 20px; }

.sugg-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Messages Wrapper */
.messages-wrapper {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.message-block {
    display: flex;
    gap: 20px;
}

.message-block.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.msg-avatar.ai {
    background: var(--primary);
    color: white;
}
.msg-avatar.human {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.msg-avatar i { width: 18px; height: 18px; }

.msg-content {
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 85%;
}

.message-block.user .msg-content {
    background: var(--bg-input);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    border-top-right-radius: 4px;
}

.msg-content p { margin-bottom: 12px; }
.msg-content p:last-child { margin-bottom: 0; }

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}
.dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Floating Input Area */
.floating-input {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    padding: 0 24px;
    z-index: 20;
}

.glow-effect {
    position: relative;
}

.glow-effect::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: linear-gradient(45deg, var(--primary), #8b5cf6, #38bdf8, var(--primary));
    border-radius: calc(var(--radius-lg) + 2px);
    z-index: -1;
    filter: blur(8px);
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: glow-rotate 4s linear infinite;
}

@keyframes glow-rotate {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.input-container:focus-within.glow-effect::before {
    opacity: 0.4;
}

.input-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-end;
    padding: 10px 14px;
    gap: 12px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.input-container:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.attachment-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
}
.attachment-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.1); }
.attachment-btn i { width: 18px; height: 18px; }

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    padding: 6px 0;
    resize: none;
    outline: none;
    max-height: 200px;
    overflow-y: auto;
}

textarea::placeholder { color: var(--text-muted); font-weight: 400; }

.send-btn {
    background: white;
    color: black;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    margin-bottom: 2px;
}
.send-btn:hover { transform: scale(1.05); background: var(--text-primary); }
.send-btn:disabled { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.3); cursor: not-allowed; transform: none; }
.send-btn i { width: 18px; height: 18px; }

.input-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 14px;
    font-weight: 500;
}

/* Scrollbar customization */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 10px; border: 2px solid var(--bg-main); }
::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* Lead Form */
.lead-form-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 12px;
    animation: iaSlideIn 0.3s ease-out;
}

.lead-form-container h4 {
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

#chat-lead-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#chat-lead-form input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

#chat-lead-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.lead-submit-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 4px;
}

.lead-submit-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

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