/* Chat Interface Styles for 21D Solution Chatbot - 21D Branded */

:root {
    /* 21D Brand Colors */
    --primary-blue: #1e3a8a;
    --accent-blue: #3b82f6;
    --medical-green: #059669;
    --light-gray: #f8fafc;
    --medium-gray: #e2e8f0;
    --dark-gray: #334155;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --white: #ffffff;
    --success-green: #10b981;
    --warning-orange: #f59e0b;
    --error-red: #ef4444;
}

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
    max-width: 400px;
    width: 100%;
    margin: 0;
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(30, 58, 138, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.chat-container.collapsed {
    height: auto;
    max-width: 60px;
    width: 60px;
    border-radius: 50%;
}

/* Chat bubble when collapsed */
.chat-bubble {
    display: none;
    width: 60px;
    height: 60px;
    background: var(--white);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.3);
    position: relative;
    border: 2px solid var(--primary-blue);
    transition: all 0.2s ease;
    padding: 8px;
}

.chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(30, 58, 138, 0.4);
}

.chat-bubble i {
    color: var(--white);
    font-size: 1.5rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.chat-bubble.collapsed-visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: opacity 0.3s ease;
}

.chat-content.hidden {
    display: none;
}

/* Header */
.chat-header {
    background: var(--primary-blue);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--medium-gray);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.chat-header h4 {
    font-size: 1rem;
    margin: 0;
    color: var(--white);
    font-weight: 600;
}

.chat-header small {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
}

.avatar {
    width: 35px;
    height: 35px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
}

.avatar-text {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.avatar-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.bubble-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: var(--light-gray);
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    animation: messageSlide 0.3s ease-out;
}

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

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

.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    position: relative;
}

.message-text {
    padding: 0.75rem 1rem;
    border-radius: 15px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    line-height: 1.4;
}

.user-message .message-text {
    background: var(--primary-blue);
    color: var(--white);
    border-bottom-right-radius: 6px;
}

.bot-message .message-text {
    background: var(--white);
    color: var(--text-primary);
    border: 1px solid var(--medium-gray);
    border-bottom-left-radius: 6px;
}

.message-text p {
    margin: 0;
    line-height: 1.5;
}

.message-text p:not(:last-child) {
    margin-bottom: 0.75rem;
}

.message-text ul, .message-text ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-text li {
    margin-bottom: 0.25rem;
}

/* Message metadata */
.message-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

.confidence-indicator {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

.confidence-high {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-green);
    border: 1px solid var(--success-green);
}

.confidence-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-orange);
    border: 1px solid var(--warning-orange);
}

.confidence-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-red);
    border: 1px solid var(--error-red);
}

/* Typing Indicator */
.typing-indicator {
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.typing-dots {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    margin-right: 4px;
    animation: typingDot 1.4s infinite;
}

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

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Input Area */
.chat-input {
    background: var(--white);
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--medium-gray);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.chat-input .form-control {
    background: var(--light-gray);
    border: 1px solid var(--medium-gray);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    border-radius: 20px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    font-size: 0.9rem;
}

.chat-input .form-control:focus {
    background: var(--light-gray);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
    color: var(--text-primary);
    outline: none;
}

.chat-input .btn-primary {
    border-radius: 25px;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    padding: 0.75rem 1.25rem;
    background: var(--primary-blue);
    border: none;
    color: var(--white);
    transition: all 0.2s ease;
}

.chat-input .btn-primary:hover {
    background: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.input-help {
    margin-top: 0.5rem;
    text-align: center;
}

.input-help .fa-info-circle {
    margin-right: 0.5rem;
    color: var(--accent-blue);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--light-gray);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--medium-gray);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--dark-gray);
}

/* 21D Brand Styling */
.brand-logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--white) !important;
    text-shadow: none;
}

.brand-tagline {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 400;
}

/* Chat footer with subtle branding */
.chat-footer {
    padding: 0.5rem 1rem;
    background: var(--light-gray);
    border-top: 1px solid var(--medium-gray);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    text-align: center;
}

.chat-footer small {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Responsive embeddable design */
@media (max-width: 450px) {
    .chat-container {
        max-width: 100%;
        height: 400px;
        border-radius: 8px;
    }
    
    .chat-header {
        padding: 0.5rem 0.75rem;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }
    
    .chat-header h4 {
        font-size: 0.9rem;
    }
    
    .chat-header small {
        font-size: 0.7rem;
    }
    
    .avatar {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
    
    .message-text {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--bs-gray-500);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border: none;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-header {
        padding: 0.75rem 1rem;
    }
    
    .chat-input {
        padding: 0.75rem 1rem;
    }
    
    .avatar {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
}

/* Error messages */
.error-message .message-text {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--bs-danger);
    color: var(--bs-danger);
}

/* Success messages */
.success-message .message-text {
    background: rgba(25, 135, 84, 0.1);
    border: 1px solid var(--bs-success);
    color: var(--bs-success);
}