/*  itsolar AI Sales — Chat Widget  */

/* HTML [hidden] debe ganar sobre cualquier display:flex/grid de las clases. */
.isc [hidden] { display: none !important; }

.isc {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Lato', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: #1a1a1a;
}

.isc-bubble {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, #f58220 0%, #db6f12 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    box-shadow: 0 12px 28px rgba(245, 130, 32, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 200ms ease, box-shadow 200ms ease;
}
.isc-bubble:hover  { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(245,130,32,0.5), 0 4px 10px rgba(0,0,0,0.2); }
.isc-bubble:active { transform: translateY(0); }
.isc-bubble svg { width: 22px; height: 22px; }
.isc-bubble.is-pulsing { animation: isc-pulse 2.4s infinite; }
@keyframes isc-pulse {
    0%   { box-shadow: 0 12px 28px rgba(245,130,32,0.4), 0 2px 6px rgba(0,0,0,0.15), 0 0 0 0 rgba(245,130,32,0.55); }
    70%  { box-shadow: 0 12px 28px rgba(245,130,32,0.4), 0 2px 6px rgba(0,0,0,0.15), 0 0 0 18px rgba(245,130,32,0); }
    100% { box-shadow: 0 12px 28px rgba(245,130,32,0.4), 0 2px 6px rgba(0,0,0,0.15), 0 0 0 0 rgba(245,130,32,0); }
}

.isc.is-open .isc-bubble { display: none; }

.isc-panel {
    width: min(380px, calc(100vw - 32px));
    height: min(480px, calc(100vh - 100px));
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: isc-pop 220ms ease both;
}
@keyframes isc-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.isc-panel__head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #0061a3 0%, #024d80 100%);
    color: #fff;
}
.isc-panel__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: grid; place-items: center;
    font-size: 1.15rem;
}
.isc-panel__title { display: flex; flex-direction: column; line-height: 1.15; }
.isc-panel__title strong { font-size: 0.95rem; font-weight: 700; }
.isc-panel__title span   { font-size: 0.75rem; opacity: 0.85; }

.isc-panel__close {
    background: transparent; border: none; color: #fff;
    font-size: 1.1rem; cursor: pointer; padding: 0.25rem 0.5rem;
    border-radius: 6px; opacity: 0.85;
}
.isc-panel__close:hover { background: rgba(255,255,255,0.15); opacity: 1; }

.isc-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f6f7f9;
    scroll-behavior: smooth;
}

.isc-msg {
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.isc-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #f58220 0%, #db6f12 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.isc-msg--assistant {
    align-self: flex-start;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e6e8eb;
    border-bottom-left-radius: 4px;
}
.isc-msg--agent {
    align-self: flex-start;
    background: #e6f4ff;
    color: #024d80;
    border: 1px solid #b6dafa;
    border-bottom-left-radius: 4px;
}
.isc-msg__meta {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 2px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.isc-typing {
    align-self: flex-start;
    background: #fff;
    color: #6b7280;
    padding: 0.625rem 0.875rem;
    border-radius: 14px;
    border: 1px solid #e6e8eb;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.isc-typing__dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #f58220;
    animation: isc-bounce 1.2s infinite;
}
.isc-typing__dot:nth-child(2) { animation-delay: 150ms; }
.isc-typing__dot:nth-child(3) { animation-delay: 300ms; }
@keyframes isc-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%           { transform: translateY(-3px); opacity: 1; }
}

.isc-panel__status {
    padding: 0.5rem 0.875rem;
    background: #fff8e6;
    color: #8a5a00;
    font-size: 0.8rem;
    border-top: 1px solid #f1e3b8;
    border-bottom: 1px solid #f1e3b8;
}

.isc-panel__form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-top: 1px solid #e6e8eb;
    background: #fff;
    align-items: end;
}
.isc-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 0.625rem 0.75rem;
    font: inherit;
    font-size: 0.92rem;
    resize: none;
    max-height: 120px;
    background: #fff;
    color: #1a1a1a;
}
.isc-input:focus { outline: none; border-color: #f58220; box-shadow: 0 0 0 3px rgba(245,130,32,0.18); }

.isc-send {
    background: linear-gradient(135deg, #f58220 0%, #db6f12 100%);
    color: #fff;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    cursor: pointer;
    transition: transform 150ms ease;
}
.isc-send:hover { transform: scale(1.06); }
.isc-send svg { width: 18px; height: 18px; }
.isc-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Pre-chat: pedir nombre + correo antes de iniciar */
.isc-prechat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 1rem 1.1rem 1.2rem;
    background: #fff;
}
.isc-prechat__intro {
    margin: 0 0 0.25rem;
    color: #4b5563;
    font-size: 0.9rem;
    line-height: 1.45;
}
.isc-prechat__label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #1a1a1a;
}
.isc-prechat__label span { letter-spacing: 0.02em; }
.isc-prechat__label input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 0.625rem 0.75rem;
    font: inherit;
    font-size: 0.92rem;
    background: #fff;
    color: #1a1a1a;
}
.isc-prechat__label input:focus {
    outline: none;
    border-color: #f58220;
    box-shadow: 0 0 0 3px rgba(245,130,32,0.18);
}
.isc-prechat__submit {
    margin-top: 0.4rem;
    background: linear-gradient(135deg, #f58220 0%, #db6f12 100%);
    color: #fff;
    border: none;
    border-radius: 9999px;
    padding: 0.625rem 1rem;
    font: inherit;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease;
}
.isc-prechat__submit:hover  { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(245,130,32,0.3); }
.isc-prechat__submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }
.isc-prechat__error {
    margin: 0;
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-size: 0.82rem;
}

@media (max-width: 480px) {
    .isc { right: 12px; bottom: 12px; }
    .isc-bubble__label { display: none; }
    .isc-bubble { padding: 0.875rem; }
}
