/* ============================================= */
/* AI CHATBOT - Premium Floating Assistant       */
/* Gjimnazi "Remzi Ademaj" Prizren               */
/* ============================================= */

/* CSS Variables for Chatbot theming */
:root {
    --cb-primary: #800000;
    --cb-primary-dark: #5a0000;
    --cb-primary-light: #a52a2a;
    --cb-bg: #ffffff;
    --cb-bg-secondary: #f7f7f8;
    --cb-bg-msg-user: #800000;
    --cb-bg-msg-assistant: #f0f0f2;
    --cb-text: #1a1a2e;
    --cb-text-light: #6b7280;
    --cb-text-user: #ffffff;
    --cb-text-assistant: #1a1a2e;
    --cb-border: rgba(0,0,0,0.08);
    --cb-shadow: 0 25px 60px rgba(0,0,0,0.2);
    --cb-radius: 20px;
    --cb-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --cb-transition: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== Floating Action Button ===== */
.chatbot-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.chatbot-fab-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 32px rgba(128, 0, 0, 0.35), 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.4s var(--cb-transition);
    position: relative;
    z-index: 2;
}

.chatbot-fab:hover .chatbot-fab-icon {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(128, 0, 0, 0.45), 0 4px 12px rgba(0,0,0,0.15);
}

.chatbot-fab-pulse {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(128, 0, 0, 0.25);
    animation: chatbot-pulse 2.5s infinite;
    z-index: 1;
}

@keyframes chatbot-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    70% { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(1.6); opacity: 0; }
}

.chatbot-fab.open .chatbot-fab-pulse { display: none; }

.chatbot-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    border: 2px solid #fff;
    animation: chatbot-badge-bounce 0.5s var(--cb-transition);
}

@keyframes chatbot-badge-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ===== Chat Window ===== */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--cb-bg);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s var(--cb-transition);
    font-family: var(--cb-font);
    border: 1px solid var(--cb-border);
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ===== Header ===== */
.chatbot-header {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}

.chatbot-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-header-info {
    display: flex;
    flex-direction: column;
}

.chatbot-header-name {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.chatbot-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    opacity: 0.85;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: status-blink 2s infinite;
}

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

.chatbot-header-actions {
    display: flex;
    gap: 4px;
    z-index: 1;
}

.chatbot-header-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    backdrop-filter: blur(8px);
}

.chatbot-header-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

/* ===== Messages Area ===== */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--cb-bg-secondary);
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chatbot-messages::-webkit-scrollbar { width: 5px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 10px; }

/* Welcome Area */
.chatbot-welcome-area {
    text-align: center;
    padding: 10px 0 15px;
}

.chatbot-welcome-emoji {
    font-size: 2.5rem;
    margin-bottom: 8px;
    display: block;
    animation: welcome-wave 1.5s ease-in-out;
}

@keyframes welcome-wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(20deg); }
    50% { transform: rotate(-10deg); }
    75% { transform: rotate(15deg); }
}

.chatbot-welcome-title {
    font-family: 'Montserrat', var(--cb-font);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cb-text);
    margin-bottom: 6px;
}

.chatbot-welcome-sub {
    font-size: 0.85rem;
    color: var(--cb-text-light);
    line-height: 1.5;
    max-width: 300px;
    margin: 0 auto;
}

/* Suggestions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 5px 0 10px;
}

.chatbot-suggestion-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--cb-border);
    background: var(--cb-bg);
    color: var(--cb-text);
    font-size: 0.8rem;
    font-family: var(--cb-font);
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.chatbot-suggestion-btn:hover {
    border-color: var(--cb-primary);
    color: var(--cb-primary);
    background: rgba(128, 0, 0, 0.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(128, 0, 0, 0.1);
}

/* Message Bubbles */
.chatbot-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    animation: msg-appear 0.35s var(--cb-transition);
    align-items: flex-end;
}

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

.chatbot-msg.user {
    flex-direction: row-reverse;
}

.chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.chatbot-msg.assistant .chatbot-msg-avatar {
    background: rgba(128, 0, 0, 0.1);
}

.chatbot-msg.user .chatbot-msg-avatar {
    background: rgba(128, 0, 0, 0.08);
}

.chatbot-msg-bubble {
    max-width: 82%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}

.chatbot-msg.user .chatbot-msg-bubble {
    background: var(--cb-bg-msg-user);
    color: var(--cb-text-user);
    border-bottom-right-radius: 6px;
}

.chatbot-msg.assistant .chatbot-msg-bubble {
    background: var(--cb-bg-msg-assistant);
    color: var(--cb-text-assistant);
    border-bottom-left-radius: 6px;
}

/* Markdown in messages */
.chatbot-msg-bubble h1, .chatbot-msg-bubble h2, .chatbot-msg-bubble h3 {
    font-family: 'Montserrat', var(--cb-font);
    margin: 8px 0 4px;
    font-size: 1rem;
}
.chatbot-msg-bubble h3 { font-size: 0.92rem; }
.chatbot-msg-bubble p { margin: 4px 0; }
.chatbot-msg-bubble ul, .chatbot-msg-bubble ol { margin: 4px 0; padding-left: 18px; }
.chatbot-msg-bubble li { margin: 2px 0; }
.chatbot-msg-bubble strong { font-weight: 600; }
.chatbot-msg-bubble em { font-style: italic; }
.chatbot-msg-bubble a { color: var(--cb-primary); text-decoration: underline; }
.chatbot-msg.user .chatbot-msg-bubble a { color: #ffd4d4; }

/* Code blocks */
.chatbot-msg-bubble pre {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 10px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.82rem;
    line-height: 1.5;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
}

.chatbot-msg-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.84rem;
    font-family: 'Fira Code', monospace;
}

.chatbot-msg-bubble pre code {
    background: none;
    padding: 0;
}

.chatbot-msg-time {
    font-size: 0.65rem;
    color: var(--cb-text-light);
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.chatbot-msg:hover .chatbot-msg-time { opacity: 1; }

/* ===== Typing Indicator ===== */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 10px;
    background: var(--cb-bg-secondary);
}

.chatbot-typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(128, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
    background: var(--cb-bg-msg-assistant);
    padding: 10px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.chatbot-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-text-light);
    animation: typing-dot 1.4s infinite ease-in-out;
}

.chatbot-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* ===== Input Area ===== */
.chatbot-input-area {
    padding: 12px 16px 10px;
    background: var(--cb-bg);
    border-top: 1px solid var(--cb-border);
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--cb-bg-secondary);
    border-radius: 16px;
    padding: 6px 6px 6px 16px;
    border: 1.5px solid var(--cb-border);
    transition: all 0.25s ease;
}

.chatbot-input-wrapper:focus-within {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.08);
}

.chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--cb-font);
    font-size: 0.88rem;
    color: var(--cb-text);
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    padding: 6px 0;
}

.chatbot-input::placeholder {
    color: var(--cb-text-light);
}

.chatbot-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: var(--cb-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
    opacity: 0.5;
}

.chatbot-send-btn:not(:disabled) {
    opacity: 1;
}

.chatbot-send-btn:not(:disabled):hover {
    background: var(--cb-primary-dark);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    cursor: not-allowed;
}

.chatbot-input-footer {
    text-align: center;
    padding-top: 6px;
}

.chatbot-powered {
    font-size: 0.65rem;
    color: var(--cb-text-light);
    opacity: 0.6;
}

/* ===== Error Message ===== */
.chatbot-error-msg {
    text-align: center;
    padding: 10px 16px;
    margin: 8px 16px;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 12px;
    font-size: 0.82rem;
    border: 1px solid #fecaca;
    animation: msg-appear 0.3s ease;
}

/* ===== Loading Skeleton ===== */
.chatbot-skeleton {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: flex-end;
}

.chatbot-skeleton-bubble {
    width: 65%;
    padding: 14px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    background: var(--cb-bg-msg-assistant);
}

.chatbot-skeleton-line {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.12) 50%, rgba(0,0,0,0.06) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    margin-bottom: 6px;
}

.chatbot-skeleton-line:last-child { width: 60%; margin-bottom: 0; }

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chatbot-fab {
        bottom: 20px;
        right: 20px;
    }

    .chatbot-fab-icon {
        width: 54px;
        height: 54px;
    }

    .chatbot-fab-pulse {
        width: 54px;
        height: 54px;
    }

    .chatbot-header {
        border-radius: 0;
        padding: 14px 14px;
    }

    .chatbot-msg-bubble {
        max-width: 88%;
    }
}

@media (max-width: 640px) and (min-width: 481px) {
    .chatbot-window {
        right: 12px;
        bottom: 90px;
        width: calc(100vw - 24px);
        height: calc(100vh - 110px);
    }
}
