/**
 * SDBot Chatbot Styles (Independent)
 */

/* ── FAB Button ── */
.sdbot-fab {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sdbot-color, #1e40af);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    /* Eliminado overflow: hidden para permitir que el punto y tooltip sobresalgan */
    -webkit-tap-highlight-color: transparent;
}

.sdbot-fab .fab-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sdbot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.sdbot-fab:active {
    transform: scale(0.95);
}

.sdbot-fab.hidden {
    display: none;
}

/* Notification dot */
.sdbot-fab .fab-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    animation: sdbot-pulse 2s infinite;
}

@keyframes sdbot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* ── Bot Tooltip (Llamada de Atención) ── */
.sdbot-tooltip {
    position: absolute;
    right: 75px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    color: #1e293b;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 997;
}

.sdbot-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #fff;
}

.sdbot-tooltip.show {
    opacity: 1;
    visibility: visible;
    animation: sdbot-bounce-x 2s infinite;
}

@keyframes sdbot-bounce-x {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(-8px); }
}

/* ── Chat Window ── */
.sdbot-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 999;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.sdbot-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Dark mode */
body.dark .sdbot-window {
    background: #1e293b;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ── Chat Header ── */
.sdbot-header {
    background: var(--sdbot-color, #1e40af);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sdbot-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sdbot-header .bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
}

.sdbot-header .bot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sdbot-header .bot-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.sdbot-header .bot-info span {
    font-size: 11px;
    opacity: 0.8;
}

.sdbot-header .header-actions {
    display: flex;
    gap: 8px;
}

.sdbot-header .header-actions button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sdbot-header .header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Chat Body ── */
.sdbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

body.dark .sdbot-body {
    background: #1e293b;
}

.sdbot-body::-webkit-scrollbar {
    width: 5px;
}

.sdbot-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

body.dark .sdbot-body::-webkit-scrollbar-thumb {
    background: #475569;
}

/* ── Message Bubbles ── */
.sdbot-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: sdbot-msg-in 0.3s ease;
}

@keyframes sdbot-msg-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sdbot-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.sdbot-msg.bot {
    align-self: flex-start;
}

.sdbot-msg .msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    overflow: hidden;
}

.sdbot-msg .msg-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sdbot-msg.bot .msg-avatar {
    background: var(--sdbot-color, #1e40af);
    color: #fff;
}

.sdbot-msg.user .msg-avatar {
    background: #e2e8f0;
    color: #475569;
}

body.dark .sdbot-msg.user .msg-avatar {
    background: #334155;
    color: #94a3b8;
}

.sdbot-msg .msg-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.sdbot-msg.bot .msg-content {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

body.dark .sdbot-msg.bot .msg-content {
    background: #334155;
    color: #e2e8f0;
}

.sdbot-msg.user .msg-content {
    background: var(--sdbot-color, #1e40af);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sdbot-msg .msg-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.5;
}

/* ── Typing indicator ── */
.sdbot-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 80px;
}

body.dark .sdbot-typing {
    background: #334155;
}

.sdbot-typing .typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sdbot-color, #1e40af);
    animation: sdbot-typing-bounce 1.4s infinite;
}

.sdbot-typing .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.sdbot-typing .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes sdbot-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Chat Input ── */
.sdbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

body.dark .sdbot-input-area {
    border-top-color: #334155;
}

.sdbot-input-area input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    color: #1e293b;
}

body.dark .sdbot-input-area input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

.sdbot-input-area input:focus {
    border-color: var(--sdbot-color, #1e40af);
}

.sdbot-input-area button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--sdbot-color, #1e40af);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.3s;
}

.sdbot-input-area button:hover {
    transform: scale(1.05);
}

.sdbot-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
    .sdbot-window {
        width: 100%;
        max-width: 100%;
        right: 0;
        bottom: 0;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .sdbot-fab {
        width: 52px;
        height: 52px;
        bottom: 20px;
        right: 20px;
        font-size: 22px;
    }

    .sdbot-header {
        border-radius: 0;
    }
}

/* ── Scroll-to-bottom button ── */
.sdbot-scroll-down {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sdbot-color, #1e40af);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 2;
}

.sdbot-scroll-down.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}