/* Modern Chat Interface - Enhanced & Interactive */

/* Quick Actions Buttons */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border-top: 1px solid #E2E8F0;
    animation: slideInUp 0.3s ease-out;
}

.quick-action-btn {
    padding: 10px 16px;
    background: white;
    border: 2px solid #E2E8F0;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border-color: #3B82F6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.quick-action-btn:active {
    transform: translateY(0);
}

.quick-action-btn .emoji {
    font-size: 1.1rem;
}

/* Modern Send Button */
.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 2px solid #F1F5F9;
    align-items: flex-end;
}

#chatInput {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #E2E8F0;
    border-radius: 24px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    transition: all 0.3s ease;
    overflow-y: auto;
    background: #FFFFFF;
    color: #1E293B;
}

#chatInput:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: #FFFFFF;
    color: #1E293B;
}

#chatInput::placeholder {
    color: #94A3B8;
}

.send-button {
    min-width: 44px;
    height: 44px;
    padding: 0;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10; /* Ensure button is clickable */
}

.send-button:hover:not(:disabled) {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    background: linear-gradient(135deg, #CBD5E1, #94A3B8);
    cursor: not-allowed;
    box-shadow: none;
}

.send-button svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.send-button:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* Typing Indicator - More Modern */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #F1F5F9;
    border-radius: 18px;
    width: fit-content;
    margin: 8px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #64748B;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

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

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Enhanced Messages */
.message {
    margin: 12px 16px;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease-out;
    position: relative;
}

.message.user {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.message.assistant {
    background: white;
    color: #1E293B;
    border: 2px solid #F1F5F9;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

/* Interactive Action Cards */
.action-card {
    background: white;
    border: 2px solid #E2E8F0;
    border-radius: 16px;
    padding: 16px;
    margin: 12px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.action-card:hover {
    border-color: #3B82F6;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

.action-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.action-card-content {
    flex: 1;
}

.action-card-title {
    font-weight: 600;
    color: #1E293B;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.action-card-desc {
    font-size: 0.85rem;
    color: #64748B;
}

/* Enhanced System Messages */
.message.system-message {
    margin: 10px 16px;
    padding: 16px 20px;
    border-radius: 16px;
    text-align: left;
    font-size: 0.9rem;
    animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1), pulse 0.6s ease;
    max-width: none;
    border: 2px solid transparent;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.system-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.system-icon {
    font-size: 24px;
    flex-shrink: 0;
    animation: bounce 1s ease infinite;
}

.system-text {
    flex: 1;
    line-height: 1.6;
    white-space: pre-line;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.message.system-success {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    border-color: #059669;
    font-weight: 500;
}

.message.system-info {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    border-color: #2563EB;
}

.message.system-warning {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    border-color: #D97706;
}

.system-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

/* Welcome Message - More Engaging */
.welcome-message {
    background: linear-gradient(135deg, #FFFFFF, #F8FAFC);
    border: 2px solid #E2E8F0;
    border-radius: 20px;
    padding: 24px;
    margin: 16px;
    text-align: left;
    animation: fadeInScale 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.enhanced-welcome {
    margin-top: 1rem;
    line-height: 1.8;
    font-size: 0.95rem;
    color: #475569;
}

.enhanced-welcome strong {
    color: #2563EB;
    font-weight: 600;
}

/* Chat Links */
.chat-link {
    color: #3B82F6;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.chat-link:hover {
    color: #2563EB;
    border-bottom-color: #2563EB;
}

/* Calendly Widget in Chat */
.calendly-inline-widget {
    margin: 1rem 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 2px solid #E2E8F0;
    background: #fff;
}

.calendly-message {
    margin: 10px 0;
}

.calendly-message .message-content {
    padding: 0;
    background: transparent;
    border: none;
}

/* 3CX Call widget */
.threecx-widget {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    padding: 20px;
    margin-top: 10px;
    border: 1px solid #bfdbfe;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.call-interface {
    text-align: center;
}

.call-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.call-icon {
    font-size: 32px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.call-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e40af;
    margin: 0;
}

.call-info {
    margin-bottom: 20px;
}

.call-info p {
    color: #64748b;
    margin-bottom: 8px;
}

.agent-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #475569;
}

.agent-label {
    font-weight: 500;
}

.agent-name {
    font-weight: 600;
    color: #1e40af;
}

.call-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.call-button:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    color: white;
}

.call-button svg {
    flex-shrink: 0;
}

.alternative-options {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e7ff;
}

.alternative-options p {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 8px;
}

.phone-link {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
    font-size: 1.1rem;
}

.phone-link:hover {
    text-decoration: underline;
}

.threecx-message {
    margin: 10px 0;
}

.threecx-message .message-content {
    padding: 0;
    background: transparent;
    border: none;
}

/* Interactive Buttons */
.chat-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.buttons-intro {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    font-style: italic;
}

.chat-button {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
    text-align: center;
}

.chat-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
}

.chat-button:active:not(:disabled) {
    transform: translateY(0);
}

.chat-button:disabled {
    cursor: not-allowed;
    background: #E5E7EB;
    color: #9CA3AF;
    box-shadow: none;
}

/* Back Button */
.chat-back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #E5E7EB;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.chat-back-button:hover {
    background: #F9FAFB;
    transform: translateX(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-back-button svg {
    width: 20px;
    height: 20px;
    color: #374151;
}

.welcome-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.welcome-message h4 {
    color: #1E293B;
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 6px 0;
}

.welcome-message .contact-info {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #64748B;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.contact-item:hover {
    color: #3B82F6;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

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

/* Message Timestamp */
.message-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
    text-align: right;
}

.message.assistant .message-time {
    color: #94A3B8;
}

/* Scroll to bottom button */
.scroll-to-bottom {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.scroll-to-bottom.visible {
    opacity: 1;
    pointer-events: all;
}

.scroll-to-bottom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

/* Loading State */
.send-button.loading::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .quick-action-btn {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .welcome-message {
        padding: 20px;
        margin: 12px;
    }
    
    .welcome-icon {
        font-size: 48px;
    }
    
    /* Fix input visibility on mobile */
    .chat-input-container {
        padding: 12px;
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        display: flex;
        gap: 8px;
        align-items: flex-end;
    }
    
    #chatInput {
        min-height: 42px;
        max-height: 100px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        -webkit-appearance: none;
        appearance: none;
        flex: 1;
    }
    
    .send-button {
        min-width: 42px;
        height: 42px;
        flex-shrink: 0;
        pointer-events: auto; /* Ensure button is clickable */
        touch-action: manipulation; /* Better touch handling */
    }
}

/* Fix for mobile keyboard overlap */
@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    .chat-input-container {
        position: sticky;
        bottom: 0;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    
    #chatInput {
        font-size: 16px !important; /* Force 16px to prevent zoom */
    }
}

/* Android specific fixes */
@media screen and (max-width: 768px) and (orientation: portrait) {
    .chat-modal.active {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height */
    }
    
    .chat-messages {
        padding-bottom: 80px; /* Extra space for keyboard */
    }
}

/* Landscape mode mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    #chatInput {
        max-height: 60px;
    }
    
    .chat-input-container {
        padding: 8px 12px;
    }
}

/* Keyboard open state */
.chat-modal.keyboard-open {
    padding-bottom: 0;
}

.chat-modal.keyboard-open .chat-messages {
    transition: max-height 0.3s ease;
}

.chat-modal.keyboard-open .chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}
