/**
 * LolaROI Chat Widget Styles
 * Modern, responsive chat interface matching the platform theme
 */

/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: var(--surface, #FFFFFF);
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-widget.hidden {
    transform: translateY(calc(100% + 20px));
    opacity: 0;
    pointer-events: none;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary, #3D7A7F) 0%, var(--primary-dark, #2D5A5E) 100%);
    color: white;
    padding: var(--space-lg, 1.5rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: var(--space-md, 1rem);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success, #10B981);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast, 150ms ease);
    backdrop-filter: blur(10px);
}

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

/* Messages Container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg, 1.5rem);
    display: flex;
    flex-direction: column;
    gap: var(--space-md, 1rem);
    background: var(--background, #F5F7FA);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-dark, #D1D5DB);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted, #9CA3AF);
}

/* Message Groups */
.message-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

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

/* Messages */
.chat-message {
    padding: var(--space-md, 1rem);
    border-radius: var(--radius-lg, 12px);
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 0.875rem;
    animation: messageSlide 0.3s ease;
}

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

.chat-message.user {
    background: linear-gradient(135deg, var(--primary, #3D7A7F) 0%, var(--primary-dark, #2D5A5E) 100%);
    color: white;
    border-bottom-right-radius: var(--radius-sm, 4px);
}

.chat-message.assistant {
    background: var(--surface, #FFFFFF);
    color: var(--text, #0A1F3D);
    border: 1px solid var(--border, #E5E7EB);
    border-bottom-left-radius: var(--radius-sm, 4px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.chat-message.system {
    background: var(--danger-light, #FEE2E2);
    color: var(--danger, #DC143C);
    border: 1px solid var(--danger, #DC143C);
    font-size: 0.8125rem;
    align-self: center;
    max-width: 90%;
}

.message-time {
    font-size: 0.6875rem;
    color: var(--text-muted, #9CA3AF);
    padding: 0 var(--space-sm, 0.5rem);
}

/* Markdown Formatting in Messages */
.chat-message.assistant strong {
    font-weight: 600;
    color: var(--text, #0A1F3D);
}

.chat-message.assistant .chat-h1 {
    display: block;
    font-size: 1rem;
    margin: 0.75rem 0 0.5rem 0;
    color: var(--primary, #3D7A7F);
}

.chat-message.assistant .chat-h1:first-child {
    margin-top: 0;
}

.chat-message.assistant .chat-h2 {
    display: block;
    font-size: 0.9375rem;
    margin: 0.625rem 0 0.375rem 0;
    color: var(--primary, #3D7A7F);
}

.chat-message.assistant .chat-h3 {
    display: block;
    font-size: 0.875rem;
    margin: 0.5rem 0 0.25rem 0;
    color: var(--primary-dark, #2D5A5E);
}

.chat-message.assistant em {
    font-style: italic;
}

.chat-message.assistant .chat-bullet {
    display: block;
    padding-left: 1rem;
    position: relative;
    margin: 0.25rem 0;
}

.chat-message.assistant .chat-bullet::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary, #3D7A7F);
    font-weight: bold;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    gap: 6px;
    padding: var(--space-md, 1rem);
    background: var(--surface, #FFFFFF);
    border-radius: var(--radius-lg, 12px);
    border-bottom-left-radius: var(--radius-sm, 4px);
    width: fit-content;
    border: 1px solid var(--border, #E5E7EB);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: var(--text-muted, #9CA3AF);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Quick Actions */
.quick-actions {
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    background: var(--surface, #FFFFFF);
    border-top: 1px solid var(--border, #E5E7EB);
    display: flex;
    gap: var(--space-sm, 0.5rem);
    overflow-x: auto;
}

.quick-actions::-webkit-scrollbar {
    height: 4px;
}

.quick-actions::-webkit-scrollbar-thumb {
    background: var(--border-dark, #D1D5DB);
    border-radius: 2px;
}

.quick-action-btn {
    background: var(--background, #F5F7FA);
    border: 1px solid var(--border, #E5E7EB);
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary, #6B7280);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast, 150ms ease);
    font-weight: 500;
}

.quick-action-btn:hover {
    background: var(--primary, #3D7A7F);
    color: white;
    border-color: var(--primary, #3D7A7F);
    transform: translateY(-1px);
}

/* Chat Input */
.chat-input {
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    border-top: 1px solid var(--border, #E5E7EB);
    background: var(--surface, #FFFFFF);
    display: flex;
    gap: var(--space-sm, 0.5rem);
    border-radius: 0 0 var(--radius-xl, 16px) var(--radius-xl, 16px);
}

.chat-input input {
    flex: 1;
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    border: 1px solid var(--border-dark, #D1D5DB);
    border-radius: 24px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition-fast, 150ms ease), box-shadow var(--transition-fast, 150ms ease);
    font-family: inherit;
}

.chat-input input:focus {
    border-color: var(--primary, #3D7A7F);
    box-shadow: 0 0 0 3px rgba(61, 122, 127, 0.1);
}

.chat-input button {
    background: linear-gradient(135deg, var(--primary, #3D7A7F) 0%, var(--primary-dark, #2D5A5E) 100%);
    color: white;
    border: none;
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: transform var(--transition-fast, 150ms ease), box-shadow var(--transition-fast, 150ms ease);
    font-family: inherit;
}

.chat-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(61, 122, 127, 0.4);
}

.chat-input button:active {
    transform: translateY(0);
}

/* Chat Toggle Button */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary, #3D7A7F) 0%, var(--primary-dark, #2D5A5E) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(61, 122, 127, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(61, 122, 127, 0.6);
}

.chat-toggle-btn.hidden {
    display: none;
}

/* Chat Icon SVG */
.chat-toggle-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-widget {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }

    .quick-actions {
        padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
    }

    .quick-action-btn {
        font-size: 0.6875rem;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .chat-widget {
        width: 100vw;
        height: calc(100vh - 80px);
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: none;
    }

    .chat-header {
        border-radius: 0;
    }

    .chat-input {
        border-radius: 0;
    }

    .chat-toggle-btn {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
}
