/**
 * Natasha AI Chat Widget Styles
 */

/* Container */
.natasha-ai-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 999999 !important;
    pointer-events: auto !important;
}

.natasha-ai-container * {
    box-sizing: border-box;
}

/* Floating widget */
.natasha-ai-floating {
    position: fixed;
}

.natasha-ai-floating.natasha-ai-bottom-right {
    bottom: 20px;
    right: 20px;
}

.natasha-ai-floating.natasha-ai-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Static widget */
.natasha-ai-static {
    width: 100%;
    max-width: 100%;
    position: relative;
}

.natasha-ai-static .natasha-ai-chat-window {
    position: relative;
    bottom: auto;
    right: auto;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* Chat button */
.natasha-ai-chat-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.9);
    cursor: pointer !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.5), 0 0 0 0 rgba(79, 70, 229, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto !important;
    position: relative;
    z-index: 999999 !important;
}

.natasha-ai-chat-button:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 8px 28px rgba(79, 70, 229, 0.6), 0 0 0 8px rgba(79, 70, 229, 0.1);
    border-color: rgba(255, 255, 255, 1);
}

.natasha-ai-chat-button:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.5);
}

.natasha-ai-chat-button svg {
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Pulse ring animation */
.natasha-ai-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid #6366F1;
    animation: pulse-ring 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.85);
        opacity: 0.8;
        border-width: 4px;
    }
    50% {
        opacity: 0.5;
        border-width: 3px;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
        border-width: 2px;
    }
}

/* Chat window */
.natasha-ai-chat-window {
    display: none;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-direction: column;
    pointer-events: auto !important;
    z-index: 999998 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fullscreen mode */
.natasha-ai-chat-window.natasha-ai-fullscreen {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    bottom: 20px !important;
    left: 20px !important;
    width: calc(100vw - 40px) !important;
    height: calc(100vh - 40px) !important;
    max-width: none !important;
    border-radius: 12px;
    z-index: 999999 !important;
}

.natasha-ai-floating .natasha-ai-chat-window {
    position: fixed;
}

.natasha-ai-floating.natasha-ai-bottom-right .natasha-ai-chat-window {
    bottom: 90px;
    right: 20px;
}

.natasha-ai-floating.natasha-ai-bottom-left .natasha-ai-chat-window {
    bottom: 90px;
    left: 20px;
}

.natasha-ai-static .natasha-ai-chat-window {
    display: flex !important;
}

/* Header */
.natasha-ai-header {
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
    position: relative;
    z-index: 1;
}

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

.natasha-ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.natasha-ai-avatar svg {
    width: 22px;
    height: 22px;
}

.natasha-ai-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #10B981;
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.natasha-ai-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.natasha-ai-status {
    font-size: 12px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
}

.natasha-ai-status-indicator {
    width: 6px;
    height: 6px;
    background: #10B981;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s ease-in-out infinite;
}

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

.natasha-ai-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 10;
    position: relative;
}

/* Close button - bulat seperti avatar */
.natasha-ai-close-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.natasha-ai-close-button svg {
    width: 20px !important;
    height: 20px !important;
    display: block;
}

.natasha-ai-close-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.natasha-ai-close-button:active {
    transform: scale(0.95);
}

.natasha-ai-close-button::after {
    content: 'Close';
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    transition: transform 0.2s;
    opacity: 0;
}

.natasha-ai-close-button:hover::after {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

/* Fullscreen button - bulat seperti avatar */
.natasha-ai-fullscreen-button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.natasha-ai-fullscreen-button svg {
    width: 20px !important;
    height: 20px !important;
    display: block;
}

.natasha-ai-fullscreen-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.natasha-ai-fullscreen-button:active {
    transform: scale(0.95);
}

.natasha-ai-fullscreen-button::after {
    content: 'Fullscreen';
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    transition: transform 0.2s;
    opacity: 0;
}

.natasha-ai-fullscreen-button:hover::after {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

/* Messages container */
.natasha-ai-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #F9FAFB;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0; /* Important for flexbox scroll */
    scroll-behavior: smooth;
}

.natasha-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.natasha-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.natasha-ai-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.natasha-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Message */
.natasha-ai-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: slideIn 0.3s ease;
}

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

.natasha-ai-message.user {
    align-self: flex-end;
}

.natasha-ai-message.bot {
    align-self: flex-start;
}

.natasha-ai-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.natasha-ai-message.user .natasha-ai-message-content {
    background-color: #4F46E5;
    color: white;
    border-bottom-right-radius: 4px;
}

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

/* Markdown styles in bot messages */
.natasha-ai-message.bot .natasha-ai-message-content p {
    margin: 0 0 8px 0;
}

.natasha-ai-message.bot .natasha-ai-message-content p:last-child {
    margin-bottom: 0;
}

.natasha-ai-message.bot .natasha-ai-message-content ul,
.natasha-ai-message.bot .natasha-ai-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.natasha-ai-message.bot .natasha-ai-message-content li {
    margin: 4px 0;
}

.natasha-ai-message.bot .natasha-ai-message-content code {
    background: #F3F4F6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.natasha-ai-message.bot .natasha-ai-message-content pre {
    background: #1F2937;
    color: #F9FAFB;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.natasha-ai-message.bot .natasha-ai-message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.natasha-ai-message.bot .natasha-ai-message-content a {
    color: #4F46E5;
    text-decoration: underline;
}

.natasha-ai-message.bot .natasha-ai-message-content strong {
    font-weight: 600;
}

.natasha-ai-message.bot .natasha-ai-message-content em {
    font-style: italic;
}

.natasha-ai-message-time {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 4px;
    padding: 0 4px;
}

.natasha-ai-message.user .natasha-ai-message-time {
    text-align: right;
}

/* Typing indicator */
.natasha-ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease;
}

.natasha-ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9CA3AF;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input container */
.natasha-ai-input-container {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #E5E7EB;
    align-items: flex-end;
    position: relative;
    z-index: 1;
}

.natasha-ai-input {
    flex: 1;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    overflow-y: auto;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.natasha-ai-input:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.natasha-ai-input::placeholder {
    color: #9CA3AF;
}

.natasha-ai-send-button {
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%) !important;
    color: white !important;
    border: 3px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 14px;
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.5), 
                0 0 0 2px rgba(255, 255, 255, 0.3) inset,
                0 0 25px rgba(79, 70, 229, 0.4);
    position: relative;
    z-index: 10;
    animation: send-button-glow 3s ease-in-out infinite;
}

@keyframes send-button-glow {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(79, 70, 229, 0.5), 
                    0 0 0 2px rgba(255, 255, 255, 0.3) inset,
                    0 0 25px rgba(79, 70, 229, 0.4);
        border-color: rgba(255, 255, 255, 0.4) !important;
    }
    50% {
        box-shadow: 0 4px 18px rgba(79, 70, 229, 0.6), 
                    0 0 0 3px rgba(255, 255, 255, 0.5) inset,
                    0 0 35px rgba(79, 70, 229, 0.6);
        border-color: rgba(255, 255, 255, 0.6) !important;
    }
}

.natasha-ai-send-button svg {
    width: 24px;
    height: 24px;
    stroke: white !important;
    stroke-width: 3;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    transition: all 0.3s ease;
    animation: send-icon-pulse 2s ease-in-out infinite;
}

@keyframes send-icon-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.08) translateY(-1px);
    }
}

.natasha-ai-send-button:hover {
    background: linear-gradient(135deg, #4338CA 0%, #5B21B6 100%) !important;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6), 
                0 0 0 3px rgba(255, 255, 255, 0.5) inset,
                0 0 45px rgba(79, 70, 229, 0.7);
    border-color: rgba(255, 255, 255, 0.6) !important;
    animation: none;
}

.natasha-ai-send-button:hover svg {
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
    animation: none;
    transform: scale(1.15) translateY(-2px);
}

.natasha-ai-send-button:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 3px 12px rgba(79, 70, 229, 0.5);
}

.natasha-ai-send-button:disabled {
    background: #E5E7EB !important;
    border-color: #D1D5DB !important;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
    animation: none;
}

.natasha-ai-send-button:disabled:hover {
    transform: none;
}

.natasha-ai-send-button:disabled svg {
    stroke: #9CA3AF !important;
    filter: none;
    animation: none;
}

/* Responsive */
@media (max-width: 480px) {
    .natasha-ai-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
    }
    
    .natasha-ai-floating.natasha-ai-bottom-right .natasha-ai-chat-window,
    .natasha-ai-floating.natasha-ai-bottom-left .natasha-ai-chat-window {
        left: 20px;
        right: 20px;
        bottom: 90px;
    }

    .natasha-ai-close-button,
    .natasha-ai-fullscreen-button {
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    .natasha-ai-send-button {
        width: 52px;
        height: 52px;
        min-width: 52px;
        min-height: 52px;
    }
    .natasha-ai-send-button svg {
        width: 26px;
        height: 26px;
    }
    .natasha-ai-close-button img {
        width: 22px;
        height: 22px;
    }
    .natasha-ai-fullscreen-button svg {
        width: 22px !important;
        height: 22px !important;
    }
}

/* Accessibility */
.natasha-ai-chat-button:focus,
.natasha-ai-close-button:focus,
.natasha-ai-fullscreen-button:focus,
.natasha-ai-send-button:focus {
    outline: 3px solid #4F46E5;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.2);
}

.natasha-ai-input:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Better button visibility on hover */
.natasha-ai-send-button::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    border-radius: 12px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.2s;
}

.natasha-ai-send-button:hover::before {
    opacity: 0.3;
    animation: glow-pulse 1.5s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

/* Ensure buttons are always visible regardless of header color */
.natasha-ai-close-button,
.natasha-ai-fullscreen-button {
    background: rgba(255,255,255,0.1) !important;
}

/* Ensure send button is always visible */
.natasha-ai-send-button {
    min-width: 50px;
    min-height: 50px;
}