/**
 * Chatbot Widget Styles
 * JP Contábil - Assistente Virtual
 */

/* CSS Variables */
:root {
    --chatbot-primary: #1e3a5f;
    --chatbot-secondary: #f7941d;
    --chatbot-bg: #ffffff;
    --chatbot-text: #333333;
    --chatbot-text-light: #666666;
    --chatbot-border: #e5e7eb;
    --chatbot-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --chatbot-shadow-hover: 0 15px 50px rgba(0, 0, 0, 0.25);
    --chatbot-radius: 16px;
    --chatbot-radius-sm: 12px;
}

/* Container */
#chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, sans-serif;
}

/* Toggle Button */
.chatbot-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        var(--chatbot-primary) 0%,
        #2c5282 100%
    );
    border: 3px solid var(--chatbot-secondary);
    cursor: pointer;
    box-shadow: var(--chatbot-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--chatbot-shadow-hover);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: contain;
}

/* Pulse animation */
.chatbot-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--chatbot-secondary);
    opacity: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow-hover);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Header */
.chatbot-header {
    background: linear-gradient(
        135deg,
        var(--chatbot-primary) 0%,
        #2c5282 100%
    );
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    padding: 4px;
    object-fit: contain;
}

.chatbot-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: white;
}

.chatbot-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Header Actions */
.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-new {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.chatbot-new:hover {
    background: var(--chatbot-secondary);
    transform: scale(1.1);
}

/* Fullscreen Button */
.chatbot-fullscreen {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.chatbot-fullscreen:hover {
    background: var(--chatbot-secondary);
    transform: scale(1.1);
}

.chatbot-fullscreen .hidden {
    display: none;
}

/* Hide fullscreen button on mobile */
.hidden-mobile {
    display: flex;
}

@media (max-width: 768px) {
    .hidden-mobile {
        display: none !important;
    }
}

/* Fullscreen Mode */
.chatbot-window.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    z-index: 10000;
    animation: fullscreenIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fullscreenIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chatbot-window.fullscreen .chatbot-header {
    padding: 20px 32px;
}

.chatbot-window.fullscreen .chatbot-header-avatar {
    width: 55px;
    height: 55px;
}

.chatbot-window.fullscreen .chatbot-title {
    font-size: 20px;
}

.chatbot-window.fullscreen .chatbot-status {
    font-size: 14px;
}

.chatbot-window.fullscreen .chatbot-messages {
    padding: 32px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chatbot-window.fullscreen .chatbot-message {
    max-width: 70%;
}

.chatbot-window.fullscreen .chatbot-message-content {
    padding: 18px 24px;
    font-size: 16px;
}

.chatbot-window.fullscreen .chatbot-message-avatar {
    width: 48px;
    height: 48px;
}

.chatbot-window.fullscreen .chatbot-typing {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 32px 20px;
}

.chatbot-window.fullscreen .chatbot-input-area {
    padding: 24px 32px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.chatbot-window.fullscreen .chatbot-input {
    padding: 16px 24px;
    font-size: 16px;
}

.chatbot-window.fullscreen .chatbot-send {
    width: 54px;
    height: 54px;
}

.chatbot-window.fullscreen .chatbot-footer {
    padding: 14px 32px;
    font-size: 13px;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Messages */
.chatbot-message {
    display: flex;
    gap: 12px;
    max-width: 90%;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-bot {
    align-self: flex-start;
}

.chatbot-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.chatbot-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: contain;
    background: white;
    padding: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-message-content {
    background: white;
    padding: 14px 18px;
    border-radius: var(--chatbot-radius-sm);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 14px;
    line-height: 1.6;
    color: var(--chatbot-text);
}

.chatbot-message-content p {
    margin: 0 0 8px 0;
}

.chatbot-message-content p:last-child {
    margin-bottom: 0;
}

.chatbot-message-content strong {
    color: var(--chatbot-primary);
    font-weight: 600;
}

.chatbot-message-bot .chatbot-message-content {
    border-bottom-left-radius: 4px;
}

.chatbot-message-user .chatbot-message-avatar {
    display: none;
}

.chatbot-message-user .chatbot-message-content {
    background: linear-gradient(
        135deg,
        var(--chatbot-primary) 0%,
        #2c5282 100%
    );
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-user .chatbot-message-content strong {
    color: var(--chatbot-secondary);
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 12px;
    padding: 0 20px 16px;
    align-items: center;
}

.chatbot-typing.hidden {
    display: none;
}

.chatbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: white;
    border-radius: var(--chatbot-radius-sm);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chatbot-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.chatbot-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.chatbot-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%,
    60%,
    100% {
        transform: translateY(0);
        background: #94a3b8;
    }
    30% {
        transform: translateY(-8px);
        background: var(--chatbot-secondary);
    }
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--chatbot-border);
    border-radius: 25px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-send {
    width: 46px;
    height: 46px;
    background: linear-gradient(
        135deg,
        var(--chatbot-secondary) 0%,
        #e87d00 100%
    );
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(247, 148, 29, 0.4);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
.chatbot-footer {
    padding: 10px 20px;
    background: #f1f5f9;
    text-align: center;
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

/* Error Message */
.chatbot-error {
    background: #fef2f2 !important;
    border-left: 3px solid #ef4444;
}

.chatbot-error p {
    color: #dc2626 !important;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chatbot-container {
        bottom: 16px;
        right: 16px;
    }

    .chatbot-toggle {
        width: 60px;
        height: 60px;
    }

    .chatbot-avatar {
        width: 42px;
        height: 42px;
    }

    .chatbot-window {
        bottom: 80px;
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: 600px;
        right: -8px;
    }

    .chatbot-header {
        padding: 14px 16px;
    }

    .chatbot-header-avatar {
        width: 40px;
        height: 40px;
    }

    .chatbot-title {
        font-size: 15px;
    }

    .chatbot-messages {
        padding: 16px;
    }

    .chatbot-message-content {
        padding: 12px 14px;
        font-size: 13px;
    }

    .chatbot-input-area {
        padding: 12px 16px;
    }

    .chatbot-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chatbot-send {
        width: 42px;
        height: 42px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chatbot-messages {
        background: #1e293b;
    }

    .chatbot-message-bot .chatbot-message-content {
        background: #334155;
        color: #e2e8f0;
    }

    .chatbot-message-bot .chatbot-message-content strong {
        color: var(--chatbot-secondary);
    }

    .chatbot-typing-indicator {
        background: #334155;
    }

    .chatbot-input-area {
        background: #1e293b;
        border-top-color: #334155;
    }

    .chatbot-input {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }

    .chatbot-input:focus {
        border-color: var(--chatbot-secondary);
    }

    .chatbot-footer {
        background: #0f172a;
        color: #94a3b8;
    }
}
