/* Chat Widget Styles */
.chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chat-button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    overflow: hidden;
    padding: 0;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

.chat-button img {
    width: 90%;
    height: 90%;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid #7575754a;
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.chat-window.open {
    display: flex;
}

.chat-header {
    background: linear-gradient(90deg,rgba(0, 136, 255, 1) 0%, rgba(0, 111, 255, 1) 50%, rgba(90, 39, 230, 1) 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.close-chat {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: rgb(249 250 251);
}

.message {
    margin-bottom: 12px;
    max-width: 80%;
    display: flex;
}

.message.user {
    margin-left: auto;
    justify-content: flex-end;
}

.message.bot {
    margin-right: auto;
    justify-content: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    width: fit-content;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content br {
    display: block;
    content: "";
    margin-top: 0.25em;
}

.message-content strong,
.message-content b {
    font-weight: 600;
}

.message-content em,
.message-content i {
    font-style: italic;
}

.message-content p {
    margin: 0 0 0.5em 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0.5em 0 0.25em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.2em; }
.message-content h2 { font-size: 1.15em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4,
.message-content h5,
.message-content h6 { font-size: 1em; }

.message.user .message-content {
    background: linear-gradient(90deg, rgb(40 116 255) 0%, rgb(0 100 255) 18%, rgb(65 27 255) 100%);
    color: white;
}

.message.bot .message-content {
    background: rgb(243 244 246);
    color: #151515;
    /*! box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); */
}

.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    padding: 12px;
    width: 44px;
    height: 44px;
    background: linear-gradient(90deg, rgb(51 123 255) 0%, rgb(0 112 255) 18%, rgb(65 27 255) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    background: #5a6fd8;
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: white;
    color: #666;
    font-style: italic;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.typing-indicator::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
    background-size: 200% 100%;
    animation: typingProgress 2s linear infinite;
}

@keyframes typingProgress {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.typing-indicator::after {
    content: '...';
    animation: typingDots 1.5s infinite;
}

@keyframes typingDots {
    0%, 20% {
        content: '.';
    }
    40%, 60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Dark mode support */
body.dark-mode .chat-window {
    background: #2d3748;
    color: #e2e8f0;
}

body.dark-mode .chat-messages {
    background: #1a202c;
}

body.dark-mode .message.bot .message-content {
    background: #2d3748;
    color: #e2e8f0;
}

body.dark-mode .chat-input-container {
    background: #2d3748;
    border-top-color: #4a5568;
}

body.dark-mode .chat-input {
    background: #4a5568;
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .chat-input:focus {
    border-color: #667eea;
}

/* Responsive - WordPress-style responsive design */
@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Modern browsers - dynamic viewport height */
        height: -webkit-fill-available; /* iOS Safari */
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 9999;
        max-height: 100vh;
        max-height: 100dvh;
        max-height: -webkit-fill-available;
    }
    
    .chat-button {
        bottom: 16px;
        right: 16px;
        width: 60px;
        height: 60px;
    }
    
    /* Ensure input container stays visible when keyboard opens */
    .chat-input-container {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
    }
    
    /* Adjust messages container to account for sticky input */
    .chat-messages {
        flex: 1;
        min-height: 0; /* Important for flexbox */
        padding-bottom: 8px;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .chat-window {
        width: 320px;
        height: 450px;
        bottom: 70px;
    }
    
    .chat-button {
        width: 65px;
        height: 65px;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .chat-window {
        width: 340px;
        height: 480px;
    }
}

/* Smooth animations */
@media (prefers-reduced-motion: no-preference) {
    .chat-window {
        animation: slideIn 0.3s ease-out;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Message animations */
.message {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-out;
}

.message.show {
    opacity: 1;
    transform: translateY(0);
}

.message.user {
    animation: slideInRight 0.4s ease-out forwards;
}

.message.bot {
    animation: slideInLeft 0.4s ease-out forwards;
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(100px) scale(0.8);
    }
    60% {
        opacity: 1;
        transform: translateX(-5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideInLeft {
    0% {
        opacity: 0;
        transform: translateX(-100px) scale(0.8);
    }
    60% {
        opacity: 1;
        transform: translateX(5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Message bubble animation */
.message-content {
    transition: all 0.2s ease;
}

.message:hover .message-content {
    transform: scale(1.02);
}

/* Typing indicator animation */
.typing-indicator {
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Pulse animation for new messages */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.message.new-message .message-content {
    animation: pulse 1.5s ease-out;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .send-button {
        min-height: 44px;
        min-width: 44px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .chat-window {
        height: 100vh;
        height: 100dvh;
        height: -webkit-fill-available;
    }
}

/* Prevent body scroll when chat is open on mobile */
@media (max-width: 480px) {
    body.chat-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* Ensure smooth transitions */
.chat-window {
    transition: height 0.2s ease-out, top 0.2s ease-out;
}

/* Improve input container visibility */
@media (max-width: 480px) {
    .chat-input-container {
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
}