/* FloatingChatBot.css - WhatsApp-inspired theme */

.floating-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: Montesserat, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.floating-chat-window {
    transition: all 0.3s ease-in-out;
}

.floating-chat-window.chat-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.floating-chat-window.chat-closed {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Floating Chat Window */
.floating-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 25.125rem;
    height: 42.4375rem;
    border-radius: 1.25rem;
    background: #efe7da;

    /* White card shadow */
    box-shadow: 3px 3px 20px 0 rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Chat Header */
.chat-header-floating {
    background: #004d37;
    color: white;
    height: 4.5rem;

    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

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

.avatar-container {
    position: relative;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    background-image: url('naturo.png');
    background-size: cover;
    background-position: center;
    border-radius: 9.375rem;
    border: 2px solid var(--Soft-Green, #ddedd0);

    display: flex;
    align-items: center;
    justify-content: center;
}

.status-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.online-indicator {
    position: relative;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

/* Connected state (green) */
.online-indicator.connected {
    background: #6ea44c;
    border: 4px solid #165e3b;
    animation: pulse 2s infinite;
}

/* Disconnected state (red) */
.online-indicator.disconnected {
    background: #e53e3e;
    border: 4px solid #7f1d1d;
    animation: pulse-red 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(229, 62, 62, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(229, 62, 62, 0);
    }
}

.header-text {
    margin-top: 10px;
}

.header-text h3 {
    margin: 0;
    color: var(--Clarity-White, #fff);
    font-size: 1rem;
    font-style: normal;
    font-weight: 600;
    line-height: 1.8rem; /* 180% */
}

.status-text {
    color: var(--Clarity-White, #fff);

    font-size: 0.75rem;
    font-style: normal;
    font-weight: 400;
    line-height: 110%; /* 0.825rem */
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-session-btn,
.close-btn {
    background: none;
    border-radius: 50%;
    border: none;
    color: var(--Regenera-Clarity-White, #fff);
}

.new-session-btn:hover,
.close-btn:hover {
    cursor: pointer;
    transform: scale(1.1);
    border-radius: 50%;
}

/* Chat Content */
.chat-content-floating {
    flex: 1;
    background: #efe7da;
    position: relative;
    overflow: hidden;
}

/* Override ChatComponent styles for floating version */
.floating-chat-component {
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.floating-chat-component .chat-header {
    display: none;
}

.floating-chat-component .chat-messages {
    background: #efe7da;
    padding: 16px;
}

.floating-chat-component .message.user .message-text {
    border-radius: 1.25rem 1.25rem 0 1.25rem;
    background: var(--Regenera-Action-Green-hover, #497d28);
    box-shadow: 2px 4px 15px 0 rgba(0, 0, 0, 0.05);

    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;

    color: var(--Regenera-Clarity-White, #fff);
    font-size: 1rem;
    font-style: normal;
    font-weight: 400;
}

.floating-chat-component .message.assistant .message-text {
    background: #ffffff !important;
    color: #303030 !important;
    border: 1px solid #e4e6ea !important;

    color: var(--Regenera-Trust-Green, #004d37);

    /* Desktop body */
    font-size: 1rem;
    font-style: normal;
    font-weight: 400;
}

.floating-chat-component .message.system .message-text {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.floating-chat-component .message-avatar {
    display: flex;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #ffffff;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message.assistant .message-avatar {
    background-image: url('naturo.png');
    background-size: cover;
    background-position: center;
    color: transparent;
    font-size: 0;
    line-height: 0;
}

.message.user .message-avatar {
    display: none;
    background: none;
    color: transparent;
    font-size: 0;
    line-height: 0;
}

.floating-chat-component .message {
    max-width: 85%;
    gap: 4px;
}

.floating-chat-component .chat-input-container {
    background: #efe7da;
    border-top: 1px solid #efe7da;
    padding: 8px 10px;
}

.floating-chat-component .chat-input-wrapper {
    padding: 6px 8px;
    border-radius: 1.25rem;
    border: 1px solid var(--regenera-earth-40, #e0d2bd);
    background: var(--Regenera-Clarity-White, #fff);
}

.floating-chat-component .chat-input::placeholder {
    color: #cbb491; /* Same color as text but with opacity */
}

.floating-chat-component .chat-input {
    font-size: 1rem;
    font-style: normal;
    font-weight: 400;
    line-height: 180%; /* 1.8rem */
}

.floating-chat-component .send-button {
    background: #497d28;
    width: 30px;
    height: 30px;
}

.floating-chat-component .send-button:hover:not(:disabled) {
    background: #497d28;
}

.floating-chat-component .typing-indicator {
    background: #ffffff !important;
    border: 1px solid #e4e6ea !important;
}

/* Credits Status Bar */
.credits-status-bar {
    background: #f0f2f5;
    padding: 8px 16px;
    border-top: 1px solid #e4e6ea;
    text-align: center;
    font-size: 12px;
}

.credits-remaining {
    color: #25d366;
    font-weight: 500;
}

.credits-exhausted {
    color: #e53e3e;
    font-weight: 500;
}

/* Floating Button */
.floating-chat-button {
    width: 3.25rem;
    height: 3.25rem;
    flex-shrink: 0;
    border-radius: 0.68056rem;
    background: #6ea44c;
    box-shadow: 1.633px 1.633px 5.889px 0 #efefef;

    border: none;
    color: white;

    cursor: pointer;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-2px);
    }
    75% {
        transform: translateX(2px);
    }
}

.floating-chat-button:hover {
    transform: scale(1.1) translateY(-4px);
    background: #497d28;
    box-shadow: 1px 2px 5px #efefef;
}

.floating-chat-button.open {
    background: #497d28;
    animation: none;
    transform: rotate(180deg);
}

.chat-icon,
.close-icon,
.exhausted-icon {
    transition: all 0.2s ease;
}

.chat-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-icon .icon-default,
.chat-icon .icon-hover {
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.2s ease-in-out;
    background-image: url('callout.png');
    width: 26px;
    height: 24px;
}

.chat-icon .icon-hover {
    opacity: 0;
}

.floating-chat-button:hover .chat-icon .icon-default {
    opacity: 0;
}

.floating-chat-button:hover .chat-icon .icon-hover {
    opacity: 1;
    background-image: url('callout_naturo.png');

    width: 26px;
    height: 24px;
}

/* Ensure the button maintains its size during hover */
.floating-chat-button .chat-icon {
    width: 26px;
    height: 24px;
}

.floating-chat-button.open .close-icon {
    transform: rotate(180deg);
}

/* Disconnected state for floating button */
.floating-chat-button.disconnected {
    background: #e53e3e;
    animation: shake 1s ease-in-out infinite;
}

.floating-chat-button.disconnected:hover {
    background: #dc2626;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: bounce 2s infinite;
}

.notification-badge.new-message {
    background: #ff6b35;
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes bounce {
    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

@keyframes pulse-glow {
    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 8px rgba(255, 107, 53, 0);
    }
}

/* Credits exhausted message styling */
.floating-chat-component .message.credits-exhausted .message-text {
    background: #fff3cd !important;
    color: #856404 !important;
    border: 1px solid #ffeaa7 !important;
    text-align: center !important;
    font-weight: 500 !important;
}

.floating-chat-component .credits-warning {
    background: #fff3cd !important;
    color: #856404 !important;
    border: 1px solid #ffeaa7 !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    margin-bottom: 8px !important;
    text-align: center !important;
    font-size: 12px !important;
}

/* Message count display in header */
.message-counter {
    position: absolute;
    top: 8px;
    right: 60px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 480px) {
    .floating-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        
    }

    .floating-chat-button {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    .chat-header-floating {
        padding: 14px 16px;
    }

    .floating-chat-component .chat-messages {
        padding: 12px !important;
    }

    .floating-chat-component .chat-input-container {
        padding: 10px 12px !important;
    }
}

@media (max-width: 360px) {
    .floating-chat-window {
        width: calc(100vw - 20px);
        
        bottom: 75px;
    }

    .floating-chat-button {
        bottom: 10px;
        right: 10px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .floating-chat-button {
        border: 2px solid #000;
    }

    .floating-chat-window {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .floating-chat-button {
        animation: none;
    }

    .notification-badge {
        animation: none;
    }

    .online-indicator.connected {
        animation: none;
    }

    .online-indicator.disconnected {
        animation: none;
    }

    .floating-chat-window {
        animation: none;
    }

    .floating-chat-button.disconnected {
        animation: none;
    }
}

/* Focus indicators for accessibility */
.floating-chat-button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.new-session-btn:focus-visible,
.close-btn:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.8);
    outline-offset: 1px;
}

.start-chat-button:focus,
.minimize-button:focus,
.floating-chat-button:focus {
    outline: 2px solid #497d28;
    outline-offset: 2px;
}
