/* 
 * FlowDent Modern Chatbot UI
 * A stunning, premium chatbot interface with gradient meshes, 
 * smooth animations, and delightful micro-interactions
 */

/* ==================== Design Tokens ==================== */
:root {
    /* Enhanced Color Palette */
    --modern-primary-50: #eff6ff;
    --modern-primary-100: #dbeafe;
    --modern-primary-200: #bfdbfe;
    --modern-primary-500: #3b82f6;
    --modern-primary-600: #2563eb;
    --modern-primary-700: #1d4ed8;
    --modern-primary-900: #1e3a8a;

    /* Accent Colors */
    --modern-accent-500: #8b5cf6;
    --modern-accent-600: #7c3aed;

    /* Semantic Colors */
    --modern-success: #10b981;
    --modern-warning: #f59e0b;
    --modern-error: #ef4444;

    /* Neutral Palette */
    --modern-gray-50: #f9fafb;
    --modern-gray-100: #f3f4f6;
    --modern-gray-200: #e5e7eb;
    --modern-gray-300: #d1d5db;
    --modern-gray-500: #6b7280;
    --modern-gray-700: #374151;
    --modern-gray-900: #111827;

    /* Shadow System */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    --shadow-colored-sm: 0 4px 12px rgb(59 130 246 / 0.15);
    --shadow-colored-md: 0 8px 24px rgb(59 130 246 / 0.25);
    --shadow-colored-lg: 0 12px 32px rgb(59 130 246 / 0.35);

    /* Animation Durations */
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Easing Functions */
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
}

/* ==================== Base Widget Container ==================== */
#flowdent-chat-widget.flowdent-modern {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== Floating Action Button (FAB) ==================== */
.flowdent-modern .flowdent-fab {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--modern-primary-600) 0%, var(--modern-accent-600) 100%);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-colored-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-normal) var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

.flowdent-modern .flowdent-fab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.flowdent-modern .flowdent-fab:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: var(--shadow-colored-lg);
}

.flowdent-modern .flowdent-fab:hover::before {
    opacity: 1;
}

.flowdent-modern .flowdent-fab:active {
    transform: scale(0.95) translateY(0);
}

/* Pulse animation for FAB */
@keyframes fab-pulse {

    0%,
    100% {
        box-shadow: var(--shadow-colored-md);
    }

    50% {
        box-shadow: var(--shadow-colored-lg), 0 0 0 8px rgba(59, 130, 246, 0.1);
    }
}

.flowdent-modern .flowdent-fab.pulse {
    animation: fab-pulse 2s ease-in-out infinite;
}

/* ==================== Main Chat Panel ==================== */
.flowdent-modern .flowdent-chat-panel {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 750px;
    max-height: calc(100vh - 80px);
    flex-direction: column;
    background: #ffffff;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
    animation: panel-slide-up var(--duration-slow) var(--ease-bounce);
}

.flowdent-modern.flowdent-open .flowdent-chat-panel {
    display: flex;
}

@keyframes panel-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==================== Gradient Mesh Header ==================== */
.flowdent-modern .flowdent-header {
    position: relative;
    padding: 16px 20px;
    min-height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradient-shift 8s ease infinite;
    overflow: hidden;
    display: flex;
    align-items: center;
}

@keyframes gradient-shift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* Animated mesh overlay */
.flowdent-modern .flowdent-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    animation: mesh-float 15s ease-in-out infinite;
}

@keyframes mesh-float {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(5%, -5%) rotate(120deg);
    }

    66% {
        transform: translate(-5%, 5%) rotate(240deg);
    }
}

.flowdent-modern .flowdent-header-content {
    position: relative;
    z-index: 1;
    color: white;
}

.flowdent-modern .flowdent-header-greeting {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.95;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.flowdent-modern .flowdent-header-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.3px;
    word-wrap: break-word;
    max-width: 280px;
}

.flowdent-modern .flowdent-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
    z-index: 2;
}

.flowdent-modern .flowdent-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ==================== Messages Area ==================== */
.flowdent-modern .flowdent-messages {
    flex: 1 1 auto;
    min-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 20px;
    background: linear-gradient(to bottom, var(--modern-gray-50) 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom scrollbar */
.flowdent-modern .flowdent-messages::-webkit-scrollbar {
    width: 6px;
}

.flowdent-modern .flowdent-messages::-webkit-scrollbar-track {
    background: transparent;
}

.flowdent-modern .flowdent-messages::-webkit-scrollbar-thumb {
    background: var(--modern-gray-300);
    border-radius: var(--radius-full);
}

.flowdent-modern .flowdent-messages::-webkit-scrollbar-thumb:hover {
    background: var(--modern-gray-500);
}

/* ==================== Message Bubbles ==================== */
.flowdent-modern .flowdent-message {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    animation: message-fade-in var(--duration-normal) var(--ease-smooth);
    animation-fill-mode: both;
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for sequential messages */
.flowdent-modern .flowdent-message:nth-child(1) {
    animation-delay: 0ms;
}

.flowdent-modern .flowdent-message:nth-child(2) {
    animation-delay: 100ms;
}

.flowdent-modern .flowdent-message:nth-child(3) {
    animation-delay: 200ms;
}

.flowdent-modern .flowdent-message:nth-child(4) {
    animation-delay: 300ms;
}

.flowdent-modern .flowdent-message:nth-child(5) {
    animation-delay: 400ms;
}

.flowdent-modern .flowdent-message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

/* Avatar with gradient ring */
.flowdent-modern .flowdent-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    position: relative;
    padding: 2px;
    background: linear-gradient(135deg, var(--modern-primary-500), var(--modern-accent-500));
    animation: avatar-appear var(--duration-normal) var(--ease-bounce);
    overflow: hidden;
}

@keyframes avatar-appear {
    from {
        opacity: 0;
        transform: scale(0);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.flowdent-modern .flowdent-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--modern-primary-400), var(--modern-primary-600));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
}

.flowdent-modern .flowdent-message.user .flowdent-avatar-inner {
    background: linear-gradient(135deg, var(--modern-gray-400), var(--modern-gray-600));
}

.flowdent-modern .flowdent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Message bubble with tail */
.flowdent-modern .flowdent-bubble {
    position: relative;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    max-width: 85%;
    background: white;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--modern-gray-200);
    transition: all var(--duration-fast) var(--ease-smooth);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.flowdent-modern .flowdent-bubble:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Bubble tail */
.flowdent-modern .flowdent-bubble::before {
    content: '';
    position: absolute;
    bottom: 8px;
    left: -6px;
    width: 12px;
    height: 12px;
    background: white;
    border-left: 1px solid var(--modern-gray-200);
    border-bottom: 1px solid var(--modern-gray-200);
    transform: rotate(45deg);
}

.flowdent-modern .flowdent-message.user .flowdent-bubble {
    background: linear-gradient(135deg, var(--modern-primary-500), var(--modern-primary-600));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-colored-sm);
}

.flowdent-modern .flowdent-message.user .flowdent-bubble:hover {
    box-shadow: var(--shadow-colored-md);
}

.flowdent-modern .flowdent-message.user .flowdent-bubble::before {
    left: auto;
    right: -6px;
    background: var(--modern-primary-500);
    border-color: transparent;
    border-right: 1px solid var(--modern-primary-600);
    border-bottom: 1px solid var(--modern-primary-600);
}

.flowdent-modern .flowdent-bubble-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* ==================== Enhanced Typing Indicator ==================== */
.flowdent-modern .flowdent-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.flowdent-modern .flowdent-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--modern-primary-500);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.flowdent-modern .flowdent-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.flowdent-modern .flowdent-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.flowdent-modern .flowdent-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }

    30% {
        transform: translateY(-8px) scale(1.1);
        opacity: 1;
    }
}

/* ==================== Option Cards with Hover Effects ==================== */
.flowdent-modern .flowdent-options {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--modern-gray-50);
    border-top: 1px solid var(--modern-gray-200);
}

/* Custom scrollbar for options */
.flowdent-modern .flowdent-options::-webkit-scrollbar {
    width: 8px;
}

.flowdent-modern .flowdent-options::-webkit-scrollbar-track {
    background: var(--modern-gray-200);
    border-radius: 4px;
}

.flowdent-modern .flowdent-options::-webkit-scrollbar-thumb {
    background: var(--modern-primary-500);
    border-radius: 4px;
}

.flowdent-modern .flowdent-options::-webkit-scrollbar-thumb:hover {
    background: var(--modern-primary-600);
}

.flowdent-modern .flowdent-option-card {
    position: relative;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    background: white;
    border: 2px solid var(--modern-gray-200);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    overflow: hidden;
    flex-shrink: 0;
}

/* Ripple effect container */
.flowdent-modern .flowdent-option-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: var(--radius-full);
    background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width var(--duration-slow) var(--ease-smooth), height var(--duration-slow) var(--ease-smooth);
}

.flowdent-modern .flowdent-option-card:hover {
    border-color: var(--modern-primary-500);
    box-shadow: var(--shadow-colored-sm);
    transform: translateY(-2px) scale(1.01);
}

.flowdent-modern .flowdent-option-card:hover::before {
    width: 300px;
    height: 300px;
}

.flowdent-modern .flowdent-option-card:active {
    transform: translateY(0) scale(0.98);
}

.flowdent-modern .flowdent-option-card.selected {
    border-color: var(--modern-primary-500);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(124, 58, 237, 0.05) 100%);
    box-shadow: var(--shadow-colored-sm);
}

.flowdent-modern .flowdent-option-text {
    position: relative;
    z-index: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--modern-gray-900);
    margin: 0;
    line-height: 1.4;
}

/* ==================== Modern Loading States ==================== */
.flowdent-modern .flowdent-skeleton {
    background: linear-gradient(90deg, var(--modern-gray-200) 25%, var(--modern-gray-100) 50%, var(--modern-gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-lg);
    height: 48px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* ==================== Input Area ==================== */
.flowdent-modern .flowdent-input-wrapper {
    padding: 16px 20px 20px;
    background: white;
    border-top: 1px solid var(--modern-gray-200);
}

.flowdent-modern .flowdent-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.flowdent-modern .flowdent-input {
    flex: 1;
    padding: 14px 18px;
    border-radius: var(--radius-xl);
    border: 2px solid var(--modern-gray-200);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--duration-fast) var(--ease-smooth);
    background: var(--modern-gray-50);
    resize: none;
    max-height: 120px;
}

.flowdent-modern .flowdent-input:focus {
    outline: none;
    border-color: var(--modern-primary-500);
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.flowdent-modern .flowdent-send-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--modern-primary-600), var(--modern-accent-600));
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-smooth);
    box-shadow: var(--shadow-colored-sm);
}

.flowdent-modern .flowdent-send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-colored-md);
}

.flowdent-modern .flowdent-send-btn:active {
    transform: scale(0.95);
}

.flowdent-modern .flowdent-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 480px) {
    #flowdent-chat-widget.flowdent-modern {
        bottom: 16px;
        right: 16px;
    }

    .flowdent-modern .flowdent-chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
    }

    .flowdent-modern .flowdent-fab {
        width: 56px;
        height: 56px;
    }
}

/* ==================== Accessibility & Motion Preferences ==================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
.flowdent-modern *:focus-visible {
    outline: 2px solid var(--modern-primary-500);
    outline-offset: 2px;
}

/* ==================== Multi-Choice Done Button ==================== */
.flowdent-modern .flowdent-multi-submit {
    width: 100%;
    margin-top: 12px;
    padding: 14px 20px;
    background: var(--modern-primary-500, #2563eb);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.flowdent-modern .flowdent-multi-submit:hover {
    background: var(--modern-primary-600, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.flowdent-modern .flowdent-multi-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}