/**
 * NeQTek Chatbot Widget Styles
 * Beautiful, responsive chat interface matching NeQTek branding
 */

/* Support for safe area insets (iPhone X and newer) */
:root {
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}

/* Container */
.neqtek-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat Button */
.neqtek-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.neqtek-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(20, 184, 166, 0.5);
}

.neqtek-chat-button:active {
    transform: scale(0.95);
}

/* Chat icons */
.neqtek-chat-icon,
.neqtek-close-icon {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
    position: absolute;
}

.neqtek-chat-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.neqtek-close-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.neqtek-chat-button.open .neqtek-chat-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.neqtek-chat-button.open .neqtek-close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Pulse animation for initial attention */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
    }
    50% {
        box-shadow: 0 4px 12px rgba(20, 184, 166, 0.8), 0 0 0 8px rgba(20, 184, 166, 0.2);
    }
}

.neqtek-chat-button:not(.open) {
    animation: pulse 2s infinite;
}

/* Chat Window */
.neqtek-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.neqtek-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.neqtek-chat-header {
    background: linear-gradient(135deg, #0A1628 0%, #1A2F4D 100%);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.neqtek-chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.1) 0%, transparent 70%);
    animation: headerGlow 3s ease-in-out infinite;
}

@keyframes headerGlow {
    0%, 100% {
        transform: translate(0, 0);
    }
    50% {
        transform: translate(-10%, -10%);
    }
}

.neqtek-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.neqtek-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.neqtek-header-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.neqtek-header-text {
    flex: 1;
}

.neqtek-header-title {
    font-size: 16px;
    font-weight: 600;
    color: #14B8A6;
    margin-bottom: 2px;
}

.neqtek-header-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.neqtek-minimize-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    z-index: 1;
}

.neqtek-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.neqtek-minimize-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Messages Container */
.neqtek-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

/* Custom scrollbar */
.neqtek-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Message */
.neqtek-message {
    display: flex;
    margin-bottom: 4px;
    animation: messageSlide 0.3s ease;
}

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

.neqtek-user-message {
    justify-content: flex-end;
}

.neqtek-bot-message {
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
}

.neqtek-message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.neqtek-user-message .neqtek-message-bubble {
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.neqtek-bot-message .neqtek-message-bubble {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Quick Actions */
.neqtek-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    max-width: 80%;
}

.neqtek-quick-action-btn {
    background: white;
    border: 2px solid #14B8A6;
    color: #14B8A6;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.neqtek-quick-action-btn:hover {
    background: #14B8A6;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

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

/* Typing Indicator */
.neqtek-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-left: 20px;
    margin-bottom: 12px;
}

.neqtek-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

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

.neqtek-typing-indicator 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;
    }
}

/* Lead Capture Form */
.neqtek-lead-form {
    background: white;
    padding: 16px;
    border-radius: 12px;
    max-width: 80%;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.neqtek-lead-header {
    margin-bottom: 12px;
}

.neqtek-lead-header strong {
    color: #14B8A6;
    font-size: 15px;
}

.neqtek-lead-header p {
    color: #6b7280;
    font-size: 13px;
    margin-top: 4px;
}

.neqtek-lead-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.neqtek-lead-input:focus {
    outline: none;
    border-color: #14B8A6;
}

.neqtek-lead-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.neqtek-lead-submit,
.neqtek-lead-skip {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.neqtek-lead-submit {
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    color: white;
}

.neqtek-lead-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.neqtek-lead-skip {
    background: #f3f4f6;
    color: #6b7280;
}

.neqtek-lead-skip:hover {
    background: #e5e7eb;
}

/* Input Container */
.neqtek-chat-input-container {
    border-top: 1px solid #e5e7eb;
    background: white;
    padding: 16px;
}

.neqtek-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.neqtek-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.neqtek-chat-input:focus {
    outline: none;
    border-color: #14B8A6;
}

.neqtek-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.neqtek-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

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

.neqtek-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Footer */
.neqtek-chat-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 16px 16px;
}

/* Tablet Responsive (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .neqtek-chat-window {
        width: 360px;
        max-width: calc(100vw - 40px);
        height: 550px;
    }

    .neqtek-chat-container {
        bottom: 15px;
        right: 15px;
    }

    .neqtek-message-bubble {
        max-width: 80%;
        font-size: 14px;
    }

    .neqtek-chat-input {
        font-size: 14px;
    }
}

/* Mobile Responsive (Small phones and below) */
@media (max-width: 480px) {
    .neqtek-chat-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
    }

    .neqtek-chat-window {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
        position: fixed;
        padding-bottom: max(0px, var(--sab));
    }

    .neqtek-chat-header {
        border-radius: 0;
        padding: 16px;
        padding-top: max(16px, var(--sat));
    }

    .neqtek-chat-button {
        width: 56px;
        height: 56px;
        position: fixed;
        bottom: calc(16px + var(--sab));
        right: calc(16px + var(--sar));
    }

    .neqtek-chat-icon,
    .neqtek-close-icon {
        width: 24px;
        height: 24px;
    }

    .neqtek-message-bubble {
        max-width: 85%;
        font-size: 14px;
        padding: 10px 14px;
    }

    .neqtek-quick-actions {
        max-width: 85%;
    }

    .neqtek-quick-action-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    .neqtek-lead-form {
        max-width: 95%;
    }

    .neqtek-lead-input {
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .neqtek-chat-input {
        padding: 12px 16px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .neqtek-chat-messages {
        padding: 16px 12px;
    }

    .neqtek-chat-input-container {
        padding: 12px;
        padding-bottom: max(12px, calc(12px + var(--sab)));
    }

    .neqtek-header-title {
        font-size: 15px;
    }

    .neqtek-header-subtitle {
        font-size: 11px;
    }

    .neqtek-chat-footer {
        padding: 6px 12px;
        padding-bottom: max(6px, calc(6px + var(--sab)));
        font-size: 10px;
    }

    /* Better touch targets for mobile */
    .neqtek-send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .neqtek-minimize-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    /* Prevent overscroll/bounce on mobile */
    .neqtek-chat-messages {
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .neqtek-chat-window {
        overscroll-behavior: contain;
    }

    /* Improve tap highlighting */
    .neqtek-chat-button,
    .neqtek-send-btn,
    .neqtek-minimize-btn,
    .neqtek-quick-action-btn,
    .neqtek-lead-submit,
    .neqtek-lead-skip {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* Extra small phones (320px - 375px) */
@media (max-width: 375px) {
    .neqtek-chat-button {
        width: 52px;
        height: 52px;
        bottom: 12px;
        right: 12px;
    }

    .neqtek-chat-icon,
    .neqtek-close-icon {
        width: 22px;
        height: 22px;
    }

    .neqtek-message-bubble {
        font-size: 13px;
        padding: 9px 12px;
    }

    .neqtek-header-avatar {
        width: 36px;
        height: 36px;
    }

    .neqtek-header-avatar svg {
        width: 20px;
        height: 20px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .neqtek-chat-window {
        height: 100vh;
        max-height: 100vh;
    }

    .neqtek-chat-messages {
        padding: 12px;
    }

    .neqtek-chat-header {
        padding: 12px 16px;
    }

    .neqtek-chat-input-container {
        padding: 10px 12px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .neqtek-chat-window {
        background: #1f2937;
    }

    .neqtek-chat-messages {
        background: #111827;
    }

    .neqtek-bot-message .neqtek-message-bubble {
        background: #374151;
        color: #f9fafb;
    }

    .neqtek-chat-input-container {
        background: #1f2937;
        border-top-color: #374151;
    }

    .neqtek-chat-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .neqtek-chat-footer {
        background: #111827;
        border-top-color: #374151;
    }

    .neqtek-lead-form {
        background: #374151;
    }

    .neqtek-lead-input {
        background: #1f2937;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .neqtek-lead-skip {
        background: #4b5563;
        color: #d1d5db;
    }

    .neqtek-typing-indicator {
        background: #374151;
    }

    .neqtek-quick-action-btn {
        background: #374151;
        border-color: #14B8A6;
        color: #14B8A6;
    }

    .neqtek-quick-action-btn:hover {
        background: #14B8A6;
        color: white;
    }
}

/* Accessibility */
.neqtek-chat-button:focus,
.neqtek-minimize-btn:focus,
.neqtek-send-btn:focus,
.neqtek-quick-action-btn:focus,
.neqtek-lead-submit:focus,
.neqtek-lead-skip:focus {
    outline: 2px solid #14B8A6;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .neqtek-chat-container {
        display: none !important;
    }
}
