@import url('../styles.css');

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-secondary, #F9FAFB);
    font-family: var(--font-sans);
}

/* Custom Scrollbar (Global) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background-color: #0d9668;
}

.app-layout {
    display: flex;
    height: 100%;
    height: 100dvh;
    width: 100%;
}

/* Sidebar styling - POP ART STYLE */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary, #F9FAFB);
    color: var(--text-primary, #111827);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color, #E5E7EB);
    transition: all 0.3s ease;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
}

.logo {
    display: flex;
    align-items: center;
    color: var(--text-primary, #111827);
    text-decoration: none;
    font-family: var(--font-serif);
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.05em;
}

.logo span {
    color: var(--accent);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.new-chat-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.05);
}

.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 4px 8px;
    margin: 0;
    font-weight: 700;
}

#history-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-primary, #111827);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
    position: relative;
}

.history-item::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 12px;
    right: 12px;
    height: 1px;
    background-color: var(--border-color, #E5E7EB);
}

.history-item:last-child::after {
    display: none;
}

.history-item:hover, .history-item.active {
    background: var(--bg-secondary, #F9FAFB);
    border-color: var(--text-primary, #111827);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.delete-chat-btn {
    background: none;
    border: none;
    color: #9ca3af;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.delete-chat-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.history-item:hover .delete-chat-btn {
    display: flex;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color, #E5E7EB);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary, #111827);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    border-color: var(--text-primary, #111827);
    background: var(--bg-secondary, #F9FAFB);
}


.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary, #FFFFFF);
    color: var(--text-primary, #111827);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-weight: bold;
    font-size: 16px;
    border: 1px solid var(--border-color, #E5E7EB);
    flex-shrink: 0;
}

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

.user-info strong {
    font-size: 0.9rem;
    color: var(--text-primary, #111827);
    font-weight: 700;
}

.user-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary, #F9FAFB);
    position: relative;
    min-width: 0;
}

.mobile-header {
    display: none;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #F9FAFB);
    position: relative;
}

.mobile-menu-btn {
    position: absolute;
    left: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary, #111827);
    padding: 0;
    display: flex;
}

.mobile-title {
    font-weight: 700;
    color: var(--text-primary, #111827);
    font-family: var(--font-serif);
}

.intro-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.chat-view-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
}



.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 5vh;
    margin-bottom: 24px;
    text-align: center;
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.empty-icon {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    background: white;
    border: 3px solid var(--text-primary, #111827);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 8px 8px 0px var(--text-primary, #111827);
}

.chat-empty-state h2 {
    font-size: 1.75rem;
    color: var(--text-primary, #111827);
    margin: 0 0 32px 0;
    font-family: var(--font-serif);
    flex-shrink: 0;
    line-height: 1.5;
    padding-bottom: 4px;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 4px;
}

.suggestion-btn {
    background: white;
    border: 1px solid var(--border-color, #E5E7EB);
    padding: 16px;
    border-radius: 12px;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-primary, #111827);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    user-select: none;
    -webkit-user-select: none;
}

.suggestion-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.05);
    background: #f3f4f6;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto 40px auto;
}

.message-enter {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(8px);
}

@keyframes slideUpFade {
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-color, #E5E7EB);
    background-color: var(--bg-primary, #FFFFFF);
}

.message.user .avatar {
    color: var(--text-primary, #111827);
}

.message.assistant .avatar {
    color: var(--text-primary, #111827);
}

.message-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary, #111827);
    max-width: calc(100% - 60px);
    padding-top: 6px;
    border: 1px solid transparent;
}

.message.user .message-content {
    background-color: white;
    padding: 12px 16px;
    border-radius: 16px;
    border-top-right-radius: 4px;
    border-color: var(--border-color, #E5E7EB);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Tech Pack Upload UI */
.techpack-upload-box {
    margin-top: 16px;
    border: 2px dashed var(--border-color, #E5E7EB);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    background: white;
    transition: all 0.2s ease;
}

.techpack-upload-box:hover {
    border-color: var(--accent, #059669);
    background: rgba(5, 150, 105, 0.02);
}

.techpack-upload-box .upload-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary, #F9FAFB);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary, #111827);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.techpack-upload-box .upload-text {
    display: flex;
    flex-direction: column;
}

/* Success and Error Banners */
.success-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    margin-top: 8px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.95rem;
}

.error-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    margin-top: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.95rem;
}

.message.assistant .message-content {
    background-color: transparent;
    padding: 0;
}

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

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

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

/* Input Area */
.chat-input-container {
    position: relative;
    z-index: 10;
    padding: 16px 24px 24px 24px;
    background: linear-gradient(180deg, rgba(249,250,251,0) 0%, rgba(249,250,251,1) 30%);
}

.chat-input-container::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to top, rgba(249, 250, 251, 1) 0%, rgba(249, 250, 251, 0.8) 50%, rgba(249, 250, 251, 0) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-input-container:focus-within::before {
    opacity: 1;
}

.intro-input-container {
    padding: 16px 24px 24px 24px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.chat-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

#chat-form, #intro-form {
    display: flex;
    align-items: flex-end;
    background: white;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

#chat-form:focus-within, #intro-form:focus-within {
    box-shadow: 0 10px 30px -10px rgba(5, 150, 105, 0.2);
    border-color: var(--accent);
}

#chat-input, #intro-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary, #111827);
    font-weight: 500;
    resize: none;
    min-height: 24px;
    max-height: 150px;
    line-height: 1.5;
    overflow-y: hidden;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

#chat-input::-webkit-scrollbar,
#intro-input::-webkit-scrollbar,
.chat-input-wrapper textarea::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

#chat-input::placeholder,
#intro-input::placeholder {
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
}

#send-btn, #intro-send-btn {
    background: var(--accent, #059669);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mic-btn {
    background: transparent;
    color: #9ca3af;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 4px;
}

.mic-btn:hover {
    color: var(--accent);
    background: rgba(5, 150, 105, 0.1);
}

.attach-btn {
    background: transparent;
    color: #9ca3af;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 2px;
}

.attach-btn:hover {
    color: var(--accent, #059669);
    background: rgba(5, 150, 105, 0.1);
}

.mic-btn.recording {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#send-btn:hover:not(:disabled),
#intro-send-btn:hover:not(:disabled) {
    background: #10b981;
    color: #ffffff;
}

#send-btn:hover:not(:disabled) svg,
#intro-send-btn:hover:not(:disabled) svg {
    color: #ffffff;
    stroke: #ffffff;
}

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

.chat-disclaimer {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 400;
}

/* Typing indicator */
#typing-indicator {
    /* Initially hidden, controlled by inline style or .active class */
}

#typing-indicator.active {
    display: flex !important;
}

.skeleton-loader {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 150px;
}

.skeleton-line {
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.skeleton-line::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 100;
    }
    
    .sidebar.active {
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15), 0 0 0 100vw rgba(0,0,0,0.5);
    }
    
    .mobile-header {
        display: flex;
    }
    
    .suggestion-wrapper {
        position: relative;
        width: 100%;
        margin-bottom: 16px;
    }
    
    .suggestion-wrapper::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to left, rgba(249,250,251,0) 0%, rgba(249,250,251,1) 100%);
        pointer-events: none;
        z-index: 2;
        opacity: 0;
        transition: opacity 0.2s ease;
    }
    
    .suggestion-wrapper.is-scrolled::before {
        opacity: 1;
    }
    
    .suggestion-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to right, rgba(249,250,251,0) 0%, rgba(249,250,251,1) 100%);
        pointer-events: none;
        z-index: 2;
    }

    .suggestion-grid {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding-bottom: 12px;
        padding-right: 40px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .suggestion-grid::-webkit-scrollbar {
        display: none;
    }
    
    .suggestion-grid.is-dragging .suggestion-btn {
        pointer-events: none;
    }

    .suggestion-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        user-select: none;
        -webkit-user-select: none;
    }
    
    .message {
        margin-bottom: 24px;
    }
}

/* Login Modal Styling */
.sustai-auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-primary, #FFFFFF);
    padding: 32px;
    border-radius: 16px;
    border: 3px solid var(--text-primary, #111827);
    box-shadow: 8px 8px 0px var(--text-primary, #111827);
    width: 90%;
    max-width: 400px;
    position: relative;
    font-family: var(--font-sans);
}

.modal-content h2 {
    font-family: var(--font-serif);
    margin-top: 0;
    color: var(--text-primary, #111827);
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

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

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary, #111827);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 1rem;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 2px 2px 0px var(--accent);
}

.btn-submit {
    width: 100%;
    background: var(--accent);
    color: #ffffff;
    border: 1px solid var(--accent);
    padding: 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    margin-top: 8px;
}

.btn-submit:hover {
    transform: translate(-2px, -2px);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.05);
}

.btn-outline {
    width: 100%;
    background: transparent;
    color: var(--text-primary, #111827);
    border: 1px solid var(--border-color, #E5E7EB);
    padding: 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    margin-top: 16px;
}

.btn-outline:hover {
    transform: translate(-2px, -2px);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.05);
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-primary, #111827);
}

#user-profile {
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

#user-profile:hover {
    border-color: var(--text-primary, #111827);
    background: var(--bg-secondary, #F9FAFB);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Sidebar Desktop Toggles */
.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color, #E5E7EB);
    cursor: pointer;
    color: var(--text-secondary, #6B7280);
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: var(--hover-color, #F3F4F6);
    color: var(--text-primary, #111827);
}

@media (min-width: 769px) {
    .sidebar.collapsed {
        margin-left: -260px;
    }

    .sidebar.collapsed ~ .chat-main .floating-sidebar-toggle {
        display: flex;
    }
}

.floating-sidebar-toggle {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    display: none;
    background: var(--bg-primary, #FFFFFF);
}

@media (max-width: 768px) {
    .chat-disclaimer {
        font-size: 0.55rem;
    }
    .chat-empty-state {
        justify-content: center;
        margin-top: 2vh;
        margin-bottom: 0;
        padding: 10px 20px;
    }
    .empty-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 12px;
    }
    .empty-icon svg {
        width: 32px;
        height: 32px;
    }
    .chat-empty-state h2 {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }
    .chat-input-container, .intro-input-container {
        padding: 12px 16px !important;
        padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }

    #chat-form, #intro-form {
        padding: 6px 8px 6px 14px;
        border-radius: 20px;
    }

    #chat-input, #intro-input {
        font-size: 0.95rem;
        padding: 7px 0;
        min-height: 24px;
        line-height: 1.4;
    }

    .attach-btn, .mic-btn {
        width: 36px;
        height: 36px;
        margin-right: 2px;
    }

    #send-btn, #intro-send-btn {
        width: 36px;
        height: 36px;
    }

    .floating-sidebar-toggle, 
    .sidebar.collapsed ~ .chat-main .floating-sidebar-toggle {
        display: none !important;
    }
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 100%; /* Sits exactly on top of the input container */
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, rgba(250, 250, 250, 1) 0%, rgba(250, 250, 250, 0.8) 50%, rgba(250, 250, 250, 0) 100%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 20px;
    pointer-events: none; /* Let clicks pass through the gradient */
    z-index: 10;
}

.scroll-down-btn {
    pointer-events: auto; /* Re-enable clicks for the button */
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    animation: bounce 2s infinite;
}

.scroll-down-btn svg {
    width: 20px;
    height: 20px;
}

.scroll-down-btn:hover {
    background: #f9fafb;
    transform: translateY(2px);
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
    60% {
        transform: translateY(-4px);
    }
}

/* Visibility Helpers */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: block !important;
    }
    .delete-chat-btn {
        display: flex !important;
    }
}

@media (max-height: 600px) and (max-width: 768px) {
    .chat-empty-state {
        justify-content: flex-start;
    }
}

/* Voice Mode Overlay */
.voice-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary, #ffffff);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer; /* iOS Safari fix for div click events */
    -webkit-tap-highlight-color: transparent;
}

.voice-mode-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: var(--text-primary, #111827);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    pointer-events: auto; /* Enable clicks here */
}
.voice-mode-close:hover {
    background: rgba(0,0,0,0.05);
}

.voice-mode-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    padding: 24px;
    pointer-events: none; /* Let clicks pass through to the overlay to reliably trigger interrupt */
}

.voice-visualizer {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

.voice-ball {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s cubic-bezier(0.2, 0, 0, 1), border-color 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 6px solid transparent;
    box-sizing: border-box;
    padding: 12px;
    background-color: var(--bg-primary, #ffffff);
}

.voice-icon {
    width: 60px;
    height: 60px;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .voice-ball {
        width: 140px;
        height: 140px;
    }
    .voice-icon {
        width: 100px;
        height: 100px;
    }
}

.voice-status {
    font-size: 1.25rem;
    color: var(--text-secondary, #4b5563);
    font-weight: 500;
    margin-bottom: 24px;
    height: 30px;
    opacity: 0.8;
}

.voice-transcript {
    font-size: 1.5rem;
    color: var(--text-primary, #111827);
    text-align: center;
    min-height: 80px;
    line-height: 1.4;
    font-family: var(--font-serif);
}

/* Animations for Voice Ball when idle or thinking */
.voice-ball.idle {
    animation: idlePulse 2.5s infinite ease-in-out;
}
.voice-ball.listening {
    border-color: #16a34a; /* Solid, darker green, no glow */
    animation: listeningPulse 2s infinite alternate ease-in-out;
}
@keyframes listeningPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.2); }
}
.voice-ball.thinking {
    border-color: #f59e0b; /* Amber */
    animation: thinkingSpin 1.5s infinite cubic-bezier(0.5, 0, 0.5, 1);
}
.voice-ball.speaking {
    border-color: #34d399; /* Mint Green */
    animation: speakingPulse 1.5s ease-in-out infinite;
}

@keyframes idlePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes thinkingSpin {
    0% { transform: rotate(0deg) scale(1.1); }
    50% { transform: rotate(180deg) scale(0.9); }
    100% { transform: rotate(360deg) scale(1.1); }
}

@keyframes speakingPulse {
    0% { transform: scale(1); border-color: #34d399; }
    50% { transform: scale(1.1); border-color: #059669; }
    100% { transform: scale(1); border-color: #34d399; }
}

.voice-controls {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 24px;
    align-items: center;
    z-index: 1000;
    pointer-events: auto; /* Re-enable clicks since parent has pointer-events: none */
}

.voice-control-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary, #4b5563);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-control-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary, #111827);
    transform: scale(1.05);
}

.voice-control-btn.muted {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.voice-control-btn.muted .icon-on {
    display: none;
}

.voice-control-btn.muted .icon-off {
    display: block !important;
}

@media (max-width: 768px) {
    .voice-controls {
        gap: 16px;
    }
}

@media (min-width: 768px) {
    .voice-ball {
        width: 160px;
        height: 160px;
        padding: 20px;
        border-width: 8px;
    }
}

#agent-connecting-banner {
    width: 100%;
    display: flex;
}

.agent-connecting-card {
    max-width: 650px;
    width: 100%;
    margin: 16px auto 32px auto;
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border: 1.5px solid rgba(16, 185, 129, 0.35);
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: 0 8px 24px -6px rgba(5, 150, 105, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
    display: flex !important;
    align-items: center;
    gap: 18px;
    animation: bannerSlideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 5;
}

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

.agent-connecting-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #10b981, #6ee7b7, #10b981);
    background-size: 200% 100%;
    animation: connectingGradient 2s ease-in-out infinite;
}

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

.connecting-pulse-wrapper {
    position: relative;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.connecting-avatar-ring {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.connecting-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ecfdf5;
    color: #059669;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #10b981;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid #10b981;
    pointer-events: none;
    animation: radarPulse 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.pulse-ring.ring-1 {
    width: 44px;
    height: 44px;
    animation-delay: 0s;
}

.pulse-ring.ring-2 {
    width: 44px;
    height: 44px;
    animation-delay: 0.9s;
}

@keyframes radarPulse {
    0% {
        width: 42px;
        height: 42px;
        opacity: 0.9;
    }
    100% {
        width: 72px;
        height: 72px;
        opacity: 0;
    }
}

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

.connecting-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

.connecting-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: dotPulse 1.6s infinite;
}

@keyframes dotPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.connecting-subtitle {
    font-size: 0.88rem;
    color: #4b5563;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.connecting-wave {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 14px;
}

.wave-bar {
    width: 3.5px;
    height: 100%;
    background: #10b981;
    border-radius: 2px;
    animation: waveBars 1.2s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0.0s; }
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }
.wave-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes waveBars {
    0%, 100% {
        transform: scaleY(0.3);
        opacity: 0.4;
    }
    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

/* Connected State */
.agent-connecting-card.connected {
    background: #ecfdf5;
    border-color: #10b981;
    padding: 16px 20px;
    transition: all 0.4s ease;
}

.agent-connecting-card.connected::before {
    background: #10b981;
    animation: none;
}

.connected-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #10b981;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.connecting-title.connected {
    color: #065f46;
}

.agent-connecting-card.connected .connecting-subtitle {
    color: #047857;
    margin: 0;
    font-weight: 500;
}

/* Human Agent Message Styling (Matilde Azevedo) */
.avatar.agent-avatar {
    padding: 0 !important;
    overflow: hidden !important;
    border: 2px solid #10b981 !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25) !important;
    background: #ffffff !important;
    width: 36px !important;
    height: 36px !important;
}

.avatar.agent-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 50% !important;
}

.agent-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding: 3px 10px;
    background: #ecfdf5;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 20px;
    font-size: 0.78rem;
    line-height: 1.4;
}

.agent-header-badge .agent-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

.agent-header-badge .agent-name {
    font-weight: 700;
    color: #065f46;
}

.agent-header-badge .agent-role {
    font-weight: 500;
    color: #047857;
    font-size: 0.74rem;
}

