/**
 * KhataJi AI Assistant - Premium Chat Widget Styles
 * Clean, modern, mobile-first design with martial arts inspired aesthetics.
 * No external dependencies. Fully responsive.
 *
 * @package KhataJi_AI_Assistant
 */

:root {
    --khataji-primary: #C41E3A;
    --khataji-text: #1E2937;
    --khataji-text-muted: #64748B;
    --khataji-border: #E2E8F0;
    --khataji-bg: #FFFFFF;
    --khataji-bg-alt: #F8FAFC;
    --khataji-bubble-assistant: #F1F5F9;
    --khataji-radius: 16px;
}

/* Widget Container */
#khataji-chat-widget {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Position variants */
.khataji-position-right {
    right: 24px;
}

.khataji-position-left {
    left: 24px;
}

/* Floating Action Button - Clean and properly sized */
.khataji-chat-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2), 0 4px 6px -4px rgb(0 0 0 / 0.2);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.khataji-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.khataji-chat-button:active {
    transform: scale(0.96);
}

.khataji-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
}

.khataji-chat-button:hover .khataji-button-icon {
    transform: scale(1.05);
}

/* Clean Professional Tooltip on Hover */
.khataji-chat-button::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #1E2937;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    pointer-events: none;
    z-index: 10;
}

/* Tooltip direction: RIGHT position (default) */
.khataji-position-right .khataji-chat-button::after {
    right: 62px;
}

/* Tooltip direction: LEFT position */
.khataji-position-left .khataji-chat-button::after {
    left: 62px;
}

.khataji-chat-button:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Chat Window - Compact modern size (text reduced, not outer size) */
.khataji-chat-window {
    position: absolute;
    bottom: 80px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 530px;
    max-height: calc(100vh - 100px);
    background: var(--khataji-bg);
    border-radius: var(--khataji-radius);
    box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.12), 0 4px 10px -3px rgba(0, 0, 0, 0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--khataji-border);
    animation: khataji-slide-up 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.khataji-position-left .khataji-chat-window {
    left: 0;
}

.khataji-position-right .khataji-chat-window {
    right: 0;
}

@keyframes khataji-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.khataji-chat-window.khataji-open {
    display: flex;
}

/* Header - compact + full name handling */
.khataji-chat-header {
    padding: 10px 12px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.khataji-header-content {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.khataji-header-avatar {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.khataji-header-avatar svg {
    width: 18px;
    height: 18px;
}

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

.khataji-header-info h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.khataji-status {
    font-size: 10px;
    opacity: 0.85;
    display: block;
    margin-top: 1px;
}

.khataji-close-button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #ffffff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.khataji-close-button svg {
    width: 11px;
    height: 11px;
}

.khataji-close-button:hover {
    background: rgba(255,255,255,0.3);
}

.khataji-restart-button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #ffffff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
    margin-right: 3px;
}

.khataji-restart-button svg {
    width: 11px;
    height: 11px;
}

.khataji-restart-button:hover {
    background: rgba(255,255,255,0.35);
}

/* Messages Area */
.khataji-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px;
    background: var(--khataji-bg-alt);
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Message Bubbles - compact modern typography */
.khataji-message {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    position: relative;
    animation: khataji-message-pop 0.18s ease;
}

@keyframes khataji-message-pop {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.khataji-message.user {
    align-self: flex-end;
    background: var(--khataji-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.khataji-message.assistant {
    align-self: flex-start;
    background: var(--khataji-bubble-assistant);
    color: var(--khataji-text);
    border: none;
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.khataji-typing {
    align-self: flex-start;
    background: var(--khataji-bubble-assistant);
    padding: 8px 12px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.khataji-typing-dots {
    display: flex;
    gap: 4px;
}

.khataji-typing-dots span {
    width: 5px;
    height: 5px;
    background: #94a3b8;
    border-radius: 50%;
    animation: khataji-typing-bounce 1.1s infinite ease-in-out;
}

.khataji-typing-dots span:nth-child(1) { animation-delay: 0s; }
.khataji-typing-dots span:nth-child(2) { animation-delay: 0.12s; }
.khataji-typing-dots span:nth-child(3) { animation-delay: 0.24s; }

@keyframes khataji-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
}

/* Quick Replies - compact */
.khataji-quick-replies {
    padding: 6px 8px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--khataji-bg-alt);
    border-top: 1px solid var(--khataji-border);
}

.khataji-quick-reply-btn {
    background: #ffffff;
    border: 1px solid var(--khataji-border);
    color: var(--khataji-text-muted);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s ease;
    white-space: normal;
    text-align: left;
}

.khataji-quick-reply-btn:hover {
    background: var(--khataji-primary);
    color: #ffffff;
    border-color: var(--khataji-primary);
}

/* Input Area - compact + better placeholder */
.khataji-input-area {
    padding: 8px 10px 10px;
    background: var(--khataji-bg);
    border-top: 1px solid var(--khataji-border);
    flex-shrink: 0;
}

.khataji-input-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.khataji-user-input {
    flex: 1;
    border: 1px solid var(--khataji-border);
    border-radius: 18px;
    padding: 7px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.khataji-user-input:focus {
    border-color: var(--khataji-primary);
    box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.1);
}

.khataji-send-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.khataji-send-button svg {
    width: 14px;
    height: 14px;
}

.khataji-send-button:hover {
    transform: scale(1.05);
}

.khataji-send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Action buttons row - compact */
.khataji-action-row {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.khataji-connect-human.compact,
.khataji-show-quick-questions.compact {
    flex: 1;
    margin-top: 0;
    padding: 5px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 5px;
}

.khataji-connect-human.compact {
    background: var(--khataji-bg-alt);
    border: 1px solid var(--khataji-border);
    color: var(--khataji-text-muted);
}

.khataji-show-quick-questions.compact {
    background: transparent;
    border: 1px dashed var(--khataji-border);
    color: var(--khataji-text-muted);
}

.khataji-connect-human.compact:hover {
    background: #e0e7ff;
    border-color: #6366f1;
    color: #4338ca;
}

.khataji-show-quick-questions.compact:hover {
    background: var(--khataji-bg-alt);
    border-color: var(--khataji-text-muted);
    color: var(--khataji-text);
}

/* Footer Note */
.khataji-footer-note {
    text-align: center;
    font-size: 10px;
    color: var(--khataji-text-muted);
    padding: 6px 10px;
    background: var(--khataji-bg-alt);
    border-top: 1px solid var(--khataji-border);
}

/* Contact Coach Modal - Clean modern (Option A layout) */
.khataji-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--khataji-radius);
}

.khataji-modal-content {
    background: var(--khataji-bg);
    width: 94%;
    max-width: 310px;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    margin: 0 auto;
}

.khataji-modal-header {
    padding: 12px 14px;
    background: var(--khataji-bg-alt);
    border-bottom: 1px solid var(--khataji-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.khataji-modal-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--khataji-text);
}

.khataji-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--khataji-text-muted);
    line-height: 1;
}

.khataji-modal-body {
    padding: 14px;
}

.khataji-contact-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.khataji-contact-card {
    background: var(--khataji-bg);
    border: 1px solid var(--khataji-border);
    border-radius: 10px;
    padding: 10px 12px;
    transition: all 0.15s ease;
}

.khataji-contact-card:hover {
    border-color: #cbd5e1;
}

.khataji-contact-card .contact-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.khataji-contact-card .contact-name {
    font-weight: 600;
    color: var(--khataji-text);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.khataji-contact-card .contact-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.khataji-contact-card .contact-number {
    font-size: 11px;
    color: var(--khataji-text-muted);
    margin-top: 4px;
    padding-left: 2px;
}

.khataji-action-btn {
    padding: 5px 9px;
    border: none;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.1s ease;
    min-width: 58px;
}

.khataji-action-btn.whatsapp-btn {
    background: #25D366;
    color: white;
}

.khataji-action-btn.whatsapp-btn:hover {
    background: #128C7E;
}

.khataji-action-btn.call-btn {
    background: #3b82f6;
    color: white;
}

.khataji-action-btn.call-btn:hover {
    background: #2563eb;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .khataji-position-right {
        right: 16px;
        bottom: 16px;
        left: auto;
    }

    .khataji-position-left {
        left: 16px;
        bottom: 16px;
        right: auto;
    }

    .khataji-chat-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 90px);
        bottom: 70px;
        max-height: none;
    }

    .khataji-position-left .khataji-chat-window,
    .khataji-position-right .khataji-chat-window {
        left: 0;
        right: 0;
    }

    .khataji-chat-button {
        width: 52px;
        height: 52px;
    }
}

/* Accessibility & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .khataji-chat-button,
    .khataji-chat-window,
    .khataji-message {
        animation: none;
        transition: none;
    }
}

/* Screen Reader Only */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}