/**
 * AFT Chatbot Widget Styles
 * Glassmorphic design with smooth animations
 */

/* CSS Variables */
:root {
    --aft-primary: #6366f1;
    --aft-primary-hover: #4f46e5;
    --aft-secondary: #22d3ee;
    --aft-bg: rgba(15, 23, 42, 0.95);
    --aft-bg-glass: rgba(30, 41, 59, 0.85);
    --aft-text: #f1f5f9;
    --aft-text-muted: #94a3b8;
    --aft-border: rgba(148, 163, 184, 0.2);
    --aft-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --aft-radius: 16px;
    --aft-radius-sm: 8px;
    --aft-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Trigger Button */
.aft-chat-trigger {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aft-primary), var(--aft-secondary));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: var(--aft-transition);
    z-index: 9998;
}

.aft-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
}

.aft-chat-trigger:active {
    transform: scale(0.95);
}

.aft-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Chat Container */
.aft-chat-container {
    position: fixed;
    bottom: 100px;
    left: 24px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--aft-bg);
    border-radius: var(--aft-radius);
    box-shadow: var(--aft-shadow);
    border: 1px solid var(--aft-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.aft-chat-container.aft-opening {
    animation: slide-up 0.3s ease-out forwards;
}

.aft-chat-container.aft-closing {
    animation: slide-down 0.3s ease-in forwards;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slide-down {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

/* Header */
.aft-chat-header {
    padding: 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(34, 211, 238, 0.1));
    border-bottom: 1px solid var(--aft-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aft-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aft-bot-avatar {
    font-size: 28px;
}

.aft-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--aft-text);
}

.aft-status {
    font-size: 12px;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 4px;
}

.aft-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}

.aft-header-actions {
    display: flex;
    gap: 8px;
}

.aft-header-actions button {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--aft-text);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--aft-transition);
}

.aft-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Templates Panel */
.aft-templates-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aft-templates-search {
    padding: 12px;
    border-bottom: 1px solid var(--aft-border);
}

.aft-search-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--aft-border);
    border-radius: var(--aft-radius-sm);
    color: var(--aft-text);
    font-size: 14px;
    outline: none;
    transition: var(--aft-transition);
}

.aft-search-input:focus {
    border-color: var(--aft-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.aft-search-input::placeholder {
    color: var(--aft-text-muted);
}

.aft-templates-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.aft-template-category {
    margin-bottom: 16px;
}

.aft-template-category h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--aft-text-muted);
    margin: 0 0 8px 0;
    letter-spacing: 0.05em;
}

.aft-template-item {
    padding: 12px;
    background: var(--aft-bg-glass);
    border-radius: var(--aft-radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--aft-transition);
    border: 1px solid transparent;
}

.aft-template-item:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--aft-primary);
    transform: translateX(4px);
}

.aft-template-name {
    display: block;
    font-weight: 500;
    color: var(--aft-text);
    margin-bottom: 4px;
}

.aft-template-desc {
    font-size: 12px;
    color: var(--aft-text-muted);
}

/* Messages Area */
.aft-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

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

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

/* Messages */
.aft-message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: message-in 0.3s ease-out;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aft-message-content {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.aft-message-bot .aft-bubble {
    background: var(--aft-bg-glass);
    border-radius: 4px 16px 16px 16px;
    max-width: 85%;
}

.aft-message-user {
    align-items: flex-end;
}

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

.aft-message-user .aft-bubble {
    background: linear-gradient(135deg, var(--aft-primary), var(--aft-secondary));
    border-radius: 16px 4px 16px 16px;
    max-width: 85%;
}

.aft-avatar {
    font-size: 24px;
    flex-shrink: 0;
}

.aft-bubble {
    padding: 12px 16px;
    color: var(--aft-text);
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid var(--aft-border);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.aft-bubble strong {
    color: var(--aft-secondary);
}

/* Options */
.aft-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 44px;
}

.aft-option-btn {
    padding: 10px 16px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--aft-primary);
    border-radius: 20px;
    color: var(--aft-text);
    font-size: 13px;
    cursor: pointer;
    transition: var(--aft-transition);
    white-space: nowrap;
}

.aft-option-btn:hover {
    background: var(--aft-primary);
    transform: translateY(-2px);
}

/* Input Area */
.aft-chat-input-area {
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid var(--aft-border);
}

.aft-quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.aft-quick-actions::-webkit-scrollbar {
    height: 0;
}

.aft-quick-actions button {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--aft-border);
    border-radius: 16px;
    color: var(--aft-text-muted);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--aft-transition);
}

.aft-quick-actions button:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--aft-primary);
    color: var(--aft-text);
}

.aft-input-row {
    display: flex;
    gap: 8px;
}

.aft-chat-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--aft-border);
    border-radius: 24px;
    color: var(--aft-text);
    font-size: 14px;
    outline: none;
    transition: var(--aft-transition);
}

.aft-chat-input:focus {
    border-color: var(--aft-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.aft-chat-input::placeholder {
    color: var(--aft-text-muted);
}

.aft-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aft-primary), var(--aft-secondary));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--aft-transition);
}

.aft-send-btn:hover {
    transform: scale(1.1);
}

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

/* Responsive */
.aft-chat-container.aft-mobile {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
}

.aft-chat-container.aft-tablet {
    bottom: 80px;
}

/* Sentinels (invisible) */
.aft-sentinel {
    pointer-events: none;
}

/* Typing indicator */
.aft-typing {
    display: flex;
    gap: 4px;
    padding: 12px;
}

.aft-typing span {
    width: 8px;
    height: 8px;
    background: var(--aft-text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.aft-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Print */
@media print {
    #aft-chatbot-widget {
        display: none !important;
    }
}