/* =============================================
   WriteTone Support Chat Widget
   Professional AI-powered support chatbot
   ============================================= */

/* CSS Variables */
:root {
    --wt-primary: #ff6100;
    --wt-primary-dark: #e85d00;
    --wt-primary-light: #ff8533;
    --wt-secondary: #178733;
    --wt-secondary-light: #1eac41;
    --wt-dark: #1a1a2e;
    --wt-gray-100: #f8f9fa;
    --wt-gray-200: #e9ecef;
    --wt-gray-300: #dee2e6;
    --wt-gray-500: #6c757d;
    --wt-gray-700: #495057;
    --wt-chat-bg: #f5f7fb;
    --wt-user-bubble: linear-gradient(135deg, #ff6100 0%, #f27c0e 100%);
    --wt-bot-bubble: #ffffff;
    --wt-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --wt-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
    --wt-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chat Widget Launcher Button */
.wt-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: var(--wt-shadow);
    transition: var(--wt-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: visible;
}

.wt-chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: var(--wt-shadow-lg);
}


/* Logo in launcher */
.wt-launcher-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

/* Support label badge */
.wt-launcher-label {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--wt-secondary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(23, 135, 51, 0.4);
}

/* Close icon */
.wt-launcher-close {
    width: 28px;
    height: 28px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wt-launcher-close svg {
    width: 28px;
    height: 28px;
}

.wt-chat-launcher.open {
    width: 56px;
    height: 56px;
    background: var(--wt-user-bubble);
}

/* Notification Badge */
.wt-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--wt-secondary);
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: wt-pulse 2s infinite;
}

@keyframes wt-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Widget Container */
.wt-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9998;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 20px;
    box-shadow: var(--wt-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--wt-transition);
}

.wt-chat-widget.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.wt-chat-header {
    background: var(--wt-user-bubble);
    padding: 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.wt-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: wt-shine 4s infinite;
}

@keyframes wt-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.wt-chat-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.wt-chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.wt-chat-header-info {
    flex: 1;
}

.wt-chat-header-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.wt-chat-header-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wt-chat-online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: wt-pulse 2s infinite;
}

.wt-chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--wt-transition);
    backdrop-filter: blur(10px);
}

.wt-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* New Chat Button */
.wt-chat-new-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--wt-transition);
    backdrop-filter: blur(10px);
    margin-right: 8px;
}

.wt-chat-new-btn svg {
    width: 18px;
    height: 18px;
}

.wt-chat-new-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Chat Body */
.wt-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--wt-chat-bg);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wt-chat-body::-webkit-scrollbar {
    width: 6px;
}

.wt-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.wt-chat-body::-webkit-scrollbar-thumb {
    background: var(--wt-gray-300);
    border-radius: 3px;
}

/* Login Required Screen */
.wt-chat-login-required {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: var(--wt-chat-bg);
}

.wt-chat-login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #fff0e6 0%, #ffe1c8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.wt-chat-login-icon svg {
    width: 40px;
    height: 40px;
    color: var(--wt-primary);
}

.wt-chat-login-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--wt-dark);
    margin: 0 0 8px 0;
}

.wt-chat-login-text {
    font-size: 14px;
    color: var(--wt-gray-500);
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.wt-chat-login-btn {
    padding: 14px 32px;
    background: var(--wt-user-bubble);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wt-transition);
    box-shadow: 0 4px 16px rgba(255, 97, 0, 0.3);
}

.wt-chat-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 97, 0, 0.4);
}

/* Welcome Screen */
.wt-chat-welcome {
    text-align: center;
    padding: 10px 0;
}

.wt-chat-welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--wt-dark);
    margin: 0 0 8px 0;
}

.wt-chat-welcome-text {
    font-size: 14px;
    color: var(--wt-gray-500);
    margin: 0;
}

/* Quick Options Grid */
.wt-chat-quick-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px 0;
}

.wt-chat-quick-option {
    background: white;
    border: 2px solid var(--wt-gray-200);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: var(--wt-transition);
    text-align: left;
}

.wt-chat-quick-option:hover {
    border-color: var(--wt-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.wt-chat-quick-option-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.wt-chat-quick-option-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--wt-dark);
    margin: 0 0 4px 0;
}

.wt-chat-quick-option-desc {
    font-size: 12px;
    color: var(--wt-gray-500);
    margin: 0;
    line-height: 1.4;
}

/* Message Bubbles */
.wt-chat-message {
    display: flex;
    gap: 10px;
    animation: wt-message-in 0.3s ease;
}

@keyframes wt-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wt-chat-message.user {
    flex-direction: row-reverse;
}

.wt-chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.wt-chat-message.bot .wt-chat-message-avatar {
    background: linear-gradient(135deg, var(--wt-primary) 0%, var(--wt-primary-light) 100%);
    color: white;
    overflow: hidden;
}

.wt-chat-message.bot .wt-chat-message-avatar .wt-chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wt-chat-message.user .wt-chat-message-avatar {
    background: var(--wt-gray-200);
    color: var(--wt-gray-700);
}

.wt-chat-message.agent .wt-chat-message-avatar {
    background: linear-gradient(135deg, var(--wt-secondary) 0%, var(--wt-secondary-light) 100%);
    color: white;
}

.wt-chat-message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wt-chat-message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.wt-chat-message.bot .wt-chat-message-bubble {
    background: white;
    color: var(--wt-dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.wt-chat-message.user .wt-chat-message-bubble {
    background: var(--wt-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.wt-chat-message.agent .wt-chat-message-bubble {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: var(--wt-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--wt-secondary);
}

.wt-chat-message-time {
    font-size: 11px;
    color: var(--wt-gray-500);
    padding: 0 4px;
}

.wt-chat-message.user .wt-chat-message-time {
    text-align: right;
}

/* Typing Indicator */
.wt-chat-typing {
    display: flex;
    gap: 10px;
    align-items: center;
}

.wt-chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: white;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.wt-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--wt-gray-300);
    border-radius: 50%;
    animation: wt-typing 1.4s infinite ease-in-out;
}

.wt-chat-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.wt-chat-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes wt-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        background: var(--wt-gray-300);
    }
    40% {
        transform: scale(1);
        background: var(--wt-primary);
    }
}

/* Suggested Questions */
.wt-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
}

.wt-chat-suggestion {
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--wt-gray-200);
    border-radius: 20px;
    font-size: 13px;
    color: var(--wt-dark);
    cursor: pointer;
    transition: var(--wt-transition);
}

.wt-chat-suggestion:hover {
    background: var(--wt-primary);
    color: white;
    border-color: var(--wt-primary);
    transform: translateY(-2px);
}

/* Action Buttons */
.wt-chat-actions {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.wt-chat-action-btn {
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--wt-transition);
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.wt-chat-action-btn.primary {
    background: var(--wt-user-bubble);
    color: white;
}

.wt-chat-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 97, 0, 0.3);
}

.wt-chat-action-btn.secondary {
    background: white;
    color: var(--wt-dark);
    border: 1px solid var(--wt-gray-200);
}

.wt-chat-action-btn.secondary:hover {
    border-color: var(--wt-primary);
    color: var(--wt-primary);
}

.wt-chat-action-btn.success {
    background: linear-gradient(135deg, var(--wt-secondary) 0%, var(--wt-secondary-light) 100%);
    color: white;
}

.wt-chat-action-btn.success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(23, 135, 51, 0.3);
}

/* Escalation Banner */
.wt-chat-escalation-banner {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 1px solid var(--wt-secondary);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
}

.wt-chat-escalation-icon {
    width: 40px;
    height: 40px;
    background: var(--wt-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.wt-chat-escalation-text {
    flex: 1;
}

.wt-chat-escalation-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--wt-dark);
    margin: 0 0 2px 0;
}

.wt-chat-escalation-subtitle {
    font-size: 12px;
    color: var(--wt-gray-500);
    margin: 0;
}

/* Chat Footer / Input */
.wt-chat-footer {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--wt-gray-200);
}

.wt-chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.wt-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid var(--wt-gray-200);
    border-radius: 22px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: var(--wt-transition);
    font-family: inherit;
    line-height: 1.4;
}

.wt-chat-input:focus {
    border-color: var(--wt-primary);
    box-shadow: 0 0 0 3px rgba(255, 97, 0, 0.1);
}

.wt-chat-input::placeholder {
    color: var(--wt-gray-500);
}

.wt-chat-send-btn {
    width: 44px;
    height: 44px;
    background: var(--wt-user-bubble);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--wt-transition);
    flex-shrink: 0;
}

.wt-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(255, 97, 0, 0.3);
}

.wt-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer Links */
.wt-chat-footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--wt-gray-200);
}

.wt-chat-footer-link {
    font-size: 12px;
    color: var(--wt-gray-500);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--wt-transition);
}

.wt-chat-footer-link:hover {
    color: var(--wt-primary);
}

/* Email Form */
.wt-chat-email-form {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.wt-chat-email-form-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--wt-dark);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wt-chat-email-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--wt-gray-200);
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    transition: var(--wt-transition);
}

.wt-chat-email-input:focus {
    border-color: var(--wt-primary);
}

.wt-chat-email-textarea {
    width: 100%;
    height: 100px;
    padding: 12px 16px;
    border: 2px solid var(--wt-gray-200);
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: var(--wt-transition);
    font-family: inherit;
}

.wt-chat-email-textarea:focus {
    border-color: var(--wt-primary);
}

.wt-chat-email-submit {
    width: 100%;
    padding: 14px;
    background: var(--wt-user-bubble);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: var(--wt-transition);
}

.wt-chat-email-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 97, 0, 0.3);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .wt-chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .wt-chat-launcher {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .wt-chat-launcher .wt-launcher-logo {
        width: 42px;
        height: 42px;
    }

    .wt-launcher-label {
        font-size: 9px;
        padding: 2px 6px;
    }

    .wt-chat-launcher.open {
        width: 50px;
        height: 50px;
    }

    .wt-chat-quick-options {
        grid-template-columns: 1fr;
    }

    .wt-chat-header {
        padding: 16px;
        border-radius: 0;
    }

    .wt-chat-body {
        padding: 16px;
    }

    .wt-chat-footer {
        padding: 12px 16px;
    }
}

/* Dark Mode Support (if user prefers) */
@media (prefers-color-scheme: dark) {
    .wt-chat-widget.dark-mode {
        --wt-chat-bg: #1a1a2e;
        --wt-bot-bubble: #2a2a3e;
        --wt-gray-100: #2a2a3e;
        --wt-gray-200: #3a3a4e;
        --wt-dark: #ffffff;
    }
}

/* Accessibility */
.wt-chat-launcher:focus,
.wt-chat-close-btn:focus,
.wt-chat-new-btn:focus,
.wt-chat-quick-option:focus,
.wt-chat-suggestion:focus,
.wt-chat-action-btn:focus,
.wt-chat-send-btn:focus {
    outline: 2px solid var(--wt-primary);
    outline-offset: 2px;
}

/* Print styles - hide chat widget */
@media print {
    .wt-chat-launcher,
    .wt-chat-widget {
        display: none !important;
    }
}
