/**
 * Colegio Ciudad de Bogotá Chatbot v3.5 - Styles
 * Icono corregido y visible
 * Soporte para HTML en respuestas
 * Estilos para mensajes de advertencia
 * Estilos para imágenes y mapas
 */

#ccdb-chatbot-widget {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#ccdb-chatbot-widget[data-position="right"] {
    right: 20px;
}

#ccdb-chatbot-widget[data-position="left"] {
    left: 20px;
}

/* ============================================
   BOTÓN FLOTANTE - CORREGIDO
   ============================================ */
.ccdb-chatbot-toggle {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25), 0 3px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    padding: 0;
}

.ccdb-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.3), 0 5px 15px rgba(0, 0, 0, 0.2);
}

.ccdb-chatbot-toggle:active {
    transform: scale(0.95);
}

/* Animación de pulso */
.ccdb-chatbot-toggle::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: ccdb-pulse 2s infinite;
    z-index: -1;
    opacity: 0.5;
}

@keyframes ccdb-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Icono del botón - ESTILO DIRECTO */
.ccdb-chatbot-toggle svg {
    width: 32px;
    height: 32px;
    display: block;
}

.ccdb-chatbot-toggle svg path {
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.ccdb-chatbot-toggle svg line {
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
}

/* Badge de notificación */
.ccdb-chatbot-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    border: 2px solid white;
    z-index: 3;
}

/* ============================================
   VENTANA DE CHAT
   ============================================ */
.ccdb-chatbot-window {
    position: absolute;
    bottom: 80px;
    width: 400px;
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#ccdb-chatbot-widget[data-position="right"] .ccdb-chatbot-window {
    right: 0;
}

#ccdb-chatbot-widget[data-position="left"] .ccdb-chatbot-window {
    left: 0;
}

.ccdb-chatbot-window.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* ============================================
   HEADER
   ============================================ */
.ccdb-chatbot-header {
    padding: 18px 20px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.ccdb-chatbot-header-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ccdb-chatbot-header-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.ccdb-chatbot-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ccdb-chatbot-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.ccdb-chatbot-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: ccdb-blink 2s infinite;
}

@keyframes ccdb-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ccdb-chatbot-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ccdb-chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ccdb-chatbot-close-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

.ccdb-chatbot-close-btn svg line {
    stroke: white;
    stroke-width: 2.5;
    stroke-linecap: round;
}

/* ============================================
   MENSAJES
   ============================================ */
.ccdb-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    min-height: 320px;
    max-height: 420px;
}

.ccdb-chatbot-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: ccdb-slideIn 0.3s ease;
}

@keyframes ccdb-slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ccdb-chatbot-message.user {
    justify-content: flex-end;
}

.ccdb-chatbot-message.user .ccdb-chatbot-message-content {
    background: var(--ccdb-primary-color, #2563eb);
    color: white;
    border-radius: 20px 20px 6px 20px;
}

.ccdb-chatbot-message.assistant .ccdb-chatbot-message-content {
    background: white;
    color: #1e293b;
    border-radius: 20px 20px 20px 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.ccdb-chatbot-message-content {
    padding: 14px 18px;
    max-width: 85%;
    line-height: 1.6;
    font-size: 14px;
}

.ccdb-chatbot-message-content p {
    margin: 0 0 10px 0;
}

.ccdb-chatbot-message-content p:last-child {
    margin-bottom: 0;
}

.ccdb-chatbot-message-content strong {
    font-weight: 600;
    color: var(--ccdb-primary-color, #2563eb);
}

.ccdb-chatbot-message.user .ccdb-chatbot-message-content strong {
    color: white;
}

/* Enlaces en mensajes */
.ccdb-chatbot-message-content a {
    color: var(--ccdb-primary-color, #2563eb);
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.4);
    text-underline-offset: 2px;
    transition: all 0.2s;
    word-break: break-word;
}

.ccdb-chatbot-message-content a:hover {
    text-decoration-color: var(--ccdb-primary-color, #2563eb);
}

.ccdb-chatbot-message.user .ccdb-chatbot-message-content a {
    color: #ffffff;
    text-decoration-color: rgba(255, 255, 255, 0.5);
}

.ccdb-chatbot-message.user .ccdb-chatbot-message-content a:hover {
    text-decoration-color: #ffffff;
}

.ccdb-chatbot-timestamp {
    font-size: 10px;
    opacity: 0.5;
    display: block;
    margin-top: 8px;
    text-align: right;
}

/* Avatar del asistente */
.ccdb-chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ccdb-chatbot-avatar svg {
    width: 20px;
    height: 20px;
    fill: white;
    display: block;
}

/* Typing indicator */
.ccdb-chatbot-typing {
    padding: 18px;
}

.ccdb-chatbot-typing-indicator {
    display: flex;
    gap: 5px;
}

.ccdb-chatbot-typing-indicator span {
    width: 9px;
    height: 9px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ccdb-typing 1.4s infinite;
}

.ccdb-chatbot-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ccdb-chatbot-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ccdb-typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   INPUT
   ============================================ */
.ccdb-chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: center;
}

.ccdb-chatbot-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ccdb-chatbot-input:focus {
    border-color: var(--ccdb-primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ccdb-chatbot-input::placeholder {
    color: #94a3b8;
}

.ccdb-chatbot-send-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.ccdb-chatbot-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

.ccdb-chatbot-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
    display: block;
}

/* ============================================
   FOOTER
   ============================================ */
.ccdb-chatbot-footer {
    padding: 10px 16px;
    background: #f8fafc;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid #e2e8f0;
}

.ccdb-chatbot-footer a {
    color: var(--ccdb-primary-color, #2563eb);
    text-decoration: none;
    font-weight: 500;
}

/* ============================================
   FORMULARIO DE CONTACTO
   ============================================ */
.ccdb-chatbot-form {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}

.ccdb-chatbot-form h4 {
    margin: 0 0 12px 0;
    color: #1e293b;
    font-size: 14px;
}

.ccdb-chatbot-form-group {
    margin-bottom: 12px;
}

.ccdb-chatbot-form-group label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.ccdb-chatbot-form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ccdb-chatbot-form-group input:focus {
    border-color: var(--ccdb-primary-color, #2563eb);
}

.ccdb-chatbot-form-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ccdb-chatbot-form-submit:hover {
    opacity: 0.9;
}

.ccdb-chatbot-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ccdb-chatbot-form-note {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    margin-top: 8px;
}

/* Mensaje de éxito */
.ccdb-success-message {
    background: #dcfce7;
    color: #166534;
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    #ccdb-chatbot-widget {
        bottom: 15px;
    }

    #ccdb-chatbot-widget[data-position="right"] {
        right: 15px;
    }

    #ccdb-chatbot-widget[data-position="left"] {
        left: 15px;
    }

    .ccdb-chatbot-window {
        width: calc(100vw - 30px);
        bottom: 75px;
        border-radius: 16px;
    }

    .ccdb-chatbot-toggle {
        width: 58px;
        height: 58px;
    }

    .ccdb-chatbot-toggle svg {
        width: 28px;
        height: 28px;
    }

    .ccdb-chatbot-messages {
        min-height: 280px;
        max-height: 350px;
    }
}

/* ============================================
   SCROLLBAR PERSONALIZADO
   ============================================ */
.ccdb-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.ccdb-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ccdb-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ccdb-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   MENSAJES DE ADVERTENCIA (CONTENIDO BLOQUEADO)
   ============================================ */
.ccdb-chatbot-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
    border: 1px solid #f59e0b !important;
    border-left: 4px solid #d97706 !important;
}

.ccdb-chatbot-warning p {
    color: #92400e !important;
}

.ccdb-chatbot-warning strong {
    color: #b45309 !important;
}

/* ============================================
   IMÁGENES EN MENSAJES
   ============================================ */
.ccdb-chatbot-message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Imagen con enlace */
.ccdb-chatbot-message-content a img {
    transition: transform 0.2s, box-shadow 0.2s;
}

.ccdb-chatbot-message-content a:hover img {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* ============================================
   IFRAMES (MAPAS, VIDEOS)
   ============================================ */
.ccdb-chatbot-message-content iframe {
    max-width: 100%;
    border-radius: 8px;
    margin: 10px 0;
    display: block;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Mapa de Google responsive */
.ccdb-chatbot-map-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin: 10px 0;
}

.ccdb-chatbot-map-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Contenedor para multimedia */
.ccdb-chatbot-media {
    margin: 10px 0;
    text-align: center;
}

.ccdb-chatbot-media img {
    display: inline-block;
    max-height: 200px;
    object-fit: cover;
}
