/**
 * FlowDrya AI Chat Widget Styles
 * Matches the FlowDrya website design
 */

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
    --fd-chat-primary: #003E01;
    --fd-chat-primary-dark: #002D01;
    --fd-chat-accent: #F8B93B;
    --fd-chat-white: #ffffff;
    --fd-chat-light: #f8f9fa;
    --fd-chat-border: #e5e5e5;
    --fd-chat-text: #1a1a1a;
    --fd-chat-text-muted: #6b7280;
    --fd-chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --fd-chat-radius: 0;
    --fd-chat-z-index: 9990;
}

/* =====================================================
   CHAT WIDGET CONTAINER
   ===================================================== */
.fd-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--fd-chat-z-index);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* =====================================================
   TOGGLE BUTTON
   ===================================================== */
.fd-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--fd-chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--fd-chat-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.fd-chat-toggle:hover {
    background: var(--fd-chat-primary-dark);
    transform: scale(1.05);
}

.fd-chat-toggle i {
    font-size: 1.5rem;
    color: var(--fd-chat-white);
}

.fd-chat-toggle .fd-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #DC2626;
    color: var(--fd-chat-white);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* =====================================================
   CHAT WINDOW
   ===================================================== */
.fd-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--fd-chat-white);
    border: 1px solid var(--fd-chat-border);
    box-shadow: var(--fd-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fd-chat-slide-up 0.3s ease;
}

@keyframes fd-chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   CHAT HEADER
   ===================================================== */
.fd-chat-header {
    background: var(--fd-chat-primary);
    color: var(--fd-chat-white);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.fd-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fd-chat-white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fd-chat-avatar i {
    font-size: 1.25rem;
    color: var(--fd-chat-primary);
}

.fd-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.fd-chat-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.fd-chat-status {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fd-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: fd-pulse 2s infinite;
}

@keyframes fd-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.fd-chat-close {
    background: none;
    border: none;
    color: var(--fd-chat-white);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.fd-chat-close:hover {
    opacity: 1;
}

/* =====================================================
   REGISTRATION FORM
   ===================================================== */
.fd-chat-registration {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--fd-chat-light);
}

.fd-chat-welcome {
    text-align: center;
    margin-bottom: 24px;
}

.fd-chat-welcome h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--fd-chat-text);
    margin-bottom: 8px;
}

.fd-chat-welcome p {
    font-size: 0.875rem;
    color: var(--fd-chat-text-muted);
    line-height: 1.5;
}

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

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

.fd-form-group label .required {
    color: #DC2626;
}

.fd-form-group input,
.fd-form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--fd-chat-border);
    background: var(--fd-chat-white);
    color: var(--fd-chat-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.fd-form-group input:focus,
.fd-form-group select:focus {
    outline: none;
    border-color: var(--fd-chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 62, 1, 0.1);
}

.fd-form-group input::placeholder {
    color: var(--fd-chat-text-muted);
}

.fd-btn-start {
    width: 100%;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--fd-chat-primary);
    color: var(--fd-chat-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    font-family: inherit;
    margin-top: 8px;
}

.fd-btn-start:hover {
    background: var(--fd-chat-primary-dark);
}

.fd-btn-start:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* =====================================================
   CHAT INTERFACE
   ===================================================== */
.fd-chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =====================================================
   MESSAGES AREA
   ===================================================== */
.fd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--fd-chat-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar styling */
.fd-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.fd-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.fd-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* =====================================================
   MESSAGE BUBBLES
   ===================================================== */
.fd-message {
    max-width: 85%;
    animation: fd-message-in 0.2s ease;
}

@keyframes fd-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fd-message-user {
    align-self: flex-end;
}

.fd-message-assistant {
    align-self: flex-start;
}

.fd-message-content {
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.fd-message-user .fd-message-content {
    background: var(--fd-chat-primary);
    color: var(--fd-chat-white);
}

.fd-message-assistant .fd-message-content {
    background: var(--fd-chat-white);
    color: var(--fd-chat-text);
    border: 1px solid var(--fd-chat-border);
}

.fd-message-content ul {
    margin: 8px 0;
    padding-left: 18px;
}

.fd-message-content li {
    margin-bottom: 4px;
}

.fd-message-content strong {
    font-weight: 600;
}

.fd-message-content a {
    color: inherit;
    text-decoration: underline;
}

.fd-message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85em;
}

/* Formula styling */
.fd-message-content .fd-formula {
    display: block;
    background: rgba(0, 62, 1, 0.05);
    padding: 8px 12px;
    margin: 8px 0;
    border-left: 3px solid var(--fd-chat-primary);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Numbered list styling */
.fd-message-content .fd-list-num {
    font-weight: 600;
    color: var(--fd-chat-primary);
    margin-right: 4px;
}

/* Indent for nested items */
.fd-message-content .fd-indent {
    display: inline-block;
    width: 20px;
}

.fd-message-time {
    font-size: 0.7rem;
    color: var(--fd-chat-text-muted);
    margin-top: 4px;
    text-align: right;
}

.fd-message-user .fd-message-time {
    text-align: right;
}

.fd-message-assistant .fd-message-time {
    text-align: left;
}

/* =====================================================
   TYPING INDICATOR
   ===================================================== */
.fd-typing .fd-typing-dots {
    padding: 12px 16px;
    background: var(--fd-chat-white);
    border: 1px solid var(--fd-chat-border);
    display: flex;
    gap: 4px;
    align-items: center;
}

.fd-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--fd-chat-text-muted);
    border-radius: 50%;
    animation: fd-typing-bounce 1.4s infinite ease-in-out both;
}

.fd-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.fd-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.fd-typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes fd-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =====================================================
   INPUT AREA
   ===================================================== */
.fd-chat-input-area {
    background: var(--fd-chat-white);
    border-top: 1px solid var(--fd-chat-border);
    flex-shrink: 0;
}

.fd-chat-context {
    padding: 8px 16px;
    background: var(--fd-chat-light);
    font-size: 0.7rem;
    color: var(--fd-chat-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--fd-chat-border);
}

.fd-chat-context i {
    color: var(--fd-chat-primary);
}

#fdChatForm {
    display: flex;
    padding: 12px;
    gap: 8px;
}

#fdChatInput {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.875rem;
    border: 1px solid var(--fd-chat-border);
    background: var(--fd-chat-light);
    color: var(--fd-chat-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

#fdChatInput:focus {
    outline: none;
    border-color: var(--fd-chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 62, 1, 0.1);
}

#fdChatInput::placeholder {
    color: var(--fd-chat-text-muted);
}

#fdChatSend {
    width: 44px;
    height: 44px;
    background: var(--fd-chat-primary);
    color: var(--fd-chat-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#fdChatSend:hover {
    background: var(--fd-chat-primary-dark);
}

#fdChatSend:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#fdChatSend i {
    font-size: 1rem;
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */
@media (max-width: 480px) {
    .fd-chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .fd-chat-toggle {
        width: 54px;
        height: 54px;
    }

    .fd-chat-toggle i {
        font-size: 1.3rem;
    }

    .fd-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 0;
    }

    .fd-chat-registration {
        padding: 16px;
    }

    .fd-message {
        max-width: 90%;
    }
}

/* =====================================================
   DARK MODE SUPPORT (Optional)
   ===================================================== */
@media (prefers-color-scheme: dark) {
    /* Can add dark mode styles if needed */
}

/* =====================================================
   PRINT STYLES - Hide chat widget
   ===================================================== */
@media print {
    .fd-chat-widget {
        display: none !important;
    }
}
