/* User message bubble with pointy right tail */
.user-message-bubble {
    position: relative;
    background: #2563eb;
    color: #fff;
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-right: 0.75rem;
    width: 100%;
    word-break: break-word;
}

.user-message-bubble::after {
    content: "";
    position: absolute;
    right: -12px;
    bottom: 12px;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 0 solid transparent;
    border-left: 12px solid #2563eb;
}

/* Final Chatbot CSS - Improved Dark Theme with Better Layout */

/* CSS Variables - Dark Theme with improved contrast */
:root {
    --chatbot-primary: #2563eb;
    --chatbot-primary-hover: #1d4ed8;
    --chatbot-bg: #1e293b;
    --chatbot-surface: #334155;
    --chatbot-border: #475569;
    --chatbot-text: #f1f5f9;
    --chatbot-text-primary: #f1f5f9;
    --chatbot-text-secondary: #cbd5e1;
    --chatbot-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --chatbot-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --chatbot-radius: 0.75rem;
    --chatbot-radius-sm: 0.375rem;
    --chatbot-user-bg: #1e40af;
    --chatbot-ai-bg: #475569;
    --chatbot-success: #10b981;
    --chatbot-error: #ef4444;
    --chatbot-input-bg: #0f172a;
    --chatbot-message-spacing: 16px;
}

/* Base styles */
.final-chatbot-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--chatbot-text);
    position: fixed;
    z-index: 10000;
    bottom: 20px;
    right: 20px;
}

.final-chatbot-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Toggle Button */
.chatbot-toggle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--chatbot-shadow-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 10001;
}

.chatbot-toggle:hover {
    background: var(--chatbot-primary-hover);
    transform: scale(1.05);
}

.chatbot-toggle .animate-ping {
    position: absolute;
    inset: 0;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {

    75%,
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Utility classes */
.w-13 {
    width: 3.25rem;
}

.h-13 {
    height: 3.25rem;
}

.absolute {
    position: absolute;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.rounded-full {
    border-radius: 9999px;
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Widget Styles */
.chatbot-widget {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Widget Header */
.chatbot-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--chatbot-primary);
    color: white;
    border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 18px;
}

.chatbot-title {
    flex: 1;
}

.chatbot-title h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chatbot-controls {
    display: flex;
    gap: 8px;
}

.chatbot-controls button {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--chatbot-radius-sm);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 12px;
}

.chatbot-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    padding: 20px 8px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: var(--chatbot-surface);
    max-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-text-secondary);
}

/* Message Styles - User right, AI left */
.message {
    display: flex;
    gap: 12px;
    width: 100%;
    margin: 0;
    align-items: flex-start;
}

.user-message {
    flex-direction: row-reverse;
    justify-content: flex-start;
    padding-right: 8px;
}

.ai-message {
    flex-direction: row;
    justify-content: flex-start;
}

.message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 2px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-message .avatar {
    display: none;
    /* Hide user avatar */
}

.ai-message .avatar {
    background: var(--chatbot-text-secondary);
    color: white;
}

.message .content {
    flex: 0 1 auto;
    max-width: 80%;
    width: auto;
}

.message .text {
    background: var(--chatbot-bg);
    padding: 12px 16px;
    border-radius: var(--chatbot-radius);
    border: 1px solid var(--chatbot-border);
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
    color: var(--chatbot-text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.user-message .text {
    background: var(--chatbot-user-bg);
    border-color: var(--chatbot-primary);
    color: var(--chatbot-text-primary);
    border-radius: var(--chatbot-radius);
    border-bottom-right-radius: 4px;
    /* Add slight edge on the right */
    position: relative;
}

.user-message .text::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -10px;
    width: 0;
    height: 0;
    border-left: 20px solid var(--chatbot-user-bg);
    border-bottom: 20px solid transparent;
}

.ai-message .text {
    background: var(--chatbot-ai-bg);
    color: var(--chatbot-text-primary);
}

/* Normalize paragraph spacing in message content */
.message .text p,
.fullpage-message .text p {
    margin: 0;
    padding: 0;
    display: inline;
}

.message .text p+p,
.fullpage-message .text p+p {
    margin-top: 0.5rem;
    display: block;
}

/* Ensure proper text flow and list containment */
.message .text,
.fullpage-message .text {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.message .text>*:first-child,
.fullpage-message .text>*:first-child {
    margin-top: 0;
}

.message .text>*:last-child,
.fullpage-message .text>*:last-child {
    margin-bottom: 0;
}

.message .content.error .text {
    background: #7f1d1d;
    border-color: var(--chatbot-error);
    color: #fca5a5;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 12px;
    background: transparent;
    margin: 0;
}

.typing-indicator .avatar {
    width: 32px;
    height: 32px;
    background: var(--chatbot-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.typing-indicator .dots {
    display: flex;
    gap: 4px;
    margin-right: 8px;
}

.typing-indicator .dots span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator .dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator .dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-indicator .dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    40% {
        opacity: 1;
        transform: scale(1);
    }
}

.typing-indicator .typing-text {
    font-size: 14px;
    color: var(--chatbot-text-secondary);
    font-weight: 400;
}

/* Input Container - Fixed positioning removed */
.chatbot-input {
    padding: 20px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chatbot-input input {
    flex: 1;
    padding: 16px 20px;
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    background: var(--chatbot-surface);
    color: var(--chatbot-text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    min-height: 48px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chatbot-input input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 2px 8px rgba(0, 0, 0, 0.15);
    background: var(--chatbot-bg);
}

.chatbot-input input::placeholder {
    color: var(--chatbot-text-secondary);
}

.chatbot-input button {
    width: 48px;
    height: 48px;
    background: var(--chatbot-primary);
    border: none;
    border-radius: var(--chatbot-radius);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.chatbot-input button:hover:not(:disabled) {
    background: var(--chatbot-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chatbot-input button:disabled {
    background: var(--chatbot-text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

/* Full Page Mode - ENHANCED */
.chatbot-fullpage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--chatbot-surface);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
    overflow: hidden;
    /* Prevent body scroll */
}

/* Prevent body scroll when fullpage is open */
body:has(.chatbot-fullpage[style*="display: flex"]) {
    overflow: hidden;
    height: 100vh;
}

/* Also ensure toggle button is hidden with high specificity */
.final-chatbot-wrapper:has(.chatbot-fullpage[style*="display: flex"]) .chatbot-toggle {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fullpage-header {
    display: flex;
    align-items: center;
    padding: 24px 32px;
    background: var(--chatbot-primary);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.fullpage-title {
    flex: 1;
}

.fullpage-title h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: white;
}

.fullpage-controls {
    display: flex;
    gap: 12px;
}

.fullpage-controls button {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--chatbot-radius-sm);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 14px;
}

.fullpage-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fullpage-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100vw;
    max-width: none;
    margin: 0;
    min-height: 0;
    background: var(--chatbot-surface);
}

.fullpage-messages {
    flex: 1;
    width: 100%;
    padding: 1rem 0.5rem;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.fullpage-input {
    padding: 1rem 1.25rem;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
    width: 100%;
}

/* Edge-aligned message layout */
.fullpage-message {
    display: flex;
    width: 100%;
    margin: 0;
    align-items: flex-start;
    padding: 0 0.5rem;
}

/* User messages - Right aligned */
.fullpage-message.user-message {
    justify-content: right;
    padding-right: 1rem;
}

/* AI messages - Left aligned */
.fullpage-message.ai-message {
    justify-content: flex-start;
    padding-left: 0.25rem;
}

/* Message container with avatar and content */
.fullpage-message .message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 85%;
    min-width: 200px;
}

/* User message wrapper - No avatar, content only */
.fullpage-message.user-message .message-wrapper {
    flex-direction: row;
}

/* AI message wrapper - Avatar on left, content on right */
.fullpage-message.ai-message .message-wrapper {
    flex-direction: row;
}

.fullpage-message .avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.fullpage-message.user-message .avatar {
    display: none;
    /* Hide user avatar in fullpage */
}

.fullpage-message.ai-message .avatar {
    background: var(--chatbot-text-secondary);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.fullpage-message .content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fullpage-message .text {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: var(--chatbot-text-primary);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 100%;
    margin: 0;
}

.fullpage-message.user-message .text {
    background: var(--chatbot-user-bg);
    border: 1px solid var(--chatbot-primary);
    border-radius: 1.25rem;
    border-bottom-right-radius: 0.5rem;
    /* Add slight edge on the right */
    color: var(--chatbot-text-primary);
    position: relative;
}

.fullpage-message.user-message .text::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -10px;
    width: 0;
    height: 0;
    border-left: 20px solid var(--chatbot-user-bg);
    border-bottom: 20px solid transparent;
}

.fullpage-message.ai-message .text {
    background: var(--chatbot-ai-bg);
    border: 1px solid var(--chatbot-border);
    border-bottom-left-radius: 0.5rem;
    color: var(--chatbot-text-primary);
}

.fullpage-message .content.error .text {
    background: #7f1d1d;
    border-color: var(--chatbot-error);
    color: #fca5a5;
}

/* Full page typing indicator */
.fullpage-typing {
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 12px;
    background: transparent;
}

.fullpage-typing .typing-dots {
    display: flex;
    gap: 6px;
}

.fullpage-typing .typing-dots span {
    width: 10px;
    height: 10px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.fullpage-typing .typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.fullpage-typing .typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.fullpage-typing .typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

.fullpage-typing span {
    font-size: 14px;
    color: var(--chatbot-text-secondary);
    font-style: italic;
}

/* Full page input - Integrated properly */
.fullpage-input {
    padding: 24px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
    width: 100%;
}

.fullpage-input .input-group {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    max-width: 100%;
}

.fullpage-input textarea {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 1px solid var(--chatbot-border);
    border-radius: 1.5rem;
    background: var(--chatbot-surface);
    color: var(--chatbot-text-primary);
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    min-height: 3rem;
    max-height: 7.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fullpage-input textarea:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 2px 12px rgba(0, 0, 0, 0.15);
    background: var(--chatbot-bg);
    transform: translateY(-1px);
}

.fullpage-input textarea::placeholder {
    color: var(--chatbot-text-secondary);
}

.fullpage-input button {
    min-height: 3rem;
    min-width: 3rem;
    padding: 0 1.25rem;
    background: var(--chatbot-primary);
    border: none;
    border-radius: 1.5rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.fullpage-input button:hover:not(:disabled) {
    background: var(--chatbot-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

.fullpage-input button:active {
    transform: translateY(0);
}

.fullpage-input button:disabled {
    background: var(--chatbot-text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.fullpage-input button i {
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 480px) {
    .final-chatbot-wrapper {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .chatbot-widget {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        bottom: 70px;
        right: 0;
        left: 0;
        margin: 0 auto;
        position: relative;
    }

    .fullpage-content,
    .fullpage-messages,
    .fullpage-input {
        padding: 16px;
    }

    .fullpage-header {
        padding: 16px 20px;
    }

    .fullpage-input button span {
        display: none;
    }

    .chatbot-messages {
        max-height: calc(70vh - 200px);
    }
}

/* Markdown content styling */
.message .text code,
.fullpage-message .text code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.message .text pre,
.fullpage-message .text pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message .text pre code,
.fullpage-message .text pre code {
    background: none;
    padding: 0;
}

.message .text ul,
.message .text ol,
.fullpage-message .text ul,
.fullpage-message .text ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
    list-style-position: outside;
}

.message .text ul,
.fullpage-message .text ul {
    list-style-type: disc;
}

.message .text ol,
.fullpage-message .text ol {
    list-style-type: decimal;
}

.message .text li,
.fullpage-message .text li {
    margin: 0.25rem 0;
    line-height: 1.5;
    display: list-item;
    word-wrap: break-word;
}

.message .text li::marker,
.fullpage-message .text li::marker {
    color: var(--chatbot-text-secondary);
}

.message .text strong,
.fullpage-message .text strong {
    font-weight: 600;
}

.message .text em,
.fullpage-message .text em {
    font-style: italic;
}

/* Focus states for accessibility */
.chatbot-toggle:focus,
.chatbot-controls button:focus,
.fullpage-controls button:focus,
.chatbot-input button:focus,
.fullpage-input button:focus {
    outline: 2px solid rgba(37, 99, 235, 0.5);
    outline-offset: 2px;
}

.chatbot-input input:focus,
.fullpage-input textarea:focus {
    outline: none;
}

/* Loading states */
.chatbot-input button.loading,
.fullpage-input button.loading {
    pointer-events: none;
}

.chatbot-input button.loading i,
.fullpage-input button.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --chatbot-border: #000000;
        --chatbot-text: #000000;
        --chatbot-bg: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .chatbot-toggle,
    .chatbot-input button,
    .fullpage-input button,
    .message,
    .chatbot-widget,
    .chatbot-fullpage {
        animation: none;
        transition: none;
    }

    .typing-indicator .dots span,
    .fullpage-typing .typing-dots span {
        animation: none;
        opacity: 1;
    }
}

/* ========== RESPONSIVE DESIGN - MOBILE FIRST ========== */

/* Mobile devices (portrait) - 320px to 480px */
@media (max-width: 480px) {
    .chatbot-widget {
        width: calc(100vw - 1rem);
        height: calc(100vh - 5rem);
        bottom: 0.5rem;
        right: 0.5rem;
        max-height: none;
        border-radius: 1rem;
        border: 2px solid var(--chatbot-border);
    }

    .chatbot-header {
        padding: 0.875rem 1rem;
    }

    .chatbot-header h3 {
        font-size: 1rem;
        font-weight: 600;
    }

    .chatbot-controls button {
        min-width: 2.75rem;
        min-height: 2.75rem;
        font-size: 0.75rem;
    }

    .chatbot-messages {
        padding: 0.75rem 0.5rem;
        gap: 0.875rem;
    }

    .user-message {
        flex-direction: row-reverse;
        justify-content: flex-start;
        padding-right: 0.5rem;
    }

    .ai-message {
        flex-direction: row;
        justify-content: flex-start;
        padding-left: 0.25rem;
    }

    .message .content {
        flex: 0 1 auto;
        max-width: 85%;
        width: auto;
    }

    .message .avatar {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }

    .message .text {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
        border-radius: 1rem;
        line-height: 1.5;
        min-height: auto;
        word-break: break-word;
        hyphens: auto;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }

    .user-message .text {
        border-bottom-right-radius: 4px;
        font-weight: 500;
    }

    .ai-message .text {
        background: var(--chatbot-ai-bg);
        border: 1px solid var(--chatbot-border);
    }

    .user-message .text::after {
        right: -5px;
        border-left: 10px solid var(--chatbot-user-bg);
        border-bottom: 10px solid transparent;
    }

    .chatbot-input {
        padding: 1rem;
    }

    .chatbot-input input {
        padding: 0.875rem 1rem;
        min-height: 2.75rem;
        font-size: clamp(0.9rem, 4vw, 1rem);
        border-radius: 1.5rem;
    }

    .chatbot-input button {
        min-width: 2.75rem;
        min-height: 2.75rem;
        font-size: 1rem;
        border-radius: 1.5rem;
    }

    /* Fullscreen mobile adjustments */
    .fullpage-header {
        padding: 1rem 1.25rem;
    }

    .fullpage-title h3 {
        font-size: clamp(1.125rem, 5vw, 1.25rem);
    }

    .fullpage-controls button {
        min-width: 2.75rem;
        min-height: 2.75rem;
        font-size: 1rem;
    }

    .fullpage-content {
        height: calc(100vh - 4.5rem);
    }

    .fullpage-messages {
        padding: 1rem 0.25rem;
        gap: 1.25rem;
    }

    .fullpage-message {
        padding: 0 0.25rem;
    }

    .fullpage-message.user-message {
        padding-right: 0.125rem;
    }

    .fullpage-message.ai-message {
        padding-left: 0.125rem;
    }

    .fullpage-message .message-wrapper {
        gap: 0.5rem;
        max-width: 95%;
        min-width: 150px;
    }

    .fullpage-message .avatar {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
        margin-top: 0.125rem;
    }

    .fullpage-message .text {
        padding: 1rem 1.25rem;
        font-size: clamp(0.95rem, 3.8vw, 1.05rem);
        border-radius: 1.25rem;
        line-height: 1.6;
        word-break: break-word;
        hyphens: auto;
    }

    .fullpage-message.user-message .text {
        border-bottom-right-radius: 8px;
    }

    .fullpage-message.user-message .text::after {
        right: -8px;
        border-left: 16px solid var(--chatbot-user-bg);
        border-bottom: 16px solid transparent;
    }

    .fullpage-message.ai-message .text {
        border-bottom-left-radius: 8px;
    }

    .fullpage-input {
        padding: 1rem;
    }

    .fullpage-input .input-group {
        gap: 0.5rem;
    }

    .fullpage-input textarea {
        padding: 1rem;
        min-height: 2.75rem;
        max-height: 6rem;
        font-size: clamp(0.9rem, 4vw, 1rem);
        border-radius: 1.25rem;
    }

    .fullpage-input button {
        min-height: 2.75rem;
        min-width: 2.75rem;
        padding: 0 1rem;
        font-size: 1rem;
        border-radius: 1.25rem;
    }

    .fullpage-input button span {
        display: none;
    }

    .typing-indicator {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .typing-indicator .avatar {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.625rem;
    }

    .typing-indicator .typing-text {
        font-size: clamp(0.75rem, 3.5vw, 0.875rem);
    }
}

/* Tablet devices - 481px to 768px */
@media (min-width: 481px) and (max-width: 768px) {
    .chatbot-widget {
        width: clamp(380px, 50vw, 420px);
        height: clamp(500px, 70vh, 600px);
    }

    .fullpage-content {
        max-width: none;
        width: 100vw;
    }

    .fullpage-messages {
        padding: 1.5rem 0.75rem;
        gap: 1.5rem;
    }

    .fullpage-message {
        padding: 0 0.5rem;
    }

    .fullpage-message.user-message {
        padding-right: 0.25rem;
    }

    .fullpage-message.ai-message {
        padding-left: 0.25rem;
    }

    .fullpage-message .message-wrapper {
        max-width: 80%;
        gap: 1rem;
    }

    .fullpage-message .avatar {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .fullpage-message .text {
        padding: 1rem 1.25rem;
        font-size: clamp(0.9rem, 2vw, 1rem);
    }

    .fullpage-input {
        padding: 1.25rem;
    }

    .fullpage-input textarea {
        font-size: clamp(0.95rem, 2vw, 1rem);
        padding: 1rem 1.25rem;
    }

    .fullpage-input button {
        font-size: clamp(0.95rem, 2vw, 1rem);
        padding: 0 1.25rem;
    }
}

/* Desktop responsive adjustments - 1200px+ */
@media (min-width: 1200px) {
    .fullpage-content {
        max-width: none;
        width: 100vw;
    }

    .fullpage-messages {
        padding: 2rem 1rem;
        gap: 2rem;
    }

    .fullpage-message {
        padding: 0 1rem;
    }

    .fullpage-message.user-message {
        padding-right: 0.5rem;
    }

    .fullpage-message.ai-message {
        padding-left: 0.5rem;
    }

    .fullpage-message .message-wrapper {
        max-width: 70%;
        gap: 0.25rem;
    }

    .fullpage-message .avatar {
        width: 3rem;
        height: 3rem;
        font-size: 1.125rem;
    }

    .fullpage-message .text {
        padding: 1.25rem 1.5rem;
        font-size: 1rem;
        line-height: 1.7;
    }

    .fullpage-input {
        padding: 1.5rem 2rem;
    }

    .fullpage-input .input-group {
        gap: 1rem;
    }

    .fullpage-input textarea {
        font-size: 1rem;
        padding: 1.25rem 1.5rem;
        min-height: 3.5rem;
    }

    .fullpage-input button {
        font-size: 1rem;
        padding: 0 1.5rem;
        min-height: 3.5rem;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    .chatbot-widget {
        height: calc(100vh - 2rem);
        bottom: 1rem;
    }

    .chatbot-messages {
        max-height: calc(100vh - 12rem);
    }

    .fullpage-messages {
        padding: 1rem 0.5rem;
    }

    .fullpage-input {
        padding: 0.75rem 1rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .chatbot-toggle {
        width: 3.75rem;
        height: 3.75rem;
        font-size: 1.5rem;
    }

    .chatbot-controls button,
    .fullpage-controls button {
        min-height: 2.75rem;
        min-width: 2.75rem;
    }

    .chatbot-input button,
    .fullpage-input button {
        min-height: 3rem;
        min-width: 3rem;
    }

    /* Increase touch targets */
    .message .text,
    .fullpage-message .text {
        min-height: 2.75rem;
        display: flex;
        align-items: center;
    }

    /* Improve scrolling on touch devices */
    .chatbot-messages,
    .fullpage-messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Better tap highlights */
    .chatbot-input button,
    .fullpage-input button,
    .chatbot-toggle,
    .chatbot-controls button,
    .fullpage-controls button {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.3);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    .fullpage-message .avatar,
    .message .avatar {
        border-width: 1px;
    }

    .fullpage-message .text,
    .message .text {
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
    }
}