/**
 * Universal AI Chatbot & Koboyo Mascot Widget Styles
 */

.uac-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-sizing: border-box;
}

.uac-container *,
.uac-container *::before,
.uac-container *::after {
    box-sizing: border-box;
}

/* Positions */
.uac-pos-bottom-right {
    bottom: 24px;
    right: 95px;
}

.uac-pos-bottom-right-offset {
    bottom: 24px;
    right: 95px;
}

.uac-pos-bottom-right-edge {
    bottom: 24px;
    right: 24px;
}

.uac-pos-bottom-left {
    bottom: 24px;
    left: 24px;
}

/* Admin Live Drag & Drop */
.uac-admin-draggable {
    cursor: grab !important;
    user-select: none;
    -webkit-user-drag: none;
}

.uac-admin-draggable:active,
.uac-is-dragging .uac-dock {
    cursor: grabbing !important;
}

.uac-drag-save-pill {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 12px;
    background: #0f172a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 9999999;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: uac-toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.uac-drag-save-pill span {
    color: #10b981;
}

@keyframes uac-toast-in {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Floating Dock */
.uac-dock {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

/* Teaser Speech Bubble */
.uac-teaser {
    position: absolute;
    bottom: 100%;
    margin-bottom: 12px;
    background: #ffffff;
    color: #1e293b;
    padding: 8px 14px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e2e8f0;
    animation: uac-float 3s ease-in-out infinite;
    pointer-events: auto;
}

.uac-teaser::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

.uac-teaser-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
}

.uac-teaser-close:hover {
    color: #ef4444;
}

/* Mascot Wrapper */
.uac-mascot-wrapper {
    position: relative;
    width: 95px;
    height: 95px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.uac-dock:hover .uac-mascot-wrapper {
    transform: scale(1.08);
}

.uac-mascot-button {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    outline: none;
    user-select: none;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.16));
}

.uac-squash-target {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    transform-origin: 50% 80%;
}

.uac-sprite-layer {
    position: absolute;
    inset: 0;
    background-size: 300% 300%;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    pointer-events: none;
}

.uac-layer-reactions {
    opacity: 0;
}

.uac-live-dot {
    position: absolute;
    bottom: 6px;
    right: 8px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
    animation: uac-pulse 2s infinite;
}

/* Chat Dialog Window */
.uac-window {
    position: absolute;
    bottom: 105px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 135px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    animation: uac-slide-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000000;
}

.uac-pos-bottom-right .uac-window,
.uac-pos-bottom-right-offset .uac-window,
.uac-pos-bottom-right-edge .uac-window,
.uac-pos-custom .uac-window {
    right: 0;
    left: auto;
}

.uac-pos-bottom-left .uac-window {
    left: 0;
    right: auto;
}

/* Header */
.uac-header {
    background: linear-gradient(135deg, #ff7a18 0%, #eb5b00 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.uac-header-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    overflow: visible;
    flex-shrink: 0;
}

.uac-mini-mascot-preview {
    width: 100%;
    height: 100%;
    background-size: 300% 300%;
    background-position: 50% 50%;
    border-radius: 50%;
}

.uac-header-status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.uac-header-info {
    flex: 1;
    min-width: 0;
}

.uac-bot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uac-bot-subtitle {
    margin: 3px 0 0;
    font-size: 12px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 6px;
}

.uac-online-badge {
    background: rgba(255, 255, 255, 0.25);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.uac-header-actions {
    display: flex;
    gap: 6px;
}

.uac-icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.uac-icon-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

/* Messages Area */
.uac-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.uac-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: uac-fade-in 0.25s ease-out;
}

.uac-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.uac-msg-bot {
    align-self: flex-start;
}

.uac-msg-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.uac-msg-user .uac-msg-bubble {
    background: #ff7a18;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.uac-msg-bot .uac-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.uac-msg-bot .uac-msg-bubble a {
    color: #ff7a18;
    font-weight: 600;
    text-decoration: underline;
}

.uac-msg-bot .uac-msg-bubble p:first-child { margin-top: 0; }
.uac-msg-bot .uac-msg-bubble p:last-child { margin-bottom: 0; }

.uac-msg-time {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator */
.uac-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    width: fit-content;
    align-self: flex-start;
}

.uac-typing-dot {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: uac-typing-bounce 1.4s infinite ease-in-out both;
}

.uac-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.uac-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Quick Suggestion Chips */
.uac-chips-container {
    padding: 8px 14px 4px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    background: #f8fafc;
    scrollbar-width: none;
}
.uac-chips-container::-webkit-scrollbar { display: none; }

.uac-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    padding: 6px 11px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.uac-chip:hover {
    background: #ff7a18;
    color: #ffffff;
    border-color: #ff7a18;
}

/* Input Form Bar */
.uac-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.uac-input-field {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: #1e293b;
}

.uac-input-field:focus {
    border-color: #ff7a18;
    box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.15);
}

.uac-send-button {
    background: #ff7a18;
    border: none;
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.uac-send-button:hover {
    background: #e66607;
    transform: scale(1.05);
}

.uac-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.uac-footer-credit {
    font-size: 11px;
    text-align: center;
    padding: 6px 0 8px;
    color: #64748b;
    background: #ffffff;
}

/* Mascot Picker Drawer Overlay */
.uac-drawer {
    position: absolute;
    inset: 0;
    background: #ffffff;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 18px;
    animation: uac-slide-in 0.22s ease-out;
}

.uac-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.uac-drawer-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

.uac-drawer-header .uac-icon-btn {
    color: #1e293b;
    background: #f1f5f9;
}

.uac-drawer-desc {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 14px;
}

.uac-mascot-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.uac-mascot-card {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.uac-mascot-card:hover {
    border-color: #ff7a18;
    background: #fff7ed;
    transform: translateY(-2px);
}

.uac-mascot-card.uac-card-selected {
    border-color: #ff7a18;
    background: #fff7ed;
    box-shadow: 0 0 0 2px #ff7a18;
}

.uac-card-preview {
    width: 65px;
    height: 65px;
    background-size: 300% 300%;
    background-position: 50% 50%;
}

.uac-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

/* Animations */
@keyframes uac-slide-up {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes uac-slide-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes uac-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes uac-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes uac-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes uac-typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ==========================================
   MOBILE RESPONSIVE RULES (FITS ALL PHONES)
========================================== */
@media screen and (max-width: 640px) {
    .uac-container,
    .uac-pos-bottom-right,
    .uac-pos-bottom-right-offset,
    .uac-pos-bottom-right-edge {
        bottom: 14px !important;
        right: 14px !important;
        left: auto !important;
    }

    .uac-mascot-wrapper {
        width: 60px !important;
        height: 60px !important;
    }

    .uac-window {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        bottom: 84px !important;
        width: calc(100vw - 24px) !important;
        max-width: 440px !important;
        height: 70vh !important;
        max-height: 520px !important;
        margin: 0 auto !important;
        border-radius: 16px !important;
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3) !important;
    }

    .uac-messages-area {
        padding: 12px !important;
        gap: 10px !important;
    }

    .uac-msg {
        max-width: 90% !important;
    }

    .uac-msg-bubble {
        font-size: 13px !important;
        padding: 9px 13px !important;
    }

    .uac-input-bar {
        padding: 10px 12px !important;
    }

    .uac-input-field {
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
}