/**
 * Cure Assistant Chat Styles
 *
 * @package CureAssistant
 */

/* Variables (can be overridden by inline styles) */
:root {
    --ca-primary-color: #2ba77b;
    --ca-secondary-color: #EC7F0B;
    --ca-bot-text-color: #000000;
    --ca-user-text-color: #0A281D;
}

/* Reset and Base */
#cure-assistant-wrapper * {
    box-sizing: border-box;
}

/* Chat Bubble */
#cure-assistant-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--ca-primary-color);
    border-radius: 50%;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

#cure-assistant-bubble:hover {
    transform: scale(1.1);
}

#cure-assistant-bubble.ca-bubble-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.ca-bubble-icon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ca-bubble-icon-img {
    object-fit: cover;
    border-radius: 50%;
    /* Width and height set via inline styles */
}

/* Bubble Animation Rings */
.ca-bubble-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ca-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--ca-primary-color);
    border-radius: 50%;
    opacity: 0;
}

/* Bubble Entry Animation */
@keyframes bubbleWobble {
    0% {
        transform: scale(0) rotate(0deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    75% {
        transform: scale(0.95) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

@keyframes ringExpand {
    0% {
        width: 60px;
        height: 60px;
        opacity: 0.8;
    }
    100% {
        width: 120px;
        height: 120px;
        opacity: 0;
    }
}

#cure-assistant-bubble.ca-bubble-enter {
    animation: bubbleWobble 0.8s ease-out;
}

#cure-assistant-bubble.ca-bubble-enter .ca-ring-1 {
    animation: ringExpand 1s ease-out 0s;
}

#cure-assistant-bubble.ca-bubble-enter .ca-ring-2 {
    animation: ringExpand 1s ease-out 0.15s;
}

#cure-assistant-bubble.ca-bubble-enter .ca-ring-3 {
    animation: ringExpand 1s ease-out 0.3s;
}

/* Modal */
#cure-assistant-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#cure-assistant-modal.ca-modal-open {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    opacity: 1;
}

.ca-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 400px;
    height: 600px;
    display: flex;
    flex-direction: column;
    margin: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

#cure-assistant-modal.ca-modal-open .ca-modal-content {
    transform: translateX(0);
}

/* Modal Header */
.ca-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ca-primary-color);
    color: #fff;
    border-radius: 12px 12px 0 0;
}

.ca-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.ca-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.ca-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.ca-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
.ca-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f9f9f9;
}

.ca-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

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

.ca-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    overflow: hidden;
}

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

.ca-message-avatar i {
    font-size: 16px;
    color: #666;
}

.ca-message-content {
    flex: 1;
    max-width: 75%;
}

.ca-message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ca-message-bubble p {
    margin: 0 0 8px 0;
}

.ca-message-bubble p:last-child {
    margin-bottom: 0;
}

.ca-message-bubble strong {
    font-weight: 600;
}

.ca-message-bubble em {
    font-style: italic;
}

.ca-message-bubble br {
    line-height: 1.5;
}

.ca-message.user {
    flex-direction: row-reverse;
}

.ca-message.user .ca-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ca-message.user .ca-message-bubble {
    background: var(--ca-secondary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

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

.ca-message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.ca-message.user .ca-message-bubble a {
    color: #fff;
}

/* Loading Indicator */
.ca-loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 15px;
}

.ca-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--ca-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ca-loading-indicator p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Typing Indicator */
.ca-typing-indicator {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
}

.ca-typing-indicator .ca-message-bubble {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.ca-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.ca-input-wrapper {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: #fff;
    border-radius: 0 0 12px 12px;
}

.ca-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.ca-input:focus {
    border-color: var(--ca-primary-color);
}

.ca-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.ca-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ca-primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.ca-send-btn:hover:not(:disabled) {
    background: var(--ca-secondary-color);
    transform: scale(1.1);
}

.ca-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #cure-assistant-bubble {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
    }
    
    #cure-assistant-modal.ca-modal-open {
        align-items: stretch;
        justify-content: stretch;
    }
    
    .ca-modal-content {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }
    
    .ca-modal-header {
        border-radius: 0;
    }
    
    .ca-input-wrapper {
        border-radius: 0;
    }
    
    .ca-message-content {
        max-width: 80%;
    }
}

/* Scrollbar Styling */
.ca-messages::-webkit-scrollbar {
    width: 6px;
}

.ca-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

.ca-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Accessibility */
.ca-input:focus,
.ca-send-btn:focus,
.ca-close-btn:focus {
    outline: 2px solid var(--ca-primary-color);
    outline-offset: 2px;
}

/* Hide modal by default */
.ca-modal {
    display: none;
}

.ca-modal.ca-modal-open {
    display: flex;
}

