/* ============================================
   CHAT CLICK — Asesor Virtual IA
   ============================================ */

/* --- BOTÓN FLOTANTE --- */
.cc-float-btn {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: #3902a0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 28px rgba(57, 2, 160, 0.45);
    z-index: 9998;
   transition: transform 0.3s, box-shadow 0.3s, opacity 0.3s;  /* agregué opacity 0.3s */
    animation: cc-pulse-btn 3s ease-in-out infinite;
	width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    padding: 0;
}
.cc-float-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 35px rgba(57, 2, 160, 0.5);
}
.cc-float-btn.active {
    animation: none;
    transform: rotate(180deg) scale(1.05);
    background: #fd073c;
    box-shadow: 0 6px 28px rgba(253, 7, 60, 0.5);
}
.cc-float-btn svg {
    width: 32px;
    height: 32px;
    fill: white;
    transition: transform 0.3s;
}
.cc-float-btn.active svg {
    transform: rotate(-180deg);
}
@keyframes cc-pulse-btn {
    0% { box-shadow: 0 6px 28px rgba(57, 2, 160, 0.45); }
    50% { box-shadow: 0 6px 40px rgba(57, 2, 160, 0.55), 0 0 0 12px rgba(57, 2, 160, 0.08); }
    100% { box-shadow: 0 6px 28px rgba(57, 2, 160, 0.45); }
}

/* --- VENTANA DE CHAT --- */
.cc-chat-window {
    position: fixed;
    bottom: 172px;
    right: 28px;
    width: 390px;
    max-width: calc(100vw - 20px);
    height: 560px;
    max-height: calc(100dvh - 130px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(57, 2, 160, 0.08);
    z-index: 9997;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    transform-origin: bottom right;
}
.cc-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* --- HEADER --- */
.cc-header {
    background: #3902a0;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}
.cc-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}
.cc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.cc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cc-header-info {
    flex: 1;
}
.cc-header-name {
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}
.cc-header-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 5px;
}
.cc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: cc-blink 2s ease-in-out infinite;
}
@keyframes cc-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.cc-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.3s;
    flex-shrink: 0;
}
.cc-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- MENSAJES --- */
.cc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fc;
    scroll-behavior: smooth;
}
.cc-messages::-webkit-scrollbar {
    width: 4px;
}
.cc-messages::-webkit-scrollbar-thumb {
    background: rgba(57, 2, 160, 0.2);
    border-radius: 4px;
}

.cc-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: cc-msg-in 0.35s ease-out;
}
@keyframes cc-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.cc-msg.bot {
    align-self: flex-start;
}
.cc-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cc-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}.cc-msg.bot .cc-msg-avatar {
    background: linear-gradient(135deg, #3902a0, #fd073c);
}
.cc-msg.bot .cc-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: white;
}
.cc-msg.user .cc-msg-avatar {
    background: #e0e0e0;
    color: #555;
    font-weight: 700;
    font-size: 11px;
}

.cc-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.87rem;
    line-height: 1.6;
    word-wrap: break-word;
}
.cc-msg.bot .cc-msg-bubble {
    background: white;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.cc-msg.user .cc-msg-bubble {
    background: linear-gradient(135deg, #3902a0, #5b1fd6);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 10px rgba(57, 2, 160, 0.3);
}

/* --- SUGERENCIAS --- */
.cc-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
    background: #f8f9fc;
}
.cc-sug-btn {
    background: white;
    border: 1.5px solid rgba(57, 2, 160, 0.2);
    color: #3902a0;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    font-family: 'Poppins', sans-serif;
}
.cc-sug-btn:hover {
    background: #3902a0;
    color: white;
    border-color: #3902a0;
    transform: translateY(-1px);
}

/* --- TYPING INDICATOR --- */
.cc-typing {
    display: flex;
    gap: 8px;
    align-self: flex-start;
    max-width: 88%;
    animation: cc-msg-in 0.3s ease-out;
}
.cc-typing .cc-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3902a0, #fd073c);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cc-typing .cc-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: white;
}
.cc-typing-dots {
    background: white;
    padding: 14px 20px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 5px;
    align-items: center;
}
.cc-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b0b0c0;
    animation: cc-dot-bounce 1.4s ease-in-out infinite;
}
.cc-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cc-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cc-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* --- INPUT --- */
.cc-input-area {
    padding: 14px 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}
.cc-input {
    flex: 1;
    border: 2px solid #e8e8f0;
    border-radius: 25px;
    padding: 11px 18px;
    font-size: 0.87rem;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: border-color 0.3s;
    background: #f8f9fc;
    color: #1a1a2e;
}
.cc-input:focus {
    border-color: #3902a0;
    background: white;
}
.cc-input::placeholder {
    color: #b0b0c0;
}
.cc-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3902a0, #fd073c);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 12px rgba(57, 2, 160, 0.3);
}
.cc-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 18px rgba(57, 2, 160, 0.4);
}
.cc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.cc-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* --- FOOTER CHAT --- */
.cc-footer {
    padding: 6px 16px;
    background: #f0f0f5;
    text-align: center;
    font-size: 0.6rem;
    color: #b0b0c0;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

/* --- ERROR --- */
.cc-error-msg {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    text-align: center;
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    .cc-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        transform-origin: bottom center;
    }
    .cc-float-btn {
        bottom: 95px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
}
.cc-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}.cc-float-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* === GLOBO DE BIENVENIDA === */
.cc-welcome-balloon {
  position: fixed;
  bottom: 172px;
  right: 28px;
  background: linear-gradient(135deg, #3902a0, #5b1fd4);
  color: #fff;
  padding: 12px 20px;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(57, 2, 160, 0.4);
  z-index: 10001;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(15px) scale(0.9);
  animation: ccBalloonIn 0.5s 1.5s ease forwards,
             ccBalloonOut 0.4s 6s ease forwards;
  pointer-events: none;
}

.cc-welcome-balloon span {
  display: block;
  line-height: 1.4;
}

.cc-balloon-arrow {
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #5b1fd4;
}

@keyframes ccBalloonIn {
  0% {
    opacity: 0;
    transform: translateY(15px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ccBalloonOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
  }
}

/* En móviles hacerlo más pequeño */
@media (max-width: 480px) {
  .cc-welcome-balloon {
    bottom: 165px;
    right: 16px;
    font-size: 13px;
    padding: 10px 16px;
    max-width: calc(100vw - 80px);
    white-space: normal;
    text-align: center;
  }
}
/* === OCULTAR ICONOS CUANDO EL CHAT ESTÁ ABIERTO === */
body.cc-chat-open .cc-float-btn {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transition: opacity 0.2s, transform 0.2s;
}

body.cc-chat-open a[href*="wa.me"] {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transition: opacity 0.2s, transform 0.2s;
}

/* === AJUSTAR VENTANA EN PC PARA NO LLEGAR AL TOPE === */
@media (min-width: 481px) {
    .cc-chat-window {
        max-height: calc(100dvh - 220px);  /* deja espacio arriba */
        bottom: 172px;
    }
}
/* ==========================================
   CAPTURA ASISTIDA POR IA
   ========================================== */
.cc-capture-wrapper {
    margin: 10px 0;
    animation: cc-msg-in 0.4s ease-out;
}
.cc-capture-form {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e8e8f0;
}
.cc-capture-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f5;
}
.cc-capture-header h4 {
    color: #3902a0;
    font-size: 1.1rem;
    margin-bottom: 5px;
}
.cc-capture-sub {
    color: #6c6c7a;
    font-size: 0.85rem;
}
.cc-form-group {
    margin-bottom: 15px;
    flex: 1;
}
.cc-form-row {
    display: flex;
    gap: 15px;
}
.cc-form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #0e0e1a;
    margin-bottom: 6px;
}
.cc-form-group input, 
.cc-form-group textarea, 
.cc-form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    transition: border-color 0.3s;
    background: #f8f9fc;
}
.cc-form-group input:focus, 
.cc-form-group textarea:focus, 
.cc-form-group select:focus {
    outline: none;
    border-color: #3902a0;
    background: white;
}
.cc-form-group textarea {
    min-height: 80px;
    resize: vertical;
}
.cc-upload-area {
    margin-top: 8px;
    border: 2px dashed #d0d0d8;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: border-color 0.3s;
}
.cc-upload-area:hover {
    border-color: #3902a0;
}
.cc-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.cc-upload-area span {
    font-size: 0.8rem;
    color: #6c6c7a;
    pointer-events: none;
}

/* ACUERDOS LEGALES */
.cc-legal-box {
    background: #f8f9fc;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 4px solid #fd073c;
}
.cc-legal-box p {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #0e0e1a;
}
.cc-check-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    color: #555;
    margin-bottom: 8px;
    cursor: pointer;
}
.cc-check-label input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: #3902a0;
}
.cc-check-label a {
    color: #3902a0;
    text-decoration: underline;
    font-weight: 600;
}

.cc-capture-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #3902a0, #fd073c);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(57, 2, 160, 0.3);
}
.cc-capture-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(57, 2, 160, 0.4);
}
.cc-capture-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 480px) {
    .cc-form-row {
        flex-direction: column;
        gap: 0;
    }
    .cc-capture-form {
        padding: 18px;
    }
}