/* Heptabot Frontend Styles - User-Friendly Design */

.heptabot-chat-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 400px;
}
/* Messages Area */
.heptabot-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
}

.heptabot-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.heptabot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.heptabot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.heptabot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Messages */
.heptabot-message {
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.4s ease-out;
    max-width: 85%;
}

.heptabot-message-user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

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

.heptabot-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.heptabot-message-bot .heptabot-message-avatar {
    background: #f3f4f6;
    color: #6b7280;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.heptabot-message-user .heptabot-message-avatar {
    background: var(--user-bubble-color, #667eea);
    color: white;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.heptabot-message-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.heptabot-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.heptabot-message-bot .heptabot-message-bubble {
    background: #ffffff;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
}

.heptabot-message-user .heptabot-message-bubble {
    background: var(--user-bubble-color, #667eea);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--user-bubble-color, #667eea) 30%, transparent);
}

.heptabot-message-time {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 6px;
    font-weight: 500;
    align-self: flex-start;
}

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

/* Typing Indicator */
.heptabot-typing {
    max-width: 85%;
}

.heptabot-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
}

.heptabot-typing-dots {
    display: flex;
    gap: 3px;
}

.heptabot-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite ease-in-out;
}

.heptabot-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

.heptabot-typing-text {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

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

/* Input Area */
.heptabot-input-area {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px 12px;
}

.heptabot-input-container {
    margin-bottom: 8px;
}

.heptabot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 8px 16px;
    transition: all 0.2s ease;
    position: relative;
}

.heptabot-input-wrapper:focus-within {
    border-color: var(--user-bubble-color, #667eea);
    background: #ffffff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--user-bubble-color, #667eea) 10%, transparent);
}

.heptabot-input {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    outline: none;
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 0;
    color: #374151;
    font-family: inherit;
    max-height: 120px;
    min-height: 20px;
    opacity: 1;
    visibility: visible;
}

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

.heptabot-send-btn {
    background: var(--user-bubble-color, #667eea);
    border: none;
    color: white;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--user-bubble-color, #667eea) 30%, transparent);
    width: 40px;
    height: 40px;
}

.heptabot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--user-bubble-color, #667eea) 40%, transparent);
}

.heptabot-send-btn:active {
    transform: scale(0.95);
}

.heptabot-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Footer */
.heptabot-footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
}

/* Error Message */
.heptabot-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    margin: 16px 0;
    border: 1px solid #fecaca;
    max-width: 85%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.4s ease-out;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .heptabot-chat-container {
        height: 70vh;
        max-height: 600px;
        border-radius: 0;
        box-shadow: none;
        border: none;
        border-top: 1px solid #e5e7eb;
    }
    
    .heptabot-chat-header {
        padding: 12px 16px;
    }
    
    .heptabot-messages-area {
        padding: 16px;
    }
    
    .heptabot-input-area {
        padding: 12px 16px 8px;
    }
    
    .heptabot-message {
        max-width: 90%;
    }
    
    .heptabot-message-bubble {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .heptabot-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .heptabot-modal .heptabot-chat-container {
        height: 80vh !important;
        max-height: 90vh !important;
    }
    
    .heptabot-chat-header {
        padding: 10px 12px;
    }
    
    .heptabot-bot-avatar {
        width: 32px;
        height: 32px;
    }
    
    .heptabot-bot-details h3 {
        font-size: 14px;
    }
    
    .heptabot-messages-area {
        padding: 12px;
    }
    
    .heptabot-input-area {
        padding: 10px 12px 6px;
    }
    
    .heptabot-message {
        max-width: 95%;
    }
    
    .heptabot-message-avatar {
        width: 30px;
        height: 30px;
    }
    
    .heptabot-message-bubble {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .heptabot-input-wrapper {
        padding: 6px 12px;
    }
    
    .heptabot-send-btn {
        width: 36px;
        height: 36px;
        padding: 8px;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Loading state */
.heptabot-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Focus states */
.heptabot-input:focus {
    outline: none;
}

/* Selection styles */
.heptabot-message-bubble ::selection {
    background: rgba(102, 126, 234, 0.2);
}

.heptabot-message-user .heptabot-message-bubble ::selection {
    background: rgba(255, 255, 255, 0.3);
}

/* Modal Styles */
.heptabot-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.heptabot-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.heptabot-modal {
    background: white;
    border-radius: 5px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 80%;
    max-width: 1000px;
    height: 70vh;
    max-height: 600px;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
}

.heptabot-modal-overlay.active .heptabot-modal {
    transform: scale(1) translateY(0);
}

.heptabot-modal-header {
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: end;
    align-items: center;
}

.heptabot-modal-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.heptabot-modal-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.heptabot-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.heptabot-modal-body {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
}

.heptabot-modal .heptabot-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    box-shadow: none;
    border: none;
    min-height: 0;
}

.heptabot-modal .heptabot-messages-area {
    height: 300px;
    overflow-y: auto;
    flex-shrink: 0;
}

.heptabot-modal .heptabot-input-area {
    height: 120px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    display: block !important;
    visibility: visible !important;
    border-radius: 0 0 5px 5px;
}

/* Responsive modal */
@media (max-width: 768px) {
    .heptabot-modal {
        width: 95%;
        height: fit-content;
        max-height: none;
    }
}

@media (max-width: 480px) {
    .heptabot-modal {
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    
    .heptabot-modal-header {
        padding: 12px 16px;
    }
}

/* Chatbox Styles */
.heptabot-chatbox {
    position: absolute;
    width: 400px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    /* Initial state - hidden */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.heptabot-chatbox.active {
    opacity: 1;
    visibility: visible !important;
    transform: scale(1) translateY(0);
}

.heptabot-chatbox-header {
    color: white;
    padding: 12px 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: end;
    align-items: center;
    flex-shrink: 0;
}

.heptabot-chatbox-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.heptabot-chatbox-controls {
    display: flex;
    gap: 8px;
}

.heptabot-chatbox-minimize,
.heptabot-chatbox-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.heptabot-chatbox-minimize:hover,
.heptabot-chatbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.heptabot-chatbox-minimize svg {
    transition: transform 0.3s ease;
}

.heptabot-chatbox-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.heptabot-chatbox .heptabot-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    box-shadow: none;
    border: none;
    min-height: 0;
}

.heptabot-chatbox .heptabot-messages-area {
    flex: 1;
    min-height: 0;
    padding: 16px;

}

.heptabot-chatbox .heptabot-input-area {
    flex-shrink: 0;
    padding: 12px 16px;
    border-radius: 0 0 12px 12px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
    background: #ffffff !important;
    border-top: 1px solid #e5e7eb !important;
}

.heptabot-chatbox .heptabot-input-container {
    display: block !important;
    visibility: visible !important;
    margin-bottom: 8px !important;
}

.heptabot-chatbox .heptabot-input-wrapper {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.heptabot-chatbox .heptabot-input {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 1 !important;
}

.heptabot-chatbox .heptabot-send-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chatbox responsive */
@media (max-width: 768px) {
    .heptabot-chatbox {
        width: 320px;
        height: 450px;
    }
}

@media (max-width: 480px) {
    .heptabot-chatbox {
        width: calc(100vw - 20px);
        height: 400px;
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        top: auto !important;
    }
}