/* ============================================
   IN TYME WEB DESIGNS — AI CHATBOT WIDGET
   ============================================ */

/* ---------- Chat Bubble (Toggle Button) ---------- */
.itwd-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b61ff 100%);
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4), 0 0 40px rgba(123, 97, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: itwd-pulse 3s ease-in-out infinite;
}

.itwd-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 30px rgba(0, 212, 255, 0.6), 0 0 60px rgba(123, 97, 255, 0.3);
}

.itwd-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.itwd-chat-bubble .itwd-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.itwd-chat-bubble.open .itwd-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

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

@keyframes itwd-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4), 0 0 40px rgba(123, 97, 255, 0.2); }
    50% { box-shadow: 0 4px 30px rgba(0, 212, 255, 0.6), 0 0 60px rgba(123, 97, 255, 0.35); }
}

.itwd-chat-bubble.open {
    animation: none;
}

/* Unread badge */
.itwd-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid #0a0a0f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.itwd-chat-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* ---------- Chat Panel ---------- */
.itwd-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-height: 560px;
    display: flex;
    flex-direction: column;
    background: rgba(12, 12, 18, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(42, 42, 58, 0.8);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 80px rgba(0, 212, 255, 0.08);
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.itwd-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---------- Chat Header ---------- */
.itwd-chat-header {
    padding: 16px 20px;
    background: rgba(16, 16, 24, 0.95);
    border-bottom: 1px solid rgba(42, 42, 58, 0.6);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.itwd-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff 0%, #7b61ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.itwd-chat-avatar svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

.itwd-chat-header-info {
    flex: 1;
    min-width: 0;
}

.itwd-chat-header-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    line-height: 1.3;
}

.itwd-chat-header-subtitle {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    color: #00d4ff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.itwd-chat-header-subtitle::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #00d4ff;
    border-radius: 50%;
    display: inline-block;
    animation: itwd-status-pulse 2s ease-in-out infinite;
}

@keyframes itwd-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- Chat Messages ---------- */
.itwd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(42, 42, 58, 0.5) transparent;
}

.itwd-chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.itwd-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(42, 42, 58, 0.5);
    border-radius: 2px;
}

/* ---------- Message Bubbles ---------- */
.itwd-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: itwd-msg-in 0.3s ease;
}

@keyframes itwd-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.itwd-msg-bot {
    align-self: flex-start;
    background: rgba(22, 22, 31, 0.9);
    color: #e0e0e8;
    border: 1px solid rgba(42, 42, 58, 0.5);
    border-bottom-left-radius: 4px;
}

.itwd-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(123, 97, 255, 0.15) 100%);
    color: #ffffff;
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-bottom-right-radius: 4px;
}

/* ---------- Quick Reply Buttons ---------- */
.itwd-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.itwd-quick-btn {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.06);
    color: #00d4ff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.itwd-quick-btn:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}

/* ---------- Typing Indicator ---------- */
.itwd-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(22, 22, 31, 0.9);
    border: 1px solid rgba(42, 42, 58, 0.5);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    animation: itwd-msg-in 0.3s ease;
}

.itwd-typing-dot {
    width: 6px;
    height: 6px;
    background: #a0a0b0;
    border-radius: 50%;
    animation: itwd-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes itwd-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Chat Input ---------- */
.itwd-chat-input-wrap {
    padding: 12px 16px;
    border-top: 1px solid rgba(42, 42, 58, 0.6);
    background: rgba(16, 16, 24, 0.95);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.itwd-chat-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(22, 22, 31, 0.8);
    border: 1px solid rgba(42, 42, 58, 0.6);
    border-radius: 10px;
    color: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
    min-height: 40px;
    max-height: 80px;
    line-height: 1.4;
}

.itwd-chat-input::placeholder {
    color: #6a6a7a;
}

.itwd-chat-input:focus {
    border-color: rgba(0, 212, 255, 0.4);
}

.itwd-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #00d4ff 0%, #7b61ff 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.itwd-chat-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.itwd-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.itwd-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* ---------- Powered By ---------- */
.itwd-chat-footer {
    padding: 6px 16px 8px;
    text-align: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 10px;
    color: #4a4a5a;
    background: rgba(16, 16, 24, 0.95);
    flex-shrink: 0;
}

.itwd-chat-footer a {
    color: #6a6a7a;
    text-decoration: none;
    transition: color 0.2s ease;
}

.itwd-chat-footer a:hover {
    color: #00d4ff;
}

/* ---------- Lead Confirmation Card ---------- */
.itwd-lead-card {
    margin: 8px 0;
    padding: 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08) 0%, rgba(123, 97, 255, 0.08) 100%);
    border: 1px solid rgba(0, 212, 255, 0.25);
    border-radius: 12px;
    animation: itwd-msg-in 0.3s ease;
}

.itwd-lead-card-header {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 10px;
}

.itwd-lead-card-info {
    margin-bottom: 14px;
}

.itwd-lead-card-info p {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin: 3px 0;
    line-height: 1.4;
}

.itwd-lead-card-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #00d4ff, #7b61ff);
    color: #0a0a0f;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.itwd-lead-card-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
}

.itwd-lead-card-btn:active {
    transform: translateY(0);
}

.itwd-lead-card-done {
    background: rgba(39, 202, 64, 0.08);
    border-color: rgba(39, 202, 64, 0.3);
}

.itwd-lead-card-confirmed {
    display: flex;
    align-items: center;
    gap: 10px;
}

.itwd-lead-card-check {
    color: #27ca40;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.itwd-lead-card-confirmed p {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    line-height: 1.4;
}

/* ---------- Mobile Styles ---------- */
@media (max-width: 768px) {
    .itwd-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100%;
        height: 100dvh;
        border-radius: 0;
        border: none;
        transform: translateY(100%);
    }

    .itwd-chat-panel.open {
        transform: translateY(0);
    }

    .itwd-chat-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .itwd-chat-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .itwd-chat-bubble svg {
        width: 24px;
        height: 24px;
    }

    .itwd-chat-input-wrap {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Mobile close button in header */
    .itwd-chat-mobile-close {
        display: flex;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        border: none;
        background: rgba(42, 42, 58, 0.5);
        border-radius: 8px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .itwd-chat-mobile-close svg {
        width: 16px;
        height: 16px;
        fill: #a0a0b0;
    }
}

@media (min-width: 769px) {
    .itwd-chat-mobile-close {
        display: none;
    }
}
