/* Chat Bot IA - Chat Widget Styles */

/* Variables */
:root {
    --cbia-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    --cbia-radius: 12px;
    --cbia-transition: all 0.3s ease;
}

/* Widget Container */
.cbia-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.cbia-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.cbia-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.cbia-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cbia-shadow);
    transition: var(--cbia-transition);
    color: #fff;
}

.cbia-chat-toggle:hover {
    transform: scale(1.1);
}

.cbia-chat-toggle svg {
    width: 28px;
    height: 28px;
}

/* Chat Window */
.cbia-chat-window {
    position: absolute;
    bottom: 80px;
    width: 370px;
    max-height: 520px;
    background: #fff;
    border-radius: var(--cbia-radius);
    box-shadow: var(--cbia-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cbiaSlideUp 0.3s ease;
}

.cbia-position-bottom-right .cbia-chat-window {
    right: 0;
}

.cbia-position-bottom-left .cbia-chat-window {
    left: 0;
}

@keyframes cbiaSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.cbia-chat-header {
    padding: 16px 20px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.cbia-chat-title {
    font-weight: 600;
    font-size: 16px;
}

.cbia-chat-minimize {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.cbia-chat-minimize:hover {
    opacity: 1;
}

.cbia-chat-minimize svg {
    width: 20px;
    height: 20px;
}

/* Intro Form */
.cbia-chat-intro {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cbia-intro-message {
    margin-bottom: 20px;
    color: #333;
}

.cbia-form-field {
    margin-bottom: 15px;
}

.cbia-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.cbia-form-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.cbia-form-field input:focus {
    outline: none;
    border-color: var(--cbia-primary, #0073aa);
}

.cbia-start-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.cbia-start-btn:hover {
    opacity: 0.9;
}

/* Messages Area */
.cbia-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    min-height: 250px;
    max-height: 300px;
    background: #f8f9fa;
}

/* Message Bubbles */
.cbia-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    animation: cbiaFadeIn 0.3s ease;
}

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

.cbia-message-user {
    align-items: flex-end;
}

.cbia-message-assistant {
    align-items: flex-start;
}

.cbia-message-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
}

.cbia-message-user .cbia-message-bubble {
    background: var(--cbia-primary, #0073aa);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cbia-message-assistant .cbia-message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cbia-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 8px;
}

/* Typing Indicator */
.cbia-typing {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
}

.cbia-typing-dot {
    width: 8px;
    height: 8px;
    background: #bbb;
    border-radius: 50%;
    margin-right: 4px;
    animation: cbiaTyping 1.4s infinite;
}

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

.cbia-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

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

/* Input Area */
.cbia-chat-input-area {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.cbia-chat-input-area form {
    display: flex;
    gap: 8px;
}

.cbia-chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.cbia-chat-input-area input:focus {
    border-color: var(--cbia-primary, #0073aa);
}

.cbia-chat-input-area button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.cbia-chat-input-area button:hover {
    opacity: 0.9;
}

.cbia-chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cbia-chat-input-area button svg {
    width: 18px;
    height: 18px;
}

/* Footer */
.cbia-chat-footer {
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.cbia-chat-footer small {
    color: #999;
    font-size: 11px;
}

/* Error Message */
.cbia-error {
    background: #fee;
    color: #c00;
    padding: 10px;
    margin: 10px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* Responsive - Tablets */
@media (max-width: 768px) {
    .cbia-chat-window {
        width: 340px;
        max-height: 65vh;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    .cbia-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .cbia-position-bottom-right,
    .cbia-position-bottom-left {
        right: 10px;
        left: auto;
    }

    .cbia-chat-toggle {
        width: 50px;
        height: 50px;
    }

    .cbia-chat-toggle svg {
        width: 24px;
        height: 24px;
    }

    .cbia-chat-window {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 70px;
        width: auto;
        max-width: none;
        max-height: none;
        height: auto;
        border-radius: 12px;
        transform: none;
    }

    .cbia-position-bottom-right .cbia-chat-window,
    .cbia-position-bottom-left .cbia-chat-window {
        right: 10px;
        left: 10px;
        transform: none;
    }

    .cbia-chat-header {
        padding: 12px 15px;
        border-radius: 12px 12px 0 0;
    }

    .cbia-chat-title {
        font-size: 15px;
    }

    .cbia-chat-messages {
        min-height: 150px;
        max-height: none;
        flex: 1;
        padding: 10px;
    }

    .cbia-message-bubble {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 14px;
    }

    .cbia-chat-input-area {
        padding: 10px;
    }

    .cbia-chat-input-area input {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .cbia-chat-input-area button {
        width: 38px;
        height: 38px;
    }

    .cbia-chat-intro {
        padding: 15px;
    }

    .cbia-form-field input {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .cbia-start-btn {
        padding: 12px;
        font-size: 15px;
    }

    .cbia-chat-footer {
        padding: 6px;
    }

    .cbia-chat-footer small {
        font-size: 10px;
    }

    .cbia-typing {
        padding: 8px 10px;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .cbia-chat-window {
        top: 5px;
        left: 5px;
        right: 5px;
        bottom: 65px;
    }

    .cbia-chat-header {
        padding: 10px 12px;
    }

    .cbia-message-bubble {
        max-width: 92%;
        padding: 7px 10px;
        font-size: 13px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .cbia-chat-window {
        top: 5px;
        bottom: 60px;
        max-height: none;
    }

    .cbia-chat-messages {
        min-height: 100px;
    }

    .cbia-chat-header {
        padding: 8px 12px;
    }

    .cbia-chat-input-area {
        padding: 8px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .cbia-chat-window {
        background: #1e1e1e;
    }

    .cbia-chat-messages {
        background: #2d2d2d;
    }

    .cbia-message-assistant .cbia-message-bubble {
        background: #3d3d3d;
        color: #eee;
    }

    .cbia-chat-input-area {
        background: #1e1e1e;
        border-top-color: #3d3d3d;
    }

    .cbia-chat-input-area input {
        background: #2d2d2d;
        border-color: #3d3d3d;
        color: #eee;
    }

    .cbia-form-field input {
        background: #2d2d2d;
        border-color: #3d3d3d;
        color: #eee;
    }

    .cbia-form-field label,
    .cbia-intro-message {
        color: #eee;
    }

    .cbia-chat-footer {
        background: #2d2d2d;
        border-top-color: #3d3d3d;
    }
}

/* Scrollbar */
.cbia-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.cbia-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cbia-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.cbia-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
