/**
 * Frontend Widget Styles
 * Premium, glassmorphism, responsive
 */

 :root {
    --llm-primary: #3b82f6; /* Modern Blue */
    --llm-primary-hover: #2563eb;
    --llm-bg: #ffffff;
    --llm-text: #1f2937;
    --llm-border: #e5e7eb;
    --llm-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --llm-font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#llm-chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--llm-font);
}

/* Setup responsive width for mobile */
@media (max-width: 480px) {
    #llm-chat-widget-container {
        bottom: 16px;
        right: 16px;
    }
}

/* Bubble Toggle */
#llm-chat-bubble-toggle {
    width: 60px;
    height: 60px;
    background: var(--llm-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.39);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28), background 0.2s;
}

#llm-chat-bubble-toggle:hover {
    transform: scale(1.05);
    background: var(--llm-primary-hover);
}

.llm-chat-opened #llm-chat-bubble-toggle {
    display: none;
}

/* Chat Window */
#llm-chat-window {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 40px);
    background: var(--llm-bg);
    border-radius: 16px;
    box-shadow: var(--llm-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    position: absolute;
    bottom: 0;
    right: 0;
    border: 1px solid var(--llm-border);
}

@media (max-width: 480px) {
    #llm-chat-window {
        width: calc(100vw - 32px);
        height: 80vh;
    }
}

.llm-chat-opened #llm-chat-window {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Header */
.llm-chat-header {
    background: var(--llm-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

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

#llm-chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
}

#llm-chat-close-btn:hover {
    opacity: 1;
}

/* View Layers */
.llm-chat-view-layer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Preform View */
#llm-chat-preform-view {
    padding: 24px;
    overflow-y: auto;
}

#llm-chat-preform-view p {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.llm-form-group {
    margin-bottom: 16px;
}

.llm-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--llm-text);
    margin-bottom: 6px;
}

.llm-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--llm-border);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.llm-form-group input:focus {
    outline: none;
    border-color: var(--llm-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.llm-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--llm-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 24px;
}

.llm-btn:hover {
    background: var(--llm-primary-hover);
}

/* Active Chat */
#llm-chat-messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.llm-message {
    display: flex;
    width: 100%;
}

.llm-message-ai {
    justify-content: flex-start;
}

.llm-message-user {
    justify-content: flex-end;
}

.llm-msg-bubble {
    max-width: 80%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 16px;
    word-break: break-word;
}

.llm-message-ai .llm-msg-bubble {
    background: #ffffff;
    border: 1px solid var(--llm-border);
    border-bottom-left-radius: 4px;
    color: var(--llm-text);
}

.llm-message-user .llm-msg-bubble {
    background: var(--llm-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator Style */
.llm-typing-indicator {
    padding: 14px 16px;
    display: inline-flex;
    gap: 4px;
}
.llm-typing-indicator span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.llm-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.llm-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.llm-chat-input-area {
    padding: 16px;
    background: var(--llm-bg);
    border-top: 1px solid var(--llm-border);
    display: flex;
    gap: 12px;
    align-items: center;
}

#llm-chat-input-field {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--llm-border);
    border-radius: 20px;
    font-size: 14px;
    background: #f9fafb;
    transition: all 0.2s;
}

#llm-chat-input-field:focus {
    outline: none;
    border-color: var(--llm-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

#llm-chat-send-btn:hover {
    background: var(--llm-primary-hover);
}

#llm-chat-send-btn:active {
    transform: scale(0.95);
}

#llm-chat-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
.llm-chat-footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding-bottom: 12px;
    background: var(--llm-bg);
}
