/* AI Consultant Chat - Frontend Styles v2 */
/* Author: Kuantero SRL */

:root {
    --aicc-primary: #6366f1;
    --aicc-secondary: #8b5cf6;
    --aicc-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --aicc-shadow: 0 10px 40px rgba(99, 102, 241, 0.25);
    --aicc-radius: 16px;
    --aicc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== BUBBLE (expanded preview) ===== */
.aicc-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    padding: 12px 16px;
    border-radius: 60px;
    box-shadow: var(--aicc-shadow), 0 2px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    z-index: 999998;
    max-width: 320px;
    animation: aicc-slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: var(--aicc-font);
}

.aicc-bubble:hover {
    transform: translateY(-2px);
    box-shadow: var(--aicc-shadow), 0 6px 20px rgba(0,0,0,0.12);
}

.aicc-bubble-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--aicc-primary);
}

.aicc-bubble-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aicc-bubble-preview {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.aicc-bubble-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--aicc-primary);
    line-height: 1.2;
}

.aicc-bubble-text {
    font-size: 13px;
    color: #64748b;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.aicc-bubble-close {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e2e8f0;
    border: none;
    font-size: 14px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.aicc-bubble:hover .aicc-bubble-close {
    opacity: 1;
}

.aicc-bubble-close:hover {
    background: #cbd5e1;
    color: #334155;
}

/* ===== MINI BUBBLE ===== */
.aicc-mini-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aicc-gradient);
    box-shadow: var(--aicc-shadow);
    cursor: pointer;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aicc-slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: transform 0.2s ease;
}

.aicc-mini-bubble:hover {
    transform: scale(1.1);
}

.aicc-mini-bubble img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.aicc-mini-pulse {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #22c55e;
    border: 3px solid #fff;
    animation: aicc-pulse 2s infinite;
}

/* ===== WAVE HAND ANIMATION ===== */
.aicc-wave-hand {
    position: absolute;
    top: -14px;
    right: -8px;
    font-size: 26px;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transform: rotate(0deg);
    transition: opacity 0.3s;
}

.aicc-wave-hand.aicc-wave-active {
    opacity: 1;
    animation: aicc-wave-anim 2.5s ease-in-out;
}

.aicc-bubble-wave-hand {
    position: fixed;
    bottom: 70px;
    right: 24px;
    font-size: 30px;
    z-index: 999999;
    pointer-events: none;
    opacity: 0;
    transform: rotate(0deg);
    transition: opacity 0.3s;
}

.aicc-bubble-wave-hand.aicc-wave-active {
    opacity: 1;
    animation: aicc-wave-anim 2.5s ease-in-out;
}

@keyframes aicc-wave-anim {
    0%   { transform: rotate(0deg); opacity: 1; }
    10%  { transform: rotate(14deg); }
    20%  { transform: rotate(-8deg); }
    30%  { transform: rotate(14deg); }
    40%  { transform: rotate(-4deg); }
    50%  { transform: rotate(10deg); }
    60%  { transform: rotate(0deg); }
    70%  { transform: rotate(8deg); }
    80%  { transform: rotate(-4deg); }
    90%  { transform: rotate(4deg); opacity: 1; }
    100% { transform: rotate(0deg); opacity: 0; }
}

/* ===== CHAT WINDOW ===== */
.aicc-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: var(--aicc-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aicc-scaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--aicc-font);
}

/* Header */
.aicc-chat-header {
    background: var(--aicc-gradient);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.aicc-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
}

.aicc-header-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.aicc-header-status {
    display: block;
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}

.aicc-header-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    margin-right: 5px;
}

.aicc-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}

.aicc-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Messages Area */
.aicc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.aicc-messages::-webkit-scrollbar {
    width: 5px;
}
.aicc-messages::-webkit-scrollbar-track {
    background: transparent;
}
.aicc-messages::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.aicc-message {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: aicc-fadeIn 0.3s ease;
}

.aicc-message-ai {
    align-self: flex-start;
}

.aicc-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aicc-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 4px;
}

.aicc-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aicc-message-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.aicc-message-ai .aicc-message-content {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.aicc-message-user .aicc-message-content {
    background: var(--aicc-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Links in AI messages */
.aicc-message-ai .aicc-message-content a {
    color: var(--aicc-primary);
    text-decoration: underline;
    font-weight: 500;
}

.aicc-message-ai .aicc-message-content a:hover {
    opacity: 0.8;
}

/* Typing indicator */
.aicc-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.aicc-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: aicc-typing 1.4s ease-in-out infinite;
}

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

/* ===== CONTACT FORM ===== */
.aicc-contact-form {
    border-top: 1px solid #e2e8f0;
    padding: 12px 16px;
    background: #f8fafc;
    animation: aicc-slideDown 0.3s ease;
}

.aicc-contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.aicc-skip-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
}

.aicc-contact-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aicc-input {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--aicc-font);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.aicc-input:focus {
    border-color: var(--aicc-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.aicc-submit-btn {
    background: var(--aicc-gradient);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.aicc-submit-btn:hover {
    opacity: 0.9;
}

/* ===== INPUT AREA ===== */
.aicc-chat-input-area {
    border-top: 1px solid #e2e8f0;
    padding: 12px 16px;
    flex-shrink: 0;
    background: #fff;
}

.aicc-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 6px 6px 6px 14px;
    border: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.aicc-input-wrapper:focus-within {
    border-color: var(--aicc-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
    background: #fff;
}

.aicc-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    font-family: var(--aicc-font);
    resize: none;
    outline: none;
    min-height: 22px;
    max-height: 100px;
    line-height: 1.5;
    color: #1e293b;
}

.aicc-chat-input::placeholder {
    color: #94a3b8;
}

.aicc-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--aicc-gradient);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.aicc-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.aicc-send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.aicc-char-count {
    text-align: right;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding-right: 4px;
}

/* ===== ANIMATIONS ===== */
@keyframes aicc-slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes aicc-scaleUp {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes aicc-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes aicc-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .aicc-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .aicc-bubble {
        bottom: 16px;
        right: 16px;
        max-width: 280px;
    }

    .aicc-mini-bubble {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}
