/* ==========================================================================
   TATEXPO — ИНТЕРАКТИВНЫЙ AI-АССИСТЕНТ
   ========================================================================== */

/* Обертка для перетаскивания и позиционирования по экрану */
.ai-bot {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 9995;
    cursor: grab;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Предотвращает нежелательный скролл при перетаскивании */
    transition: transform 0.2s ease-out;
    border-radius: 8px;
}

.ai-bot:active {
    cursor: grabbing;
}

/* Всплывающее облачко (Speech Bubble) */
.ai-bot .ai-speech-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px) scale(0.85);
    background: rgba(10, 15, 26, 0.94); /* Глубокий тёмный фон со стеклянным эффектом */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 235, 199, 0.35);
    border-radius: 8px; /* Архитектурная геометрия сетки */
    padding: 12px 18px;
    color: #ffffff;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.38;
    letter-spacing: -0.01em;
    white-space: pre-wrap;
    min-width: 200px;
    max-width: 270px;
    box-shadow: 
        0 16px 36px rgba(0, 0, 0, 0.6), 
        0 0 20px rgba(0, 235, 199, 0.25), 
        0 0 35px rgba(59, 130, 246, 0.2);
    opacity: 0;
    transform-origin: bottom center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
    pointer-events: none;
    z-index: 10;
    margin-bottom: 16px;
    text-align: left;
}

/* Хвостик облачка */
.ai-bot .ai-speech-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: rgba(10, 15, 26, 0.94) transparent transparent transparent;
}

/* Показ облачка */
.ai-bot .ai-speech-bubble.show {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
}

/* Мигающий курсор при печати (неоновый бирюзовый #00ebc7) */
.ai-bot .ai-speech-text::after {
    content: '|';
    animation: aiBlinkCursor 0.8s step-start infinite;
    color: #00ebc7;
    margin-left: 2px;
    font-weight: 700;
}

@keyframes aiBlinkCursor {
    50% { opacity: 0; }
}

/* Квадратное высокотехнологичное тело робота */
.ai-bot .ai-body {
    width: 100%;
    height: 100%;
    border-radius: 8px; /* Квадратная форма с небольшим скруглением углов */
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(10, 15, 30, 0.92) 50%, rgba(13, 27, 50, 0.95) 100%);
    border: 1.5px solid rgba(0, 235, 199, 0.7);
    box-shadow: 
        0 0 20px rgba(0, 235, 199, 0.5),
        0 0 35px rgba(59, 130, 246, 0.35),
        inset 0 0 18px rgba(0, 235, 199, 0.25),
        inset 0 0 30px rgba(59, 130, 246, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: aiFlight 8s infinite ease-in-out, aiPulseGlow 3s infinite ease-in-out;
    transform-style: preserve-3d;
    transition: transform 0.25s ease;
    position: relative;
    overflow: hidden;
}

/* Верхний неоновый световой блик */
.ai-bot .ai-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(180deg, rgba(0, 235, 199, 0.22) 0%, transparent 100%);
    pointer-events: none;
    border-radius: 6px 6px 0 0;
}

/* Пульсирующее неоновое свечение (#00ebc7 бирюзовый и #3b82f6 электрик-синий) */
@keyframes aiPulseGlow {
    0%, 100% {
        box-shadow: 
            0 0 16px rgba(0, 235, 199, 0.5),
            0 0 32px rgba(59, 130, 246, 0.35),
            0 10px 25px rgba(0, 0, 0, 0.45),
            inset 0 0 15px rgba(0, 235, 199, 0.3),
            inset 0 0 25px rgba(59, 130, 246, 0.25);
        border-color: rgba(0, 235, 199, 0.75);
    }
    50% {
        box-shadow: 
            0 0 30px rgba(0, 235, 199, 0.85),
            0 0 55px rgba(59, 130, 246, 0.65),
            0 15px 35px rgba(0, 0, 0, 0.6),
            inset 0 0 24px rgba(0, 235, 199, 0.5),
            inset 0 0 40px rgba(59, 130, 246, 0.4);
        border-color: rgba(59, 130, 246, 0.95);
    }
}

/* Контейнер глаз */
.ai-bot .ai-eyes {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    animation: aiBlink 6s infinite;
    pointer-events: none;
    z-index: 2;
}

/* Зрачки/глаза робота (сохраняют плавную округлую форму зрачков) */
.ai-bot .ai-eye {
    width: 12px;
    height: 34px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 0 10px #ffffff, 0 0 18px #00ebc7, 0 0 28px #3b82f6;
    transform-origin: center center;
    transition: transform 0.08s ease-out;
    will-change: transform;
}

/* Резкое двойное моргание в конце цикла */
@keyframes aiBlink {
    0%, 88%, 92%, 96%, 100% { transform: scaleY(1); }
    90%, 94% { transform: scaleY(0.1); } 
}

/* Плавный полет, зависания и левитация робота */
@keyframes aiFlight {
    0%   { transform: translate(0, 0) rotate(0deg); }
    20%  { transform: translate(-12px, -16px) rotate(-4deg); }
    40%  { transform: translate(14px, -8px) rotate(5deg) scale(1.03); }
    55%  { transform: translate(18px, 12px) rotate(3deg); }
    75%  { transform: translate(-12px, 10px) rotate(-3deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Спец-анимация: Кивок */
.ai-nod {
    animation: aiNodAnim 0.8s ease-in-out !important;
}
@keyframes aiNodAnim {
    0%, 100% { transform: rotateX(0deg) translateY(0) scale(1.05); }
    30% { transform: rotateX(25deg) translateY(8px) scale(1.05); }
    60% { transform: rotateX(-8deg) translateY(-3px) scale(1.05); }
}

/* Спец-анимация: Отскок при приземлении */
.ai-bounce {
    animation: aiBounceAnim 0.5s ease-in-out !important;
}
@keyframes aiBounceAnim {
    0%, 100% { transform: scale(1, 1) translateY(0); }
    30% { transform: scale(1.2, 0.8) translateY(8px); }
    60% { transform: scale(0.9, 1.12) translateY(-10px); }
    80% { transform: scale(1.05, 0.96) translateY(3px); }
}

/* Адаптивность для мобильных экранов */
@media (max-width: 768px) {
    .ai-bot {
        width: 68px;
        height: 68px;
        border-radius: 8px;
    }
    .ai-bot .ai-body {
        border-radius: 8px;
    }
    .ai-bot .ai-eye {
        width: 10px;
        height: 28px;
    }
    .ai-bot .ai-eyes {
        gap: 11px;
    }
    .ai-bot .ai-speech-bubble {
        min-width: 170px;
        max-width: 230px;
        font-size: 0.85rem;
        padding: 10px 14px;
        border-radius: 8px;
    }
}


/* ==========================================================================
   ЭКСПИК CHAT WINDOW
   ========================================================================== */
.expik-chat-window {
  position: absolute;
  z-index: 10001;
  /* overlay is 9990, chat stays above */
  background: var(--bg-elevated, #1a1a1a);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  max-height: 450px;
}

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

.expik-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #00ebc7 0%, #3b82f6 100%);
  color: #fff;
  font-family: var(--font-heading, 'Unbounded', sans-serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.expik-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.expik-chat-close:hover { opacity: 1; }

.expik-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  min-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.expik-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  animation: expikMsgIn 0.3s ease;
}

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

.expik-msg--bot {
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  color: var(--text-primary, #fff);
  border: 1px solid rgba(255,255,255,0.06);
}

.expik-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #00ebc7 0%, #3b82f6 100%);
  color: #fff;
}

.expik-typing .expik-dots {
  display: inline-block;
  animation: expikDots 1s infinite;
}
@keyframes expikDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.expik-chat-form {
  display: flex;
  padding: 12px;
  gap: 8px;
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
  background: var(--bg-elevated, #1a1a1a);
}

.expik-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary, #fff);
  font-size: 13px;
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  outline: none;
  transition: border-color 0.2s;
}
.expik-chat-input:focus {
  border-color: #00ebc7;
}
.expik-chat-input::placeholder {
  color: var(--text-secondary, #666);
}

.expik-chat-send {
  background: linear-gradient(135deg, #00ebc7 0%, #3b82f6 100%);
  border: none;
  border-radius: 8px;
  width: 42px;
  height: 42px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.expik-chat-send:hover { opacity: 0.85; }

/* Light theme overrides for chat */
body.light-theme .expik-chat-window {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
body.light-theme .expik-msg--bot {
  background: #f1f5f9;
  color: #0f172a;
  border-color: rgba(0,0,0,0.05);
}
body.light-theme .expik-chat-form {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}
body.light-theme .expik-chat-input {
  background: #f8fafc;
  border-color: rgba(0,0,0,0.1);
  color: #0f172a;
}
body.light-theme .expik-chat-input::placeholder {
  color: #94a3b8;
}

/* Mobile: full-width bottom sheet */
@media (max-width: 767px) {
  .expik-chat-window {
    max-height: 60vh !important;
    border-radius: 16px 16px 0 0 !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
  }
  .expik-chat-messages {
    max-height: 45vh;
  }
}

/* ==========================================================================
   NEWS CARDS GRID
   ========================================================================== */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 48px;
}

.news-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.news-card:hover {
  transform: translateY(-4px);
  border-color: #00ebc7;
  box-shadow: 0 12px 40px rgba(0, 235, 199, 0.1);
}

.news-card__image {
  height: 200px;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border-color);
}

.news-card__body {
  padding: 24px;
}

.news-card__date {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 12px;
}

.news-card__title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.news-card__text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.news-card__link {
  font-size: 13px;
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: color 0.2s;
}
.news-card__link:hover { color: #00ebc7; }

@media (max-width: 1024px) {
  .news-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .news-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   MOBILE: EXPIC BOT — smaller, pinned bottom-right, centered chat
   ========================================================================== */
@media (max-width: 767px) {
  /* Smaller bot body */
  .ai-bot {
    width: 56px !important;
    height: 56px !important;
    z-index: 9995 !important;
  }

  .ai-body {
    width: 56px !important;
    height: 56px !important;
  }

  .ai-eyes {
    gap: 10px !important;
    padding: 0 !important;
  }

  .ai-eye {
    width: 10px !important;
    height: 10px !important;
  }

  /* Smaller speech bubble */
  .ai-bot .ai-speech-bubble {
    min-width: 140px !important;
    max-width: 180px !important;
    padding: 8px 12px !important;
    font-size: 0.72rem !important;
    line-height: 1.3 !important;
    left: auto !important;
    right: 0 !important;
    transform: translateX(0) translateY(8px) scale(0.85) !important;
    bottom: 100% !important;
  }

  .ai-bot .ai-speech-bubble.show {
    transform: translateX(0) translateY(0) scale(1) !important;
  }

  /* Bot stays absolute — JS positions it mid-screen */

  /* Chat window: centered modal on mobile */
  .expik-chat-window {
    position: fixed !important;
    top: 10px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) scale(0.95) !important;
    width: calc(100vw - 20px) !important;
    max-width: 380px !important;
    height: 380px !important; /* Fixed height on mobile so it does not squish */
    min-height: 320px !important;
    border-radius: 14px !important;
    z-index: 99999 !important;
  }

  .expik-chat-window.open {
    transform: translateX(-50%) scale(1) !important;
  }

  .expik-chat-header {
    padding: 12px 14px !important;
    font-size: 12px !important;
  }

  .expik-chat-messages {
    padding: 12px !important;
    flex: 1 !important;
    min-height: 200px !important;
    max-height: 260px !important;
  }

  .expik-msg {
    font-size: 13px !important;
    padding: 8px 12px !important;
    max-width: 90% !important;
  }

  .expik-chat-form {
    padding: 10px !important;
  }

  .expik-chat-input {
    font-size: 14px !important; /* prevent iOS zoom */
    padding: 10px 12px !important;
  }
}

/* ==========================================================================
   MOBILE: EXPIC BOT — smaller, stays mobile, centered chat
   ========================================================================== */
@media (max-width: 767px) {
  .ai-bot {
    width: 56px !important;
    height: 56px !important;
  }

  .ai-body {
    width: 56px !important;
    height: 56px !important;
  }

  .ai-eyes {
    gap: 10px !important;
  }

  .ai-eye {
    width: 10px !important;
    height: 10px !important;
  }

  /* Smaller speech bubble */
  .ai-bot .ai-speech-bubble {
    min-width: 140px !important;
    max-width: 180px !important;
    padding: 8px 12px !important;
    font-size: 0.72rem !important;
    line-height: 1.3 !important;
  }

  /* Chat window: centered modal */
  .expik-chat-window {
    position: fixed !important;
    top: 10px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) scale(0.95) !important;
    width: calc(100vw - 20px) !important;
    max-width: 380px !important;
    height: 380px !important; /* Fixed height on mobile so it does not squish */
    min-height: 320px !important;
    border-radius: 14px !important;
    z-index: 99999 !important;
  }

  .expik-chat-window.open {
    transform: translateX(-50%) scale(1) !important;
  }

  .expik-chat-header {
    padding: 12px 14px !important;
    font-size: 12px !important;
  }

  .expik-chat-messages {
    padding: 12px !important;
    flex: 1 !important;
    min-height: 200px !important;
    max-height: 260px !important;
  }

  .expik-msg {
    font-size: 13px !important;
    padding: 8px 12px !important;
    max-width: 90% !important;
  }

  .expik-chat-form {
    padding: 10px !important;
  }

  .expik-chat-input {
    font-size: 14px !important;
    padding: 10px 12px !important;
  }
}

/* ==========================================================================
   CHAT OVERLAY
   ========================================================================== */
.expik-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9990;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.expik-overlay.open {
  opacity: 1;
}

/* ==========================================================================
   SPEECH RECOGNITION BUTTON
   ========================================================================== */
.expik-chat-mic {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  width: 42px;
  height: 42px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.expik-chat-mic:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.expik-chat-mic.recording {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  animation: expikPulseMic 1.5s infinite;
}

@keyframes expikPulseMic {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Light theme overrides for mic */
body.light-theme .expik-chat-mic {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}
body.light-theme .expik-chat-mic:hover {
  background: #e2e8f0;
}
