/**
 * INLINE CIVIC CHAT WIDGETS - V34.3.0
 * Contextual AI chat for Representatives and Supreme Court sections
 * Created: January 25, 2025
 */

/* ============================================
   INLINE CHAT SECTION
   ============================================ */

.inline-chat-section {
    margin-top: 2rem;
    border-radius: 12px;
    border: 2px solid rgba(102, 126, 234, 0.15);
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ============================================
   INLINE CHAT TOGGLE BUTTON
   ============================================ */

.inline-chat-toggle {
    width: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border: none;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    flex-wrap: wrap;
}

.inline-chat-toggle:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.inline-chat-toggle:active {
    transform: scale(0.98);
}

/* ============================================
   INLINE CHAT WINDOW
   ============================================ */

.inline-chat-window {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    background: white;
}

.inline-chat-window.active {
    max-height: 600px;
    opacity: 1;
}

/* ============================================
   INLINE CHAT MESSAGES
   ============================================ */

.inline-chat-messages {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 1.5rem;
    background: linear-gradient(180deg, #f8f9fd 0%, #ffffff 100%);
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.inline-chat-message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 12px;
    animation: fadeIn 0.3s ease;
}

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

.inline-chat-message-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: 2rem;
}

.inline-chat-message-assistant {
    background: white;
    border: 2px solid rgba(102, 126, 234, 0.1);
    margin-right: 2rem;
}

/* ============================================
   INLINE CHAT INPUT AREA
   ============================================ */

.inline-chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem;
    background: white;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.inline-chat-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    max-height: 120px;
    transition: all 0.3s ease;
}

.inline-chat-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inline-chat-input::placeholder {
    color: #9ca3af;
}

.inline-chat-send {
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-height: 48px;
}

.inline-chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.inline-chat-send:active {
    transform: translateY(0);
}

/* ============================================
   LOADING STATE
   ============================================ */

.inline-chat-loading {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    justify-content: center;
}

.inline-chat-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: bounce 1.4s infinite ease-in-out;
}

.inline-chat-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.inline-chat-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 639px) {
    .inline-chat-toggle {
        padding: 1rem;
        font-size: 0.875rem;
    }
    
    .inline-chat-message-user,
    .inline-chat-message-assistant {
        margin-left: 0;
        margin-right: 0;
    }
    
    .inline-chat-input-area {
        flex-direction: column;
        padding: 1rem;
    }
    
    .inline-chat-send {
        width: 100%;
        justify-content: center;
    }
    
    .inline-chat-messages {
        padding: 1rem;
        min-height: 150px;
        max-height: 300px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .inline-chat-message,
    .inline-chat-toggle,
    .inline-chat-send {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.inline-chat-toggle:focus-visible,
.inline-chat-input:focus-visible,
.inline-chat-send:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Ensure sufficient color contrast */
.inline-chat-message-assistant {
    color: #1f2937;
}

.inline-chat-message-user {
    color: white;
}
