/**
 * KTNBS AI Chat Widget Styles
 * Modern floating chat interface
 */

/* Chat Widget Container */
#ktnbs-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button */
.ktnbs-chat-button {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktnbs-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.5);
}

.ktnbs-chat-button svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
}

.ktnbs-chat-icon {
    display: block;
}

.ktnbs-chat-close {
    display: none;
}

.ktnbs-chat-button.active .ktnbs-chat-icon {
    display: none;
}

.ktnbs-chat-button.active .ktnbs-chat-close {
    display: block;
}

/* Notification Badge */
.ktnbs-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

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

/* Chat Window */
.ktnbs-chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ktnbs-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Maximized State */
.ktnbs-chat-window.maximized {
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border-radius: 16px;
}

/* Smooth transition for maximize */
.ktnbs-chat-window {
    transition: all 0.3s ease, opacity 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Header */
.ktnbs-chat-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ktnbs-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ktnbs-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktnbs-chat-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.ktnbs-chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ktnbs-chat-status {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ktnbs-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: blink 2s infinite;
}

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

/* Header Action Buttons */
.ktnbs-chat-header-actions {
    display: flex;
    gap: 8px;
}

.ktnbs-chat-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.ktnbs-chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.ktnbs-chat-action-btn:active {
    transform: scale(0.95);
}

.ktnbs-chat-action-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Minimize Button (legacy support) */
.ktnbs-chat-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ktnbs-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ktnbs-chat-minimize svg {
    width: 20px;
    height: 20px;
    color: white;
}

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

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

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

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

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

/* Message Bubbles */
.ktnbs-message {
    display: flex;
    animation: slideIn 0.3s ease;
}

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

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

.ktnbs-message.bot {
    justify-content: flex-start;
}

.ktnbs-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ktnbs-message.user .ktnbs-message-content {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.ktnbs-message-content strong {
    font-weight: 600;
}

.ktnbs-message-content a {
    color: inherit;
    text-decoration: underline;
}

.ktnbs-message.user .ktnbs-message-content a {
    color: white;
}

.ktnbs-message.bot .ktnbs-message-content a {
    color: #3b82f6;
}

/* Typing Indicator */
.ktnbs-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

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

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

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

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

/* Quick Actions */
.ktnbs-quick-actions {
    padding: 12px 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.ktnbs-quick-action {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #374151;
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ktnbs-quick-action:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    transform: translateY(-1px);
}

/* Input Area */
.ktnbs-chat-input-container {
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 16px 16px;
}

.ktnbs-chat-form {
    padding: 16px 20px;
    display: flex;
    gap: 8px;
}

.ktnbs-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}

.ktnbs-chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ktnbs-chat-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ktnbs-chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.ktnbs-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ktnbs-chat-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Footer */
.ktnbs-chat-footer {
    padding: 8px 20px 12px;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
}

.ktnbs-chat-footer strong {
    color: #3b82f6;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ktnbs-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        right: 10px;
        bottom: 90px;
    }
    
    /* Auto-maximize on mobile */
    .ktnbs-chat-window.active {
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
    
    .ktnbs-chat-window.maximized {
        border-radius: 0;
    }
    
    #ktnbs-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .ktnbs-message-content {
        max-width: 85%;
    }
    
    /* Hide maximize button on mobile (already fullscreen) */
    #ktnbs-chat-maximize {
        display: none;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .ktnbs-chat-window {
        width: 450px;
        height: 650px;
    }
    
    .ktnbs-chat-window.maximized {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
    }
}

/* Print Styles */
@media print {
    #ktnbs-chat-widget {
        display: none !important;
    }
}
