/* AI Sales Closer - Chat Widget */

#asc-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Toggle button ── */
#asc-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    margin-left: auto;
}

#asc-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.55);
}

#asc-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ── Chat panel ── */
#asc-panel {
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    transform: scale(0.85) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

#asc-panel.asc-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ── */
#asc-header {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#asc-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#asc-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

#asc-bot-name {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}

#asc-status-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

#asc-status-text.asc-waiting {
    color: #fbbf24;
}

#asc-status-text.asc-live {
    color: #86efac;
}

#asc-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

#asc-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ── Messages area ── */
#asc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

#asc-messages::-webkit-scrollbar {
    width: 4px;
}

#asc-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* ── Message bubbles ── */
.asc-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.asc-msg--user {
    align-self: flex-end;
    align-items: flex-end;
}

.asc-msg--bot,
.asc-msg--agent {
    align-self: flex-start;
    align-items: flex-start;
}

.asc-bubble {
    padding: 9px 13px;
    border-radius: 18px;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.45;
}

.asc-msg--user .asc-bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.asc-msg--bot .asc-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.asc-msg--agent .asc-bubble {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
    border-bottom-left-radius: 4px;
}

.asc-msg-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 3px;
    padding: 0 4px;
}

.asc-msg--agent .asc-msg-label {
    color: #16a34a;
    font-weight: 500;
}

/* ── Typing indicator ── */
#asc-typing {
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f8fafc;
}

#asc-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: asc-bounce 1.2s infinite;
}

#asc-typing span:nth-child(2) { animation-delay: 0.2s; }
#asc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes asc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* ── Input area ── */
#asc-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

#asc-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
    transition: border-color 0.15s;
    background: #f8fafc;
}

#asc-input:focus {
    border-color: #2563eb;
    background: #fff;
}

#asc-input::placeholder {
    color: #94a3b8;
}

#asc-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

#asc-send:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

#asc-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* ── Handoff card ── */
.asc-handoff-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    margin: 4px 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    align-self: flex-start;
    max-width: 88%;
}

.asc-handoff-card p {
    margin: 0 0 10px;
    color: #475569;
    font-size: 13px;
}

.asc-handoff-buttons {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.asc-btn-wa {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #25d366;
    color: #fff !important;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.asc-btn-wa:hover {
    background: #1ebe5d;
}

.asc-btn-queue {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.asc-btn-queue:hover {
    background: #dbeafe;
}

/* ── System message ── */
.asc-system-msg {
    text-align: center;
    font-size: 11.5px;
    color: #94a3b8;
    padding: 4px 0;
    align-self: center;
}

.asc-system-msg.asc-live-banner {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    border-radius: 20px;
    padding: 5px 14px;
    font-weight: 500;
}

/* ── Schedule card ── */
.asc-schedule-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    margin: 4px 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    align-self: flex-start;
    max-width: 92%;
    width: 100%;
    box-sizing: border-box;
}

.asc-card-title {
    font-size: 13px;
    color: #374151;
    font-weight: 600;
    margin: 0 0 10px;
}

/* Días disponibles */
.asc-date-pills,
.asc-slot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.asc-pill {
    border: 1.5px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.asc-pill:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

.asc-pill:active {
    transform: scale(0.97);
}

.asc-slot-pill {
    min-width: 54px;
    text-align: center;
    border-color: #a5f3b0;
    background: #f0fdf4;
    color: #15803d;
}

.asc-slot-pill:hover {
    background: #dcfce7;
}

/* Indicador de carga para slots */
.asc-slots-loading {
    display: flex;
    gap: 5px;
    padding: 8px 0;
}
.asc-slots-loading span {
    width: 8px; height: 8px;
    background: #94a3b8; border-radius: 50%;
    animation: asc-bounce 1.2s infinite;
}
.asc-slots-loading span:nth-child(2) { animation-delay: .2s; }
.asc-slots-loading span:nth-child(3) { animation-delay: .4s; }

/* Formulario de confirmación */
.asc-booking-summary {
    font-size: 13px;
    color: #374151;
    margin: 0 0 10px;
}

.asc-booking-form {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.asc-book-input {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
    background: #f8fafc;
}

.asc-book-input:focus {
    border-color: #2563eb;
    background: #fff;
}

.asc-booking-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.asc-btn-confirm {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}

.asc-btn-confirm:hover {
    background: #1d4ed8;
}

.asc-link-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    padding: 0;
    text-decoration: underline;
}

.asc-link-btn:hover {
    color: #374151;
}

/* ── Mobile responsive ── */
@media (max-width: 400px) {
    #asc-root {
        bottom: 12px;
        right: 12px;
    }

    #asc-panel {
        width: calc(100vw - 24px);
        height: 480px;
    }
}
