/* ═══════════════════════════════════════════════════════════════════════════════
   PREMIUM CHATBOT - Atyrau University
   Glass morphism, animations, drag & drop, responsive
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    --chatbot-primary: #187D35;
    --chatbot-primary-dark: #0d5a25;
    --chatbot-gold: #c9a227;
    --chatbot-bg: #ffffff;
    --chatbot-text: #1e293b;
    --chatbot-text-muted: #64748b;
    --chatbot-border: #e2e8f0;
    --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --chatbot-radius: 20px;
}

/* Main Container */
.au-chatbot {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9998;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Toggle Button */
.au-chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(24, 125, 53, 0.4);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.au-chatbot-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.2) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.au-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(24, 125, 53, 0.5);
}

.au-chatbot-toggle:hover::before {
    opacity: 1;
}

.au-chatbot-toggle__icon {
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
}

.au-chatbot-toggle__icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.au-chatbot--open .au-chatbot-toggle__icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.au-chatbot--open .au-chatbot-toggle__icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.au-chatbot-toggle__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

/* Chat Window */
.au-chatbot-window {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--chatbot-border);
}

.au-chatbot--open .au-chatbot-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.au-chatbot--minimized .au-chatbot-window {
    height: 60px;
}

.au-chatbot-window--dragging {
    transition: none !important;
    cursor: grabbing;
    user-select: none;
}

/* Header */
.au-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    cursor: grab;
    flex-shrink: 0;
}

.au-chatbot-header:active {
    cursor: grabbing;
}

.au-chatbot-header__info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.au-chatbot-header__avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
}

.au-chatbot-header__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.au-chatbot-header__status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid white;
}

.au-chatbot-header__text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.au-chatbot-header__text span {
    font-size: 12px;
    opacity: 0.8;
}

.au-chatbot-header__actions {
    display: flex;
    gap: 8px;
}

.au-chatbot-header__btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.au-chatbot-header__btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

.au-chatbot-header__btn svg {
    width: 16px;
    height: 16px;
}

/* Messages Container */
.au-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.au-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.au-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.au-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 3px;
}

/* Message Bubble */
.au-chatbot-message {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.au-chatbot-message--user {
    flex-direction: row-reverse;
}

.au-chatbot-message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.au-chatbot-message__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.au-chatbot-message__content {
    max-width: 75%;
}

.au-chatbot-message__text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.au-chatbot-message--bot .au-chatbot-message__text {
    background: white;
    color: var(--chatbot-text);
    border: 1px solid var(--chatbot-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.au-chatbot-message--user .au-chatbot-message__text {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.au-chatbot-message--error .au-chatbot-message__text {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.au-chatbot-message__text a {
    color: inherit;
    text-decoration: underline;
}

.au-chatbot-message--user .au-chatbot-message__text a {
    color: #bef264;
}

.au-chatbot-message__time {
    display: block;
    font-size: 11px;
    color: var(--chatbot-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.au-chatbot-message--user .au-chatbot-message__time {
    text-align: right;
}

/* Typing Indicator */
.au-chatbot-typing__dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.au-chatbot-typing__dots span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.au-chatbot-typing__dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.au-chatbot-typing__dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Quick Commands */
.au-chatbot-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--chatbot-border);
    background: #f8fafc;
}

.au-chatbot-quick__btn {
    padding: 8px 14px;
    border: 1px solid var(--chatbot-border);
    background: white;
    border-radius: 20px;
    font-size: 13px;
    color: var(--chatbot-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.au-chatbot-quick__btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(24, 125, 53, 0.3);
}

/* Input Area */
.au-chatbot-input {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--chatbot-border);
    background: white;
}

.au-chatbot-input textarea {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    max-height: 100px;
    line-height: 1.4;
}

.au-chatbot-input textarea:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(24, 125, 53, 0.1);
}

.au-chatbot-input textarea::placeholder {
    color: var(--chatbot-text-muted);
}

.au-chatbot-send {
    width: 48px;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.au-chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(24, 125, 53, 0.4);
}

.au-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.au-chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* Minimized State */
.au-chatbot--minimized .au-chatbot-messages,
.au-chatbot--minimized .au-chatbot-quick,
.au-chatbot--minimized .au-chatbot-input {
    display: none;
}

/* Responsive */
@media (max-width: 480px) {
    .au-chatbot {
        bottom: 20px;
        right: 20px;
    }

    .au-chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .au-chatbot-window {
        bottom: 90px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        height: calc(100vh - 120px);
        max-height: none;
        border-radius: 16px;
    }

    .au-chatbot-header {
        padding: 14px 16px;
    }

    .au-chatbot-messages {
        padding: 16px;
    }

    .au-chatbot-input {
        padding: 12px 16px;
    }

    .au-chatbot-quick {
        padding: 10px 16px;
    }
}

/* Animation for pulse */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Print - hide chatbot */
@media print {
    .au-chatbot {
        display: none !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .au-chatbot-toggle,
    .au-chatbot-window,
    .au-chatbot-message,
    .au-chatbot-quick__btn,
    .au-chatbot-send {
        transition: none;
        animation: none;
    }
}
