/* ChatGPT AI Chatbot - Base Styles */

/* Reset/Base */
.chatgpt-chatbot-widget,
.chatgpt-chatbot-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Toggle Button */
.chatgpt-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary, #0066cc);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatgpt-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.chatgpt-chatbot-toggle .close-icon { display: none; }
.chatgpt-chatbot-toggle.active .chat-icon { display: none; }
.chatgpt-chatbot-toggle.active .close-icon { display: block; }
.chatgpt-chatbot-toggle img.toggle-icon { 
    width: 28px; 
    height: 28px; 
    object-fit: contain; 
}

/* Widget Container */
.chatgpt-chatbot-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.chatgpt-chatbot-widget.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
    background: var(--chatbot-header-bg, #0066cc);
    color: var(--chatbot-header-text, #fff);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-avatar,
.chatbot-avatar-default {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    object-fit: cover;
}

.chatbot-avatar-default svg {
    stroke: var(--chatbot-header-text, #fff);
}

.chatbot-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.chatbot-name {
    font-weight: 600;
    font-size: 15px;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.85;
}

.chatbot-header-actions {
    display: flex;
    gap: 2px;
}

.chatbot-header-actions button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: var(--chatbot-chat-bg, #f5f5f5);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/* Message */
.chat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgIn 0.25s ease;
    min-width: 0;
}

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

.chat-message.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--chatbot-primary, #0066cc);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar svg {
    stroke: #fff;
    width: 14px;
    height: 14px;
}

.message-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.bot-message .message-bubble {
    background: var(--chatbot-bot-bubble, #fff);
    color: var(--chatbot-bot-text, #333);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.user-message .message-bubble {
    background: var(--chatbot-user-bubble, #0066cc);
    color: var(--chatbot-user-text, #fff);
    border-bottom-right-radius: 4px;
}

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

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

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Quick Actions */
.chatbot-quick-actions {
    padding: 8px 12px;
    background: var(--chatbot-chat-bg, #f5f5f5);
    display: none;
    flex-wrap: wrap;
    gap: 6px;
}

.chatbot-quick-actions.visible {
    display: flex;
}

.quick-action-btn {
    background: #fff;
    border: 1px solid var(--chatbot-primary, #0066cc);
    color: var(--chatbot-primary, #0066cc);
    padding: 7px 14px;
    border-radius: 18px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-action-btn:hover {
    background: var(--chatbot-primary, #0066cc);
    color: #fff;
}

/* Input Area */
.chatbot-input-area {
    padding: 12px;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-input-border, #e0e0e0);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    font-family: inherit;
    background: var(--chatbot-input-bg, #fff);
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary, #0066cc);
}

.chatbot-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--chatbot-primary, #0066cc);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
}

/* ===== RESULT CARDS ===== */
.message-cards {
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.results-section {
    margin-bottom: 10px;
    max-width: 100%;
}

.results-section:last-child {
    margin-bottom: 0;
}

.results-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #666;
    margin-bottom: 6px;
}

.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 100%;
}

/* Base Card */
.result-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--chatbot-card-bg, #fff);
    border: 1px solid var(--chatbot-card-border, #e8e8e8);
    border-radius: 10px;
    padding: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.result-card:hover {
    border-color: var(--chatbot-primary, #0066cc);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Service Card */
.service-card .card-img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0;
    flex-shrink: 0;
}

.service-card .card-img.no-img {
    display: flex;
    align-items: center;
    justify-content: center;
}

.service-card .card-img.no-img svg {
    stroke: #bbb;
    width: 20px;
    height: 20px;
}

/* Doctor Card */
.doctor-card {
    padding: 10px;
}

.doctor-img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #f0f0f0;
}

.doctor-img.no-img {
    display: flex;
    align-items: center;
    justify-content: center;
}

.doctor-img.no-img svg {
    stroke: #bbb;
    width: 22px;
    height: 22px;
}

/* Card Body */
.card-body {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.card-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-desc {
    font-size: 11px;
    color: #666;
    line-height: 1.3;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-specialty {
    font-size: 11px;
    color: var(--chatbot-primary, #0066cc);
    margin-top: 1px;
}

/* Location Card */
.location-card {
    padding: 10px;
}

.location-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 102, 204, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.location-icon svg {
    stroke: var(--chatbot-primary, #0066cc);
    width: 18px;
    height: 18px;
}

.card-address {
    font-size: 11px;
    color: #666;
    margin: 2px 0;
    line-height: 1.3;
}

.card-phone {
    font-size: 11px;
    margin-bottom: 4px;
}

.card-phone a {
    color: var(--chatbot-primary, #0066cc);
    text-decoration: none;
}

.maps-btn {
    display: inline-block;
    font-size: 11px;
    color: var(--chatbot-primary, #0066cc);
    text-decoration: none;
    font-weight: 500;
}

.maps-btn:hover {
    text-decoration: underline;
}

/* Contact Card */
.contact-card-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    font-size: 13px;
    transition: all 0.2s;
}

.contact-btn:hover {
    border-color: var(--chatbot-primary, #0066cc);
}

.contact-btn.whatsapp {
    background: #25D366;
    color: #fff;
    border-color: #25D366;
}

.contact-btn.whatsapp:hover {
    background: #1da851;
}

/* Hours Card */
.hours-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 10px;
}

.hours-card pre {
    margin: 0;
    font-family: inherit;
    font-size: 12px;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 2px;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px) {
    .chatgpt-chatbot-toggle {
        width: 55px;
        height: 55px;
        bottom: 15px;
        right: 15px;
    }
    
    .chatgpt-chatbot-toggle.pos-bottom-left {
        right: auto;
        left: 15px;
    }
    
    /* Fullscreen on mobile by default */
    .chatgpt-chatbot-widget {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        transform: translateY(100%);
    }
    
    .chatgpt-chatbot-widget.active {
        transform: translateY(0);
    }
    
    .chatbot-header {
        padding: 12px 14px;
        padding-top: max(12px, env(safe-area-inset-top));
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .chatbot-input-area {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    .chat-message {
        max-width: 92%;
    }
    
    .message-bubble {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .result-card {
        padding: 8px;
    }
    
    .card-title {
        font-size: 13px;
    }
    
    .card-body {
        max-width: calc(100% - 55px);
    }
    
    .doctor-img {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .service-card .card-img {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }
}

/* RTL Support */
[dir="rtl"] .chatgpt-chatbot-toggle {
    right: auto;
    left: 20px;
}

[dir="rtl"] .chatgpt-chatbot-widget {
    right: auto;
    left: 20px;
}

[dir="rtl"] .chat-message.user-message {
    margin-left: 0;
    margin-right: auto;
    flex-direction: row;
}

[dir="rtl"] .chat-message.bot-message {
    flex-direction: row-reverse;
}

[dir="rtl"] .bot-message .message-bubble {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .user-message .message-bubble {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

@media (max-width: 480px) {
    [dir="rtl"] .chatgpt-chatbot-toggle {
        left: 15px;
    }
}
