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

/* Обертка для перетаскивания и позиционирования по экрану */
.ai-bot {
    position: absolute;
    width: 150px;
    height: 150px;
    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: 50%;
}

.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: #ffffff; /* Чистый белый фон */
    border: 1px solid #ebd5c1; /* Тонкая тёплая песочно-терракотовая рамка */
    border-radius: 16px;
    padding: 12px 18px;
    color: #1e1b18; /* Тёмный благородный графит */
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: pre-wrap;
    min-width: 200px;
    max-width: 270px;
    box-shadow: 0 12px 30px rgba(196, 85, 43, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04);
    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: 14px;
    text-align: left;
}

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

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

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

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

/* Kira Avatar Styling */
.ai-bot .ai-body.ai-body-kira {
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 3px solid #ffffff !important;
    box-shadow: 0 8px 25px rgba(196, 85, 43, 0.35), 0 0 0 2.5px #c4552b !important;
    overflow: hidden;
    position: relative;
    padding: 0;
}
.ai-body.ai-body-kira::before {
    display: none !important;
}
.kira-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    transition: transform 0.3s ease;
}
.ai-bot:hover .kira-avatar-img {
    transform: scale(1.08);
}
.kira-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    z-index: 5;
    animation: kiraPulse 2s infinite;
}
@keyframes kiraPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.85); opacity: 0.7; }
}

/* Квадратное высокотехнологичное тело робота */
.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: 120px;
        height: 120px;
        border-radius: 50%;
    }
    .ai-bot .ai-body {
        border-radius: 50%;
    }
    .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;
  background: #ffffff;
  border: 1px solid #e8e4dc;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.12), 0 4px 15px rgba(196, 85, 43, 0.08);
  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: 480px;
}

.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, #c4552b 0%, #ad441c 100%);
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.expik-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
  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: 320px;
  min-height: 200px;
  background: #fdfbf7;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.expik-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  font-family: 'Manrope', 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: #ffffff;
  color: #1e1b18;
  border: 1px solid #ebd5c1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.expik-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #c4552b 0%, #a83d16 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(196, 85, 43, 0.25);
}

.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 #e8e4dc;
  background: #ffffff;
}

.expik-chat-input {
  flex: 1;
  background: #f7f3eb;
  border: 1px solid #ebd5c1;
  border-radius: 10px;
  padding: 10px 14px;
  color: #1e1b18;
  font-size: 13px;
  font-family: 'Manrope', sans-serif;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.expik-chat-input:focus {
  border-color: #c4552b;
  background: #ffffff;
}
.expik-chat-input::placeholder {
  color: #a8a29e;
}

.expik-chat-send {
  background: linear-gradient(135deg, #c4552b 0%, #ad441c 100%);
  border: none;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
}
.expik-chat-send:hover { opacity: 0.92; transform: scale(1.03); }
.expik-chat-send:active { transform: scale(0.97); }

.expik-chat-mic {
  background: #f7f3eb;
  border: 1px solid #ebd5c1;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}
.expik-chat-mic:hover { background: #efe8dc; }
.expik-chat-mic.recording {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  animation: expikMicPulse 1s infinite;
}
  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 — responsive sizing, pinned bottom-right, centered chat
   ========================================================================== */
@media (max-width: 767px) {
  /* Bot body on mobile — enlarged for visibility */
  .ai-bot {
    width: 74px !important;
    height: 74px !important;
    z-index: 9995 !important;
    bottom: 85px !important; /* Above mobile dock */
  }

  .ai-body {
    width: 74px !important;
    height: 74px !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: 210px !important;
    padding: 9px 13px !important;
    font-size: 0.78rem !important;
    line-height: 1.35 !important;
    left: auto !important;
    right: 0 !important;
    background: #ffffff !important;
    border: 1px solid #ebd5c1 !important;
    color: #1e1b18 !important;
    box-shadow: 0 10px 24px rgba(196, 85, 43, 0.14) !important;
    border-radius: 14px !important;
    transform: translateX(0) translateY(8px) scale(0.85) !important;
    bottom: 100% !important;
  }

  .ai-bot .ai-speech-bubble::after {
    left: auto !important;
    right: 18px !important;
    border-color: #ffffff transparent transparent transparent !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 — responsive sizing, stays mobile, centered chat
   ========================================================================== */
@media (max-width: 767px) {
  .ai-bot {
    width: 74px !important;
    height: 74px !important;
  }

  .ai-body {
    width: 74px !important;
    height: 74px !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;
}
