/* -------------------------------------------------------------
   Chatbot Widget Styles (Scoped under #rexo-chatbot-widget)
   ------------------------------------------------------------- */
.rexo-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    left: auto;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Floating Trigger */
.rexo-chat-trigger {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    outline: none;
}
.rexo-chat-trigger:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.55);
}
.rexo-chat-trigger:active {
    transform: scale(0.95);
}

.rexo-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.rexo-icon-close {
    display: none;
}
.rexo-chat-widget.is-open .rexo-icon-open {
    display: none;
}
.rexo-chat-widget.is-open .rexo-icon-close {
    display: flex;
}

/* Subtle Pulse Glow */
.rexo-trigger-pulse {
    position: absolute;
    top: -3px; left: -3px; right: -3px; bottom: -3px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.5);
    animation: rexoPulse 2.4s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
}
@keyframes rexoPulse {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.22); opacity: 0; }
    100% { transform: scale(1.22); opacity: 0; }
}
.rexo-chat-widget.is-open .rexo-trigger-pulse {
    display: none;
}

/* Tooltip badge */
.rexo-trigger-tooltip {
    position: absolute;
    right: 72px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.12);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.rexo-chat-widget:not(.is-open):hover .rexo-trigger-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-4px);
}
.rexo-chat-widget.is-open .rexo-trigger-tooltip {
    display: none;
}

/* Popup Container */
.rexo-chat-popup {
    position: absolute;
    bottom: 75px;
    right: 0;
    left: auto;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 570px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15,23,42,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.94);
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.rexo-chat-widget.is-open .rexo-chat-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.rexo-chat-header {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    flex-shrink: 0;
}
.rexo-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.rexo-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff, #dbeafe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}
.rexo-header-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}
.rexo-header-status {
    font-size: 11px;
    color: #dbeafe;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.rexo-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 6px #10b981;
}
.rexo-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.rexo-header-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.rexo-header-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Messages Area */
.rexo-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}
.rexo-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.rexo-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(15,23,42,0.18);
    border-radius: 10px;
}

/* Welcome Box */
.rexo-welcome-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 14px;
    text-align: center;
    color: #334155;
    margin-bottom: 6px;
}
.rexo-welcome-avatar {
    font-size: 26px;
    margin-bottom: 6px;
}
.rexo-welcome-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}
.rexo-welcome-desc {
    font-size: 12px;
    line-height: 1.5;
    color: #64748b;
    margin-bottom: 12px;
}
.rexo-quick-prompts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rexo-quick-btn {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}
.rexo-quick-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
    transform: translateX(2px);
}

/* Message Bubble */
.rexo-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: rexoMsgFade 0.25s ease-out;
}
@keyframes rexoMsgFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.rexo-msg.user {
    flex-direction: row-reverse;
}
.rexo-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}
.rexo-msg.bot .rexo-msg-avatar {
    background: linear-gradient(135deg, #1d4ed8, #38bdf8);
    color: #fff;
}
.rexo-msg.user .rexo-msg-avatar {
    background: #94a3b8;
    color: #fff;
}
.rexo-msg-body {
    max-width: 82%;
    display: flex;
    flex-direction: column;
}
.rexo-msg.user .rexo-msg-body {
    align-items: flex-end;
}
.rexo-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}
.rexo-msg.bot .rexo-msg-bubble {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(15,23,42,0.05);
    border-top-left-radius: 4px;
}
.rexo-msg.bot .rexo-msg-bubble strong {
    color: #1d4ed8;
}
.rexo-msg.bot .rexo-msg-bubble h3 {
    font-size: 13px;
    font-weight: 700;
    margin: 8px 0 4px;
    color: #1d4ed8;
}
.rexo-msg.user .rexo-msg-bubble {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
}
.rexo-msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #64748b;
    margin-top: 3px;
    padding: 0 4px;
}
.rexo-msg-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
}
.rexo-msg-tag.database {
    background: #d1fae5;
    color: #047857;
}
.rexo-msg-tag.ai {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Typing indicator */
.rexo-typing {
    display: none;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.rexo-typing.is-active {
    display: flex;
}
.rexo-typing-bubble {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 10px 14px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.rexo-typing-bubble span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2563eb;
    animation: rexoBounce 1.4s infinite ease-in-out;
}
.rexo-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.rexo-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes rexoBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* Footer / Input */
.rexo-chat-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.rexo-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 4px 6px 4px 12px;
    transition: border-color 0.2s;
}
.rexo-chat-form:focus-within {
    border-color: #2563eb;
}
.rexo-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
    font-size: 13px;
    padding: 6px 0;
}
.rexo-chat-input::placeholder {
    color: #64748b;
}
.rexo-chat-send {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
}
.rexo-chat-send:hover {
    transform: scale(1.05);
}
.rexo-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.rexo-powered {
    text-align: center;
    font-size: 10px;
    color: #64748b;
    margin-top: 6px;
}
.rexo-powered strong {
    color: #1d4ed8;
}

/* Date & Time Picker Card */
.rexo-dt-picker-card {
    margin-top: 10px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
    animation: rexoMsgFade 0.3s ease-out;
}
.rexo-dt-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.rexo-dt-input-group {
    display: flex;
    gap: 8px;
}
.rexo-dt-date-input, .rexo-dt-custom-time {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #0f172a;
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    color-scheme: light;
    transition: border-color 0.2s;
}
.rexo-dt-date-input:focus, .rexo-dt-custom-time:focus {
    border-color: #2563eb;
}
.rexo-dt-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.rexo-dt-slot-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 4px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.rexo-dt-slot-btn:hover {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1e40af;
}
.rexo-dt-slot-btn.active {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    border-color: #1d4ed8;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.rexo-dt-confirm-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.2s, background 0.2s, opacity 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}
.rexo-dt-confirm-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #059669, #047857);
}
.rexo-dt-picker-card.is-submitted {
    opacity: 0.6;
    pointer-events: none;
}
.rexo-dt-picker-card.is-submitted .rexo-dt-confirm-btn {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

@media (max-width: 480px) {
    .rexo-chat-widget {
        bottom: 16px;
        right: 16px;
        left: auto;
    }
    .rexo-chat-popup {
        bottom: 70px;
        right: -8px;
        left: auto;
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        border-radius: 16px;
    }
}
