/* AI Chatbot Styles - Glassmorphism Design */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    right: 2rem;
    z-index: 999;
    font-family: 'Inter', sans-serif;
}

.chatbot-container.active {
    z-index: 1000;
}

/* Toggle Button */
.chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--bg-primary);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(30, 58, 138, 0.4), 0 0 0 4px rgba(30, 58, 138, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(30, 58, 138, 0.5), 0 0 0 6px rgba(30, 58, 138, 0.15);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid var(--bg-primary);
    animation: pulse 2s infinite;
}

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

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chatbot-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px 20px 0 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-primary);
    flex-shrink: 0;
}

.chatbot-header-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.chatbot-status {
    font-size: 0.75rem;
    color: #10b981;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chatbot-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

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

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

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.chatbot-message {
    display: flex;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
}

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

.chatbot-message-user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.chatbot-message-user .message-avatar {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--bg-primary);
}

.message-content {
    max-width: 75%;
    padding: 0.875rem 1rem;
    border-radius: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.chatbot-message-user .message-content {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--bg-primary);
    border: none;
}

.message-content p {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.chatbot-message-user .message-content p {
    color: var(--bg-primary);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.chatbot-message-user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: fit-content;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: typing 1.4s infinite;
}

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

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

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

/* Quick Actions */
.chatbot-quick-actions {
    padding: 0 1.25rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.quick-action-btn {
    padding: 0.5rem 0.875rem;
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-action-btn:hover {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Input Container */
.chatbot-input-container {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 0 20px 20px;
}

.chatbot-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.chatbot-input::placeholder {
    color: var(--text-secondary);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--bg-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

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

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
.chatbot-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
}

.chatbot-footer p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chatbot-footer a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s ease;
}

.chatbot-footer a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* Responsive */
@media (max-width: 768px) {
    /* Hide emergency banner when chatbot is open on tablet */
    .chatbot-container.active ~ .emergency-banner {
        display: none !important;
    }
    
    /* Hide contact widget when chatbot is open on tablet */
    .chatbot-container.active ~ .contact-widget {
        display: none !important;
    }
    
    .chatbot-container {
        right: 1rem;
        bottom: 140px; /* Space for contact widget */
    }
    
    .chatbot-window {
        width: calc(100vw - 2rem);
        max-width: 400px;
        height: calc(100vh - 240px);
        max-height: 600px;
        right: 0;
        bottom: 80px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }
    
    .chatbot-header {
        padding: 1rem;
    }
    
    .chatbot-messages {
        padding: 1rem;
    }
    
    .chatbot-input-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    /* Hide emergency banner when chatbot is open */
    body.chatbot-open .emergency-banner,
    .chatbot-container.active ~ .emergency-banner {
        display: none !important;
    }
    
    /* Hide contact widget when chatbot is open */
    body.chatbot-open .contact-widget,
    .chatbot-container.active ~ .contact-widget {
        display: none !important;
    }
    
    .chatbot-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10002;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .chatbot-container.active {
        opacity: 1;
        pointer-events: all;
    }
    
    .chatbot-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        max-width: none;
        position: fixed;
        z-index: 10003;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Header mobile optimizations */
    .chatbot-header {
        padding: 1rem;
        flex-shrink: 0;
        min-height: 60px;
        border-radius: 0;
    }
    
    .chatbot-header-info {
        gap: 0.625rem;
    }
    
    .chatbot-avatar {
        width: 36px;
        height: 36px;
    }
    
    .chatbot-header-info h3 {
        font-size: 0.9375rem;
        line-height: 1.2;
    }
    
    .chatbot-status {
        font-size: 0.6875rem;
        margin-top: 0.125rem;
    }
    
    .chatbot-close {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }
    
    /* Messages container mobile */
    .chatbot-messages {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        min-height: 0; /* Important for flex */
    }
    
    /* Message bubbles mobile */
    .chatbot-message {
        margin-bottom: 1rem;
        gap: 0.625rem;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px;
        flex-shrink: 0;
    }
    
    .message-content {
        max-width: 80%;
        padding: 0.75rem 1rem;
        border-radius: 16px;
    }
    
    .message-content p {
        font-size: 0.875rem;
        line-height: 1.5;
        margin: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .message-time {
        font-size: 0.6875rem;
        margin-top: 0.25rem;
    }
    
    .chatbot-message-user .message-content {
        max-width: 75%;
        margin-left: auto;
    }
    
    .chatbot-message-bot .message-content {
        max-width: 85%;
    }
    
    /* Quick actions mobile */
    .chatbot-quick-actions {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        flex-shrink: 0;
    }
    
    .quick-action-btn {
        width: 100%;
        text-align: center;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Input container mobile */
    .chatbot-input-container {
        padding: 0.875rem 1rem;
        border-top: 1px solid var(--border);
        background: rgba(255, 255, 255, 0.05);
        flex-shrink: 0;
        /* Safe area for iOS notch */
        padding-bottom: max(0.875rem, env(safe-area-inset-bottom));
    }
    
    .chatbot-form {
        display: flex;
        gap: 0.625rem;
        align-items: flex-end;
    }
    
    .chatbot-input {
        font-size: 16px !important; /* Prevent zoom on iOS */
        min-height: 44px;
        max-height: 120px;
        padding: 0.75rem 1rem;
        border-radius: 22px;
        line-height: 1.4;
        resize: none;
    }
    
    .chatbot-send {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        flex-shrink: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }
    
    .chatbot-send svg {
        width: 20px;
        height: 20px;
    }
    
    /* Footer mobile */
    .chatbot-footer {
        padding: 0.75rem 1rem;
        flex-shrink: 0;
        border-top: 1px solid var(--border);
        background: rgba(255, 255, 255, 0.02);
    }
    
    .chatbot-footer p {
        font-size: 0.75rem;
        text-align: center;
    }
    
    /* Typing indicator mobile */
    .chatbot-typing {
        padding: 0.75rem 1rem;
    }
    
    .chatbot-typing span {
        width: 6px;
        height: 6px;
    }
    
    /* Prevent body scroll when chatbot is open */
    body.chatbot-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}
