/* ============== VARIABLES ============== */
:root {
    --sky-black: #0f172a;
    --sky-black-soft: #1e293b;
    --sky-white: #ffffff;
    --sky-gray-50: #f8fafc;
    --sky-gray-100: #f1f5f9;
    --sky-gray-200: #e2e8f0;
    --sky-gray-300: #cbd5e1;
    --sky-gray-400: #94a3b8;
    --sky-gray-500: #64748b;
    --sky-gray-600: #475569;
    --sky-gray-900: #0f172a;

    --sky-online: #22c55e;
    --sky-danger: #ef4444;

    --sky-border: rgba(0, 0, 0, 0.06);
    --sky-border-strong: rgba(0, 0, 0, 0.12);

    --sky-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --sky-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --sky-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --sky-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --sky-shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
    --sky-shadow-bubble: 0 8px 24px rgba(15, 23, 42, 0.18);

    --sky-radius-sm: 8px;
    --sky-radius-md: 12px;
    --sky-radius-lg: 18px;
    --sky-radius-xl: 22px;
}

/* ============== BUBBLE LAUNCHER ============== */
.sky-chat-bubble {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--sky-black);
    border: none;
    cursor: pointer;
    z-index: 999998;
    box-shadow: var(--sky-shadow-bubble);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
}

.sky-chat-bubble svg {
    width: 24px;
    height: 24px;
    transition: transform 0.25s ease;
}

.sky-chat-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
    background: var(--sky-black-soft);
}

.sky-chat-bubble:hover svg {
    transform: scale(1.1);
}

.sky-chat-bubble:active {
    transform: scale(0.96);
}

.sky-chat-bubble.is-open,
.sky-chat-bubble.chat-open {
    background: var(--sky-gray-100);
    color: var(--sky-black);
}

.sky-chat-bubble.is-open:hover,
.sky-chat-bubble.chat-open:hover {
    background: var(--sky-gray-200);
}

.sky-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--sky-danger);
    color: white;
    border-radius: 12px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 600;
    border: 2px solid white;
    display: none;
    min-width: 20px;
    text-align: center;
}

.sky-chat-badge.has-message,
.sky-chat-badge.active {
    display: block;
    animation: skyBadgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes skyBadgePop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* ============== CHAT WINDOW ============== */
.sky-chat-window {
    position: fixed;
    bottom: 96px;
    left: 24px;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--sky-white);
    border-radius: 20px;
    box-shadow: var(--sky-shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999997;
    border: 0.5px solid var(--sky-border);
    transform-origin: bottom left;
}

.sky-chat-window.is-open,
.sky-chat-window.active {
    display: flex;
    animation: skyWindowOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes skyWindowOpen {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============== HEADER ============== */
.sky-chat-header {
    background: #1e293b;
    color: var(--sky-black);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 0.5px solid var(--sky-border);
}

.sky-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sky-chat-avatar {
    width: 40px;
    height: 40px;
    background: var(--sky-black);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 16px;
    flex-shrink: 0;
    position: relative;
}

.sky-chat-avatar::before {
    content: 'S';
    color: white;
    font-weight: 500;
}

.sky-chat-avatar > * {
    display: none;
}

.sky-chat-avatar-status {
    display: block !important;
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    background: var(--sky-online);
    border-radius: 50%;
    border: 2.5px solid #1e293b;
}

.sky-chat-title {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    color: white;
    letter-spacing: -0.01em;
}

.sky-chat-status {
    margin: 2px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 400;
}

.sky-chat-status-dot {
    width: 6px;
    height: 6px;
    background: var(--sky-online);
    border-radius: 50%;
}

.sky-chat-actions {
    display: flex;
    gap: 2px;
}

.sky-chat-btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.85);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
}

.sky-chat-btn-icon:hover {
    background: rgba(255, 255, 255, 0.18);
    color: white;
}

.sky-chat-btn-icon:active {
    background: rgba(255, 255, 255, 0.25);
}

.sky-chat-btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ============== MESSAGES AREA ============== */
.sky-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--sky-white);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sky-chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.sky-chat-messages::-webkit-scrollbar-thumb {
    background: var(--sky-gray-200);
    border-radius: 10px;
}

.sky-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--sky-gray-300);
}

/* ============== MESSAGE ROW ============== */
.sky-chat-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
    animation: skyMessageIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes skyMessageIn {
    0% {
        opacity: 0;
        transform: translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.sky-chat-message-row.user {
    flex-direction: row-reverse;
}

.sky-chat-message-avatar {
    width: 26px;
    height: 26px;
    background: var(--sky-gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--sky-gray-600);
    font-weight: 500;
    flex-shrink: 0;
    border: 0.5px solid var(--sky-border);
}

.sky-chat-message-row.user .sky-chat-message-avatar {
    display: none;
}

/* ============== MESSAGE BUBBLES ============== */
.sky-chat-message {
    max-width: calc(82% - 34px);
    padding: 10px 14px;
    border-radius: var(--sky-radius-lg);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    flex-shrink: 0;
    letter-spacing: -0.005em;
}

.sky-chat-message.user {
    background: var(--sky-black);
    color: white;
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
}

.sky-chat-message.assistant {
    background: var(--sky-gray-100);
    color: var(--sky-black);
    border-radius: 18px 18px 18px 4px;
}

.sky-chat-message strong {
    font-weight: 600;
}

.sky-chat-message em {
    font-style: italic;
    color: var(--sky-gray-500);
}

.sky-chat-message a {
    color: var(--sky-black);
    text-decoration: underline;
    font-weight: 500;
}

.sky-chat-message.user a {
    color: white;
    text-decoration: underline;
}

.sky-chat-message code {
    background: rgba(15, 23, 42, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    color: var(--sky-black);
    border: 0.5px solid var(--sky-border);
}

.sky-chat-message.user code {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

/* ============== TYPING INDICATOR ============== */
.sky-chat-typing {
    display: none;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
    animation: skyMessageIn 0.25s ease;
}

.sky-chat-typing.is-visible,
.sky-chat-typing.active {
    display: flex;
}

.sky-chat-typing-bubble {
    background: var(--sky-gray-100);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.sky-chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sky-gray-400);
    animation: skyTypingDot 1.3s ease-in-out infinite;
}

.sky-chat-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.sky-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.sky-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* ============== QUICK REPLIES (PILL BUTTONS) ============== */
.sky-chat-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.sky-chat-replies:empty {
    display: none;
}

.sky-chat-reply,
.sky-chat-reply-btn {
    background: var(--sky-gray-100);
    border: 0.5px solid var(--sky-border);
    color: var(--sky-black);
    padding: 8px 14px;
    border-radius: var(--sky-radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: -0.005em;
}

.sky-chat-reply:hover,
.sky-chat-reply-btn:hover {
    background: var(--sky-black);
    color: white;
    border-color: var(--sky-black);
    transform: translateY(-1px);
}

.sky-chat-reply:active,
.sky-chat-reply-btn:active {
    transform: translateY(0);
}

.sky-chat-reply-icon {
    font-size: 13px;
}

/* ============== INPUT AREA ============== */
.sky-chat-input-area {
    padding: 12px 14px;
    border-top: 0.5px solid var(--sky-border);
    background: var(--sky-white);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.sky-chat-input {
    flex: 1;
    border: none;
    background: var(--sky-gray-100);
    border-radius: var(--sky-radius-xl);
    padding: 10px 16px;
    font-size: 14px;
    color: var(--sky-black);
    outline: none;
    transition: all 0.15s ease;
    font-family: inherit;
    letter-spacing: -0.005em;
}

.sky-chat-input::placeholder {
    color: var(--sky-gray-400);
}

.sky-chat-input:focus {
    background: var(--sky-white);
    box-shadow: 0 0 0 1px var(--sky-black);
}

.sky-chat-send-btn {
    background: var(--sky-black);
    border: none;
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    padding: 0;
}

.sky-chat-send-btn:hover {
    background: var(--sky-black-soft);
    transform: scale(1.05);
}

.sky-chat-send-btn:active {
    transform: scale(0.95);
}

.sky-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.sky-chat-send-btn svg {
    width: 18px;
    height: 18px;
    margin-left: 0;
}

/* ============== FOOTER ============== */
.sky-chat-footer {
    text-align: center;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--sky-gray-400);
    border-top: 0.5px solid var(--sky-border);
    background: var(--sky-white);
    flex-shrink: 0;
    font-weight: 400;
}

.sky-chat-footer a {
    color: var(--sky-black);
    text-decoration: none;
    font-weight: 500;
}

.sky-chat-footer a:hover {
    text-decoration: underline;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 480px) {
    .sky-chat-window {
        width: calc(100vw - 24px);
        left: 12px;
        height: calc(100vh - 120px);
        bottom: 96px;
    }

    .sky-chat-bubble {
        left: 16px;
        bottom: 24px;
    }

    .sky-chat-message {
        max-width: calc(86% - 34px);
    }
}

/* ============== ACCESSIBILITY ============== */
@media (prefers-reduced-motion: reduce) {
    .sky-chat-bubble,
    .sky-chat-window,
    .sky-chat-message-row,
    .sky-chat-typing,
    .sky-chat-replies {
        animation: none !important;
        transition: none !important;
    }
}

.sky-chat-reply:focus-visible,
.sky-chat-reply-btn:focus-visible,
.sky-chat-btn-icon:focus-visible,
.sky-chat-send-btn:focus-visible,
.sky-chat-bubble:focus-visible {
    outline: 2px solid var(--sky-black);
    outline-offset: 2px;
}

.sky-chat-input:focus-visible {
    outline: none;
}
/* ============== TEASER PROACTIVO (B6) ============== */
/* La burbuja Sky vive en la esquina inferior izquierda en este proyecto
   (la esquina derecha esta ocupada por .btn-scroll-top + Customerly),
   asi que el teaser se ancla a la izquierda. */
.sky-chat-teaser {
    position: fixed;
    bottom: 96px;
    left: 24px;
    display: none;
    align-items: center;
    gap: 10px;
    max-width: 280px;
    padding: 12px 14px 12px 16px;
    background: var(--sky-white);
    color: var(--sky-black);
    border: 1px solid var(--sky-border);
    border-radius: 14px;
    box-shadow: var(--sky-shadow-lg);
    font-size: 14px;
    line-height: 1.35;
    font-weight: 500;
    z-index: 9998;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.sky-chat-teaser.is-visible {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.sky-chat-teaser::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 28px;
    width: 14px;
    height: 14px;
    background: var(--sky-white);
    border-right: 1px solid var(--sky-border);
    border-bottom: 1px solid var(--sky-border);
    transform: rotate(45deg);
}

.sky-chat-teaser-close {
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--sky-gray-500);
    padding: 2px;
    margin-left: 4px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.sky-chat-teaser-close:hover {
    background: var(--sky-gray-100);
    color: var(--sky-black);
}

.sky-chat-teaser-close svg {
    width: 14px;
    height: 14px;
}

@media (max-width: 600px) {
    .sky-chat-teaser {
        bottom: 86px;
        left: 16px;
        max-width: calc(100vw - 80px);
        font-size: 13px;
    }
    .sky-chat-teaser::after {
        left: 24px;
    }
}