/* ===========================
   IT Sales Chatbot - Styles
   =========================== */

/* Variables inyectadas por JS */
:root {
    --itsc-primary: #0a192f;
    --itsc-accent: #64ffda;
    --itsc-accent-hover: #4fd1c5;
    --itsc-bg: #ffffff;
    --itsc-surface: #f8fafc;
    --itsc-border: #e2e8f0;
    --itsc-text: #1e293b;
    --itsc-text-muted: #64748b;
    --itsc-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    --itsc-radius: 18px;
    --itsc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --itsc-z: 999999;
}

/* Contenedor */
#itsc-chat-container {
    position: fixed;
    z-index: var(--itsc-z);
    font-family: var(--itsc-font);
    box-sizing: border-box;
}

#itsc-chat-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#itsc-chat-container.itsc-position-bottom-right {
    bottom: 24px;
    right: 24px;
}

#itsc-chat-container.itsc-position-bottom-left {
    bottom: 24px;
    left: 24px;
}

/* ===== BOTÓN FLOTANTE ===== */
#itsc-chat-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--itsc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(100, 255, 218, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    animation: itsc-pulse 3s infinite;
    outline: none;
}

#itsc-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 0 8px rgba(100, 255, 218, 0.1);
    animation: none;
}

#itsc-chat-toggle:focus-visible {
    outline: 3px solid var(--itsc-accent);
    outline-offset: 3px;
}

@keyframes itsc-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 0 0 0 rgba(100,255,218,0.4); }
    50% { box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 0 0 10px rgba(100,255,218,0); }
}

.itsc-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.itsc-toggle-icon svg {
    width: 26px;
    height: 26px;
    color: var(--itsc-accent);
    stroke: var(--itsc-accent);
}

.itsc-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: itsc-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes itsc-bounce {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* ===== PANEL DEL CHAT ===== */
#itsc-chat-panel {
    position: absolute;
    bottom: 78px;
    width: 380px;
    max-height: 600px;
    background: var(--itsc-bg);
    border-radius: var(--itsc-radius);
    box-shadow: var(--itsc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--itsc-border);
    transform-origin: bottom right;
    animation: itsc-open 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.itsc-position-bottom-right #itsc-chat-panel {
    right: 0;
}

.itsc-position-bottom-left #itsc-chat-panel {
    left: 0;
    transform-origin: bottom left;
}

#itsc-chat-panel[hidden] {
    display: none;
}

@keyframes itsc-open {
    0% { transform: scale(0.8) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ===== HEADER ===== */
.itsc-chat-header {
    background: var(--itsc-primary);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.itsc-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(100, 255, 218, 0.15);
    border: 2px solid rgba(100, 255, 218, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.itsc-chat-avatar svg {
    width: 22px;
    height: 22px;
    fill: var(--itsc-accent);
}

.itsc-chat-header-info {
    flex: 1;
}

.itsc-agent-name {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.itsc-agent-status {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.itsc-status-dot {
    width: 7px;
    height: 7px;
    background: var(--itsc-accent);
    border-radius: 50%;
    display: inline-block;
    animation: itsc-status-pulse 2s infinite;
}

@keyframes itsc-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.itsc-close-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.itsc-close-btn:hover {
    background: rgba(255,255,255,0.18);
}

.itsc-close-btn svg {
    width: 16px;
    height: 16px;
    color: rgba(255,255,255,0.8);
    stroke: rgba(255,255,255,0.8);
}

/* ===== MENSAJES ===== */
.itsc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: var(--itsc-surface);
}

.itsc-messages::-webkit-scrollbar { width: 4px; }
.itsc-messages::-webkit-scrollbar-track { background: transparent; }
.itsc-messages::-webkit-scrollbar-thumb { background: var(--itsc-border); border-radius: 2px; }

.itsc-msg {
    max-width: 85%;
    animation: itsc-msg-in 0.25s ease-out;
}

@keyframes itsc-msg-in {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.itsc-msg-bot { align-self: flex-start; }
.itsc-msg-user { align-self: flex-end; }

.itsc-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
}

.itsc-msg-bot .itsc-msg-bubble {
    background: #ffffff;
    color: var(--itsc-text);
    border: 1px solid var(--itsc-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.itsc-msg-user .itsc-msg-bubble {
    background: var(--itsc-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.itsc-msg-time {
    font-size: 10px;
    color: var(--itsc-text-muted);
    margin-top: 4px;
    padding: 0 2px;
}

.itsc-msg-user .itsc-msg-time { text-align: right; }

/* Typing indicator */
.itsc-typing {
    align-self: flex-start;
}

.itsc-typing-bubble {
    background: #ffffff;
    border: 1px solid var(--itsc-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.itsc-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--itsc-text-muted);
    border-radius: 50%;
    animation: itsc-typing 1.2s infinite;
}

.itsc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.itsc-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ===== ACCIONES RÁPIDAS ===== */
.itsc-quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: var(--itsc-bg);
    border-top: 1px solid var(--itsc-border);
    flex-wrap: wrap;
}

.itsc-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    font-family: var(--itsc-font);
}

.itsc-cta-calendar {
    background: var(--itsc-primary);
    color: #ffffff;
}

.itsc-cta-calendar:hover {
    background: #112240;
    color: var(--itsc-accent);
    transform: translateY(-1px);
}

.itsc-cta-whatsapp {
    background: #25d366;
    color: #ffffff;
}

.itsc-cta-whatsapp:hover {
    background: #1db954;
    color: #ffffff;
    transform: translateY(-1px);
}

.itsc-quick-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ===== INPUT AREA ===== */
.itsc-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    background: var(--itsc-bg);
    border-top: 1px solid var(--itsc-border);
    flex-shrink: 0;
}

#itsc-input {
    flex: 1;
    border: 1.5px solid var(--itsc-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    font-family: var(--itsc-font);
    color: var(--itsc-text);
    resize: none;
    line-height: 1.5;
    min-height: 40px;
    max-height: 110px;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--itsc-bg);
    outline: none;
}

#itsc-input:focus {
    border-color: var(--itsc-primary);
    box-shadow: 0 0 0 3px rgba(10, 25, 47, 0.08);
}

#itsc-input::placeholder {
    color: var(--itsc-text-muted);
}

#itsc-send {
    width: 40px;
    height: 40px;
    background: var(--itsc-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    outline: none;
}

#itsc-send:hover:not(:disabled) {
    background: var(--itsc-accent);
    transform: scale(1.05);
}

#itsc-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#itsc-send svg {
    width: 17px;
    height: 17px;
    color: var(--itsc-accent);
    stroke: var(--itsc-accent);
}

#itsc-send:hover:not(:disabled) svg {
    color: var(--itsc-primary);
    stroke: var(--itsc-primary);
}

/* ===== POWERED BY ===== */
.itsc-powered-by {
    text-align: center;
    font-size: 10px;
    color: var(--itsc-text-muted);
    padding: 6px 0 8px;
    background: var(--itsc-bg);
    letter-spacing: 0.02em;
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 480px) {
    #itsc-chat-panel {
        width: calc(100vw - 24px);
        max-height: 80vh;
        bottom: 74px;
    }

    .itsc-position-bottom-right #itsc-chat-panel {
        right: -4px;
    }

    .itsc-position-bottom-left #itsc-chat-panel {
        left: -4px;
    }

    #itsc-chat-container.itsc-position-bottom-right {
        bottom: 16px;
        right: 16px;
    }

    #itsc-chat-container.itsc-position-bottom-left {
        bottom: 16px;
        left: 16px;
    }
}
