/* =========================
   PAGE / GAME CARDS
   ========================= */

.main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  max-width: var(--page-max);
  padding: 40px var(--page-pad);
  margin: 0 auto;
  width: 100%;
}

.content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 28px;
  justify-content: flex-start;
  width: 100%;
  padding-right: 380px;
  box-sizing: border-box;
}

.game-section {
  width: 100%;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: #ffa500;
  margin: 6px 0 14px;
  letter-spacing: 0.2px;
}

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 16px;
  align-items: flex-start;
  width: 100%;
}

.search-empty {
  width: 100%;
  text-align: center;
  padding: 24px 0 8px;
  color: #ffcc66;
  font-size: 18px;
}

.game-card {
  background: none;
  border-radius: 0;
  overflow: visible;
  text-decoration: none;
  box-shadow: none;
  transition: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  min-height: 0;
  border: none;
  padding: 0;
}

.game-card:hover {
  transform: none;
}

.game-card.hidden-by-limit,
.game-card.hidden-by-search {
  display: none;
}

.game-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: rgba(12, 12, 12, 0.9);
  border-radius: 16px;
}

.game-cover-frame {
  width: 100%;
  padding: 0;
  border-radius: 16px;
  background: none;
  box-shadow: none;
  position: relative;
  overflow: visible;
}

.game-cover-frame .game-cover {
  border-radius: 16px;
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
}

.game-cover-frame:hover .game-cover {
  transform: scale(1.04);
}

.game-cover-frame::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 165, 0, 0.7), rgba(255, 204, 102, 0.5), rgba(255, 165, 0, 0.35));
  filter: blur(12px);
  opacity: 0;
  z-index: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.game-cover-frame:hover::before {
  opacity: 0.75;
}

.game-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #ffcc66;
  text-transform: uppercase;
}

.game-title {
  padding: 0;
  color: #ffa500;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  min-height: 0;
  display: block;
  width: 100%;
  transition: color 0.2s ease, text-shadow 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.game-title:hover {
  color: #ffcc66;
  text-shadow: 0 0 6px #ffa500;
}

/* =========================
   LIGHT THEME — GAME CARDS
   ========================= */

body.light-theme .game-card {
  background: none;
  border: none;
  box-shadow: none;
}

body.light-theme .game-card:hover {
  transform: none;
}

body.light-theme .section-title {
  color: #000;
}

body.light-theme .game-title {
  color: #000;
}
body.light-theme .game-title:hover {
  color: #ff9500;
  text-shadow: none;
}

.show-more-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.show-more-btn {
  background: rgba(255, 165, 0, 0.12);
  color: #ffcc66;
  border: 1px solid rgba(255, 165, 0, 0.35);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.show-more-btn:hover {
  background: rgba(255, 165, 0, 0.25);
  color: #ffa500;
  border-color: rgba(255, 165, 0, 0.6);
}

body.light-theme .show-more-btn {
  background: #fff5dd;
  color: #111;
  border-color: #f1c27a;
}

body.light-theme .main {
  padding-top: 40px;
  transition: padding 0.3s ease;
}

body.light-theme .search-empty {
  color: #000;
}

@media (max-width: 1100px) {
  .content {
    padding-right: 0;
  }
}

body.light-theme .game-cover-frame:hover::before {
  opacity: 0;
}

@media (max-width: 720px) {
  .game-list {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
  .ai-widget {
    right: 12px;
    bottom: 16px;
  }
}

/* =========================
   AI WIDGET
   ========================= */

/* фиксируем ширину кнопки, чтобы прогресс можно было сделать ровно как textarea */
.ai-widget {
  --ai-gap: 6px;
  --ai-send-w: 86px; /* подгони если хочешь (обычно 80–95 норм) */

  position: fixed;
  right: 24px;
  bottom: 90px;
  width: 340px;
  max-height: 520px;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

/* сама карточка */
.ai-chat-card {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 7, 7, 0.97);
  display: flex;
  flex-direction: column;
  max-height: 520px;
  min-height: 380px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6), 0 0 22px rgba(245, 181, 68, 0.18);
  overflow: hidden;
}

.ai-chat-header {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-bot-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 0%, #f5b544 0, #18120a 55%, #050404 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.ai-bot-avatar span {
  color: #fff;
  font-weight: 700;
}

.ai-bot-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.ai-bot-status {
  font-size: 11px;
  color: #9f9f9f;
}

/* Кнопка свернуть/развернуть */
.ai-collapse-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #f5b544;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 999px;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.ai-collapse-btn:hover {
  background: rgba(245, 181, 68, 0.1);
  color: #ffd173;
}

.ai-chat-body {
  flex: 1;
  padding: 8px 12px 10px;
  font-size: 13px;
  color: #dddddd;
  overflow-y: auto;
  scrollbar-width: none;
}

.ai-chat-body::-webkit-scrollbar {
  display: none;
}

.ai-message a {
  color: #ffc800;
  text-decoration: none;
}

.ai-message a:hover {
  color: #ffa500;
  text-shadow: 0 0 6px #ffa500;
}

.ai-message {
  max-width: 90%;
  padding: 7px 9px;
  border-radius: 10px;
  margin-bottom: 6px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-message.ai-user {
  margin-left: auto;
  border-bottom-right-radius: 2px;
  background: rgba(245, 181, 68, 0.12);
  border: 1px solid rgba(245, 181, 68, 0.55);
  color: #fbe6b5;
}

.ai-message.ai-bot {
  margin-right: auto;
  border-bottom-left-radius: 2px;
  background: rgba(18, 18, 18, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-chat-empty {
  font-size: 12px;
  color: #8f8f8f;
  text-align: center;
  margin-top: 16px;
}

.ai-chat-footer {
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* textarea + button */
.ai-input-row {
  display: flex;
  gap: var(--ai-gap);
  align-items: flex-end;
}

.ai-input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(5, 5, 5, 0.95);
  padding: 7px 9px;
  font-size: 13px;
  color: #f5f5f5;
  resize: none;
  min-height: 34px;
  max-height: 96px;
  line-height: 1.35;
  scrollbar-width: none;
  box-sizing: border-box;
}

.ai-input::placeholder {
  color: #808080;
}

.ai-input:focus {
  outline: none;
  border-color: rgba(245, 181, 68, 0.7);
  box-shadow: 0 0 10px rgba(245, 181, 68, 0.25);
}

.ai-send-btn {
  width: var(--ai-send-w);
  padding: 7px 0;
  border-radius: 999px;
  border: 1px solid rgba(245, 181, 68, 0.8);
  background: linear-gradient(135deg, rgba(245, 181, 68, 0.18), rgba(245, 181, 68, 0.05));
  color: #f5b544;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-sizing: border-box;
}

.ai-send-btn span {
  font-size: 14px;
}

.ai-send-btn:hover {
  background: rgba(245, 181, 68, 0.2);
  box-shadow: 0 0 12px rgba(245, 181, 68, 0.3);
}

.ai-send-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* =========================
   COLLAPSED
   ========================= */

.ai-widget.collapsed .ai-chat-body,
.ai-widget.collapsed .ai-chat-footer {
  display: none;
}

.ai-widget.collapsed .ai-chat-card {
  max-height: none;
  min-height: auto;
  padding-bottom: 8px;
}

#ai-widget.collapsed .ai-chat-card {
  height: 58px;
  min-height: 58px;
  max-height: 58px;

  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  overflow: hidden;
}

#ai-widget.collapsed .ai-chat-body,
#ai-widget.collapsed .ai-chat-footer {
  display: none;
}

#ai-widget.collapsed .ai-chat-header {
  border: none;
  padding: 0;
}

/* =========================
   AI Query meter (0..80)
   ВАЖНО: делаем ширину как textarea (без кнопки)
   ========================= */

.ai-query-meta {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;

  /* ширина = ширина textarea (вся ширина футера минус кнопка и gap) */
  width: calc(100% - var(--ai-send-w) - var(--ai-gap));
}

.ai-query-progress {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.ai-query-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: #2ecc71;
  transition: width 0.15s ease, background-color 0.15s ease;
}

.ai-query-counter {
  font-size: 13px;
  color: #aaa;
  text-align: left;
}

/* Light theme */
body.light-theme .ai-query-progress {
  background: #ffffff;
  border: 1px solid #bebebe;
  border-radius: 6px;
  height: 6px;
  overflow: hidden;
}

body.light-theme .ai-query-counter {
  color: #333;
  font-weight: 500;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 900px) {
  .ai-widget {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    max-width: none;
  }
}

/* если вдруг у тебя было это — оставляю (но можно удалить) */
@media (max-width: 853px) and (min-width: 700px) {
  .ai-chat-card {
    width: 45%;
  }
}

/* =========================
  LIGHT THEME — AI WIDGET
========================= */

body.light-theme .ai-chat-card {
  background: #ffffff;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.12);
}

body.light-theme .ai-chat-body {
  color: #222;
}

body.light-theme .ai-message.ai-bot {
  background: #f7f7f7;
  border-color: #e2e2e2;
}

body.light-theme .ai-message.ai-user {
  background: #fff5dd;
  border-color: #f5b544;
  color: #5a420f;
}

body.light-theme .ai-input {
  background: #fafafa;
  border: 1px solid #bebebe;
  color: #111;
}

body.light-theme .ai-input::placeholder {
  color: #9b9b9b;
}

body.light-theme .ai-send-btn {
  background: #fafafa;
  border: 1px solid #bebebe;
  color: #111;
}

body.light-theme .ai-send-btn:hover {
  background-color: #bebebe;
  box-shadow: none;
}

body.light-theme .ai-bot-name {
  color: #000;
}

body.light-theme .ai-bot-status {
  color: #666;
}

body.light-theme .ai-collapse-btn {
  color: #000;
  transform: none;
}

body.light-theme .ai-collapse-btn:hover {
  background: rgba(245, 181, 68, 0.18);
  color: #e39f1c;
}

body.light-theme .ai-widget {
  border: 1px solid #bebebe;
  border-radius: 16px;
}
