/* ==========================================================================
   DreamAI ChatBot — Premium AI Assistant Widget
   ========================================================================== */

.dreamai-chatbot {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    pointer-events: none;
}

.dreamai-chatbot.is-open {
    pointer-events: auto;
}

/* ── Toggle Button ─────────────────────────────────────────────────────── */
.dreamai-toggle {
    position: relative;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border: 0;
    border-radius: 24px;
    background: linear-gradient(135deg, #0E3A66 0%, #155B96 55%, #32A9FF 100%);
    box-shadow: 0 20px 55px rgba(14, 58, 102, 0.28);
    color: #fff;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    isolation: isolate;
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dreamai-toggle__glow {
    position: absolute;
    inset: -8px;
    border-radius: 30px;
    background: conic-gradient(from 0deg, rgba(50, 169, 255, 0), rgba(50, 169, 255, 0.55), rgba(14, 58, 102, 0));
    animation: dreamaiOrbit 4s linear infinite;
    z-index: -1;
    pointer-events: none;
}

.dreamai-toggle::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #31E981;
    border: 2px solid #fff;
    box-shadow: 0 0 0 5px rgba(49, 233, 129, 0.18);
    z-index: 2;
}

.dreamai-toggle__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.dreamai-toggle__icon svg {
    width: 100%;
    height: 100%;
}

.dreamai-toggle__label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #0E3A66;
    white-space: nowrap;
    pointer-events: none;
    background: linear-gradient(135deg, #0E3A66, #32A9FF);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dreamai-toggle:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 28px 70px rgba(14, 58, 102, 0.36);
}

.dreamai-toggle[aria-expanded="true"] {
    transform: scale(0.96);
    box-shadow: 0 14px 40px rgba(14, 58, 102, 0.24);
}

@keyframes dreamaiOrbit {
    to { transform: rotate(360deg); }
}

/* ── Panel ─────────────────────────────────────────────────────────────── */
.dreamai-panel {
    position: fixed;
    right: 24px;
    bottom: 112px;
    width: 410px;
    max-height: 580px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
    border: 1px solid rgba(231, 238, 245, 0.95);
    border-radius: 28px;
    box-shadow:
        0 32px 80px rgba(14, 58, 102, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.dreamai-chatbot.is-open .dreamai-panel,
.dreamai-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.dreamai-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 20px 18px;
    background: linear-gradient(135deg, #0E3A66 0%, #155B96 50%, #1A6BB5 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.dreamai-header::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(50, 169, 255, 0.35) 0%, transparent 70%);
    pointer-events: none;
}

.dreamai-avatar {
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(145deg, #32A9FF 0%, #0E3A66 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.dreamai-avatar::before {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    background: rgba(50, 169, 255, 0.35);
    animation: dreamaiPulse 2.4s ease-in-out infinite;
    z-index: -1;
}

@keyframes dreamaiPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.06); }
}

.dreamai-header__text {
    flex: 1;
    min-width: 0;
    z-index: 1;
}

.dreamai-header__text h3 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.dreamai-header__text p {
    margin: 4px 0 0;
    font-size: 0.8125rem;
    opacity: 0.88;
    font-weight: 500;
}

.dreamai-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
    z-index: 1;
}

.dreamai-close:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

.dreamai-close svg {
    width: 18px;
    height: 18px;
}

/* ── Body ────────────────────────────────────────────────────────────── */
.dreamai-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #F7FAFD;
}

.dreamai-messages {
    flex: 1;
    min-height: 220px;
    max-height: 360px;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(50, 169, 255, 0.06) 0%, transparent 60%),
        linear-gradient(180deg, #F7FAFD 0%, #F4F8FC 100%);
    position: relative;
}

.dreamai-messages::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(14, 58, 102, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14, 58, 102, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    opacity: 0.5;
}

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

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

.dreamai-messages::-webkit-scrollbar-thumb {
    background: rgba(14, 58, 102, 0.15);
    border-radius: 10px;
}

.dreamai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 58, 102, 0.28);
}

/* ── Messages ────────────────────────────────────────────────────────── */
.dreamai-msg {
    position: relative;
    max-width: 88%;
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.6;
    z-index: 1;
}

.dreamai-msg--bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #E7EEF5;
    color: #1B1F24;
    border-bottom-left-radius: 8px;
    box-shadow: 0 4px 18px rgba(14, 58, 102, 0.06);
    animation: dreamaiBotIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.dreamai-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0E3A66 0%, #155B96 100%);
    color: #fff;
    border-bottom-right-radius: 8px;
    box-shadow: 0 8px 24px rgba(14, 58, 102, 0.22);
    animation: dreamaiUserIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

@keyframes dreamaiUserIn {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ── Typing Indicator ────────────────────────────────────────────────── */
.dreamai-msg--typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #E7EEF5;
    color: #5D6773;
    font-size: 0.8125rem;
    font-weight: 500;
    animation: dreamaiBotIn 0.35s ease both;
}

.dreamai-typing-label {
    color: #0E3A66;
    font-weight: 600;
}

.dreamai-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dreamai-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #32A9FF;
    animation: dreamaiDotBounce 1.2s ease-in-out infinite;
}

.dreamai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.dreamai-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dreamaiDotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Links in messages ───────────────────────────────────────────────── */
.dc-chatbot-link {
    color: #32A9FF;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(50, 169, 255, 0.35);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.dc-chatbot-link:hover {
    color: #0E3A66;
    border-bottom-color: #0E3A66;
}

.dreamai-msg--user .dc-chatbot-link {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.45);
}

.dreamai-msg--user .dc-chatbot-link:hover {
    color: #B8E4FF;
    border-bottom-color: #B8E4FF;
}

.dc-chatbot-link--tel::before {
    content: "☎ ";
    font-size: 0.9em;
    opacity: 0.85;
}

/* ── Question Chips ──────────────────────────────────────────────────── */
.dreamai-questions {
    padding: 14px 16px 18px;
    background: #fff;
    border-top: 1px solid #E7EEF5;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.dreamai-questions::-webkit-scrollbar {
    width: 5px;
}

.dreamai-questions::-webkit-scrollbar-thumb {
    background: rgba(14, 58, 102, 0.12);
    border-radius: 10px;
}

.dreamai-question-btn {
    width: 100%;
    border: 1px solid #DDEAF5;
    background: rgba(255, 255, 255, 0.86);
    color: #0E3A66;
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.45;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    cursor: pointer;
    transition: all 0.24s ease;
    font-family: inherit;
}

.dreamai-question-btn__text {
    flex: 1;
    min-width: 0;
}

.dreamai-question-btn__star {
    flex-shrink: 0;
    color: #32A9FF;
    font-size: 0.875rem;
    line-height: 1;
}

.dreamai-question-btn__arrow {
    flex-shrink: 0;
    opacity: 0.45;
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.24s ease, opacity 0.24s ease;
}

.dreamai-question-btn:hover {
    border-color: rgba(14, 58, 102, 0.28);
    background: #F4F8FC;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 58, 102, 0.08);
}

.dreamai-question-btn:hover .dreamai-question-btn__arrow {
    transform: translateX(4px);
    opacity: 1;
}

.dreamai-question-btn:active {
    transform: translateY(0) scale(0.98);
}

.dreamai-question-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dreamai-chatbot {
        right: 14px !important;
        bottom: 14px !important;
        z-index: 99999 !important;
    }

    .dreamai-toggle {
        width: 64px !important;
        height: 64px !important;
        border-radius: 22px;
        pointer-events: auto !important;
        touch-action: manipulation;
    }

    .dreamai-toggle__glow {
        inset: -6px;
        border-radius: 28px;
        pointer-events: none;
    }

    .dreamai-toggle__icon {
        width: 30px;
        height: 30px;
        pointer-events: none;
    }

    .dreamai-toggle__label {
        font-size: 10px;
        bottom: -20px;
    }

    .dreamai-panel {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        bottom: 92px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 120px) !important;
        overflow: hidden !important;
        z-index: 100000 !important;
        transform-origin: bottom center;
    }

    .dreamai-messages {
        max-height: calc(100vh - 340px);
        min-height: 180px;
        padding: 16px 14px;
    }

    .dreamai-questions {
        max-height: 160px;
        padding: 12px 14px 16px;
    }

    .dreamai-question-btn {
        padding: 12px 14px;
        font-size: 0.78rem;
        touch-action: manipulation;
    }
}
