/* ═══════════════════════════════════════════════════════════════
   AI TUTOR — Premium Chat Interface
   Enterprise-Grade Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Core Palette */
    --bg-primary: #0f0f14;
    --bg-secondary: #16161d;
    --bg-tertiary: #1c1c26;
    --bg-elevated: #222230;
    
    /* Accent Colors */
    --accent-purple: #8b5cf6;
    --accent-violet: #a78bfa;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #3b82f6 100%);
    --accent-glow: 0 0 40px rgba(139, 92, 246, 0.3);
    
    /* Text */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Borders & Effects */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(139, 92, 246, 0.3);
    --glass-bg: rgba(28, 28, 38, 0.8);
    --glass-blur: blur(20px);
    
    /* Spacing */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    
    /* Typography */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ═══════════════════════════════════════════════════════════════
   WIDGET CONTAINER
   ═══════════════════════════════════════════════════════════════ */

.ai-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--font-sans);
}

.ai-chat-widget.embedded-mode {
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
    width: 100% !important;
    height: 100% !important;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT WINDOW — The Heart
   ═══════════════════════════════════════════════════════════════ */

.chat-window {
    width: 420px;
    height: 680px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.03),
        var(--accent-glow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.embedded-mode .chat-window {
    width: 100% !important;
    height: 100% !important;
    max-width: 900px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
}

/* ═══════════════════════════════════════════════════════════════
   HEADER — Premium Branded
   ═══════════════════════════════════════════════════════════════ */

.chat-header {
    padding: 20px 24px;
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
    animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.header-info {
    flex: 1;
}

.header-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-violet);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGES AREA
   ═══════════════════════════════════════════════════════════════ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--bg-elevated) transparent;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGE BUBBLES — Premium Design
   ═══════════════════════════════════════════════════════════════ */

.message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.6;
    animation: message-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

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

/* AI Messages — Gradient Accent */
.message.ai {
    align-self: flex-start;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
}

.message.ai::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-gradient);
    border-radius: 3px 0 0 3px;
}

/* User Messages — Clean Accent */
.message.user {
    align-self: flex-end;
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

/* Message Images */
.message-image {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    border: 1px solid var(--border-subtle);
}

/* ═══════════════════════════════════════════════════════════════
   TYPING INDICATOR — Elegant Animation
   ═══════════════════════════════════════════════════════════════ */

.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background: var(--accent-purple);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ═══════════════════════════════════════════════════════════════
   IMAGE PREVIEW
   ═══════════════════════════════════════════════════════════════ */

.image-preview-container {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
}

.preview-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--accent-purple);
}

.preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    font-size: 0.65rem;
    text-align: center;
    padding: 2px;
    color: var(--accent-violet);
    font-weight: 600;
}

.remove-image {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ef4444;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.remove-image:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   INPUT AREA — Glass Effect Premium
   ═══════════════════════════════════════════════════════════════ */

.chat-input-area {
    padding: 20px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.image-upload-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.image-upload-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.image-upload-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-purple);
}

.image-upload-btn:hover svg {
    color: var(--accent-violet);
}

.chat-input {
    flex: 1;
    height: 48px;
    padding: 0 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.chat-send {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

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

.chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.chat-send:active {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════
   TOGGLE BUTTON (для лендинга)
   ═══════════════════════════════════════════════════════════════ */

.chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 8px 24px rgba(139, 92, 246, 0.4),
        0 0 0 4px rgba(139, 92, 246, 0.1);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: absolute;
    bottom: 0;
    right: 0;
}

.chat-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 
        0 12px 32px rgba(139, 92, 246, 0.5),
        0 0 0 6px rgba(139, 92, 246, 0.15);
}

.embedded-mode .chat-toggle {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .ai-chat-widget:not(.embedded-mode) {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }
    
    .chat-window {
        width: 100%;
        height: calc(100vh - 100px);
        max-height: 600px;
    }
    
    .chat-header {
        padding: 16px 20px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message {
        max-width: 90%;
        padding: 14px 16px;
    }
    
    .chat-input-area {
        padding: 16px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY & HOVER STATES
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   AI DISCLAIMER POPUP
   ═══════════════════════════════════════════════════════════════ */

.ai-disclaimer-popup {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeInPopup 0.3s ease-out;
}

@keyframes fadeInPopup {
    from { opacity: 0; }
    to { opacity: 1; }
}

.disclaimer-content {
    background: linear-gradient(145deg, #1c1c26 0%, #16161d 100%);
    border: 1px solid rgba(255, 180, 0, 0.3);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    max-width: 400px;
    text-align: center;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(255, 180, 0, 0.1);
    animation: slideUpPopup 0.3s ease-out;
}

@keyframes slideUpPopup {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.disclaimer-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: pulseIcon 2s infinite;
}

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

.disclaimer-content h4 {
    color: #fbbf24;
    font-size: 1.3em;
    font-weight: 700;
    margin: 0 0 16px 0;
    letter-spacing: -0.02em;
}

.disclaimer-content p {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.disclaimer-content p strong {
    color: #f87171;
    font-weight: 600;
}

.disclaimer-note {
    color: var(--text-muted) !important;
    font-size: 0.85em !important;
    font-style: italic;
}

.disclaimer-btn {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1c1c26;
    border: none;
    border-radius: var(--radius-full);
    padding: 14px 28px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
}

.disclaimer-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(251, 191, 36, 0.4);
}

.disclaimer-btn:active {
    transform: translateY(0);
}
