* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #eef0f1;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    max-width: 800px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-radius: 20px;
    /* box-shadow: 0 0 40px rgba(0, 0, 0, 0.06); */
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background-color: #ffffff;
    border-radius: 20px 20px 0 0;
}

.chat-header .material-symbols-outlined {
    font-size: 28px;
    color: #3b82f6;
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    flex: 1;
}

.debug-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.debug-toggle:hover {
    background-color: #e5e7eb;
    color: #3b82f6;
}

.debug-toggle .material-symbols-outlined {
    font-size: 20px;
}

.stop-button {
    height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    border: none;
    background-color: #fee2e2;
    color: #dc2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 8px;
}

.stop-button:hover {
    background-color: #fecaca;
    transform: scale(1.02);
}

.stop-button .material-symbols-outlined {
    font-size: 18px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 75%;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot,
.message.admin {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: auto;
}

.message.bot .message-avatar {
    background-color: #eff6ff;
    color: #3b82f6;
}

.message.admin .message-avatar {
    background-color: #fef3c7;
    color: #d97706;
}

.message.user .message-avatar {
    background-color: #f3f4f6;
    color: #6b7280;
}

.message-avatar .material-symbols-outlined {
    font-size: 20px;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.bot .message-bubble {
    background-color: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.message.admin .message-bubble {
    background-color: #fef3c7;
    color: #78350f;
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background-color: #3b82f6;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-media {
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
    min-width: 220px;
}

.message-media img,
.message-media video {
    max-width: 100%;
    height: auto;
    display: block;
}

.message-media audio {
    width: 100%;
}

.template-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.template-button {
    padding: 10px 16px;
    background-color: #dbdfe6;
    border: none;
    border-radius: 6px;
    color: #1f2937;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.template-button:hover {
    background-color: #b1b5ba;
}

.template-button:active {
    background-color: #9ca3af;
    transform: scale(0.98);
}

.typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.typing-indicator .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #eff6ff;
    color: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-dots {
    background-color: #f3f4f6;
    padding: 16px 20px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 6px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.system-message {
    align-self: center;
    padding: 8px 16px;
    background-color: #fef3c7;
    color: #92400e;
    border-radius: 20px;
    font-size: 14px;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 80%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.system-message.error {
    background-color: #fee2e2;
    color: #991b1b;
}

.system-message.complete {
    background-color: #d1fae5;
    color: #065f46;
}

.system-message.messenger-alert {
    background-color: #bcdef5;
    padding: 8px;
    border-radius: 12px;
    color: #0369a1;
}

.input-container {
    border-top: 1px solid #e5e7eb;
    background-color: #ffffff;
    padding: 16px 24px;
}

.collect-container {
    margin-bottom: 16px;
}

.collect-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collect-input,
.collect-select {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid #3b82f6;
    border-radius: 24px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #eff6ff;
}

.collect-input:focus,
.collect-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.collect-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.collect-submit {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background-color: #3b82f6;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    font-weight: 600;
}

.collect-submit:hover:not(:disabled) {
    background-color: #2563eb;
    transform: scale(1.05);
}

.collect-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.collect-submit:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
    opacity: 0.6;
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 0;
    transition: min-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-replies:empty {
    margin-bottom: 0;
}

.quick-reply-button {
    padding: 10px 18px;
    background-color: #ffffff;
    border: 1.5px solid #3b82f6;
    color: #3b82f6;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', sans-serif;
}

.quick-reply-button:hover {
    background-color: #eff6ff;
    transform: translateY(-1px);
}

.quick-reply-button:active {
    transform: translateY(0);
}

.quick-replies-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 48px;
    margin-bottom: 8px;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 24px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#messageInput:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#messageInput:disabled {
    background-color: #f9fafb;
    cursor: not-allowed;
    opacity: 0.6;
}

#sendButton {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background-color: #3b82f6;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    background-color: #2563eb;
    transform: scale(1.05);
}

#sendButton:active:not(:disabled) {
    transform: scale(0.98);
}

#sendButton:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
    opacity: 0.6;
}

#sendButton .material-symbols-outlined {
    font-size: 20px;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background-color: #1f2937;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.debug-panel.open {
    right: 0;
}

.debug-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid #374151;
    background-color: #111827;
}

.debug-header .material-symbols-outlined {
    font-size: 24px;
    color: #60a5fa;
}

.debug-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #f3f4f6;
    flex: 1;
}

.debug-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background-color: transparent;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.debug-close:hover {
    background-color: #374151;
    color: #f3f4f6;
}

.debug-close .material-symbols-outlined {
    font-size: 20px;
}

.debug-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #d1d5db;
    line-height: 1.6;
    margin: 0;
}

.debug-content::-webkit-scrollbar {
    width: 6px;
}

.debug-content::-webkit-scrollbar-track {
    background: #111827;
}

.debug-content::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

.debug-content::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Debug Node Info */
.debug-node-info {
    align-self: flex-start;
    font-size: 11px;
    color: #6b7280;
    background-color: #f9fafb;
    padding: 4px 10px;
    border-radius: 10px;
    margin-left: 48px;
    margin-bottom: 4px;
    font-family: 'Courier New', monospace;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.debug-node-info-user {
    align-self: flex-end;
    margin-left: 0;
    margin-right: 48px;
}

/* Quick reply wrapper for button with debug info */
.quick-reply-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

/* Debug info for buttons */
.debug-node-info-button {
    font-size: 11px;
    color: #6b7280;
    background-color: #f9fafb;
    padding: 2px 8px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    margin-left: 4px;
    margin-bottom: 6px;
}
