.site-tools__container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1001;

  display: flex;
  align-items: center;
  gap: 10px;
}

#visit-counter {
  padding: 10px 14px;

  background: rgba(17, 24, 39, 0.9);
  color: white;

  border-radius: 999px;
  box-shadow: var(--shadow-md);

  font-size: 13px;
  font-weight: 600;

  user-select: none;
  white-space: nowrap;
  display: none;
}

.site-tools__button {
  display: flex !important;
  align-items: center;
  justify-content: center;

  width: 46px;
  height: 46px;
  padding: 0;

  border: none;
  border-radius: 50%;

  background: var(--color-primary);
  color: #ffffff;

  font-size: 1.2rem;

  cursor: pointer;

  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.site-tools__button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgb(0 0 0 / 18%);
}

.site-tools__button:active {
  transform: translateY(0);
}

/* ========================================
   Feedback Panel
======================================== */

.feedback-panel {
  position: fixed;
  right: 20px;
  bottom: 78px;
  z-index: 1000;

  width: min(390px, calc(100vw - 32px));
  max-height: calc(100vh - 110px);

  box-sizing: border-box;

  padding: 20px;

  overflow-y: auto;

  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);

  box-shadow: var(--shadow-md);
}

.feedback-panel[hidden] {
  display: none;
}

/* Header */

.feedback-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 16px;

  margin-bottom: 18px;
}

.feedback-panel-header > div {
  min-width: 0;
}

.feedback-panel-header strong {
  display: block;

  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;

  color: var(--color-text);
}

.feedback-panel-header p {
  margin: 6px 0 0;

  font-size: 0.85rem;
  line-height: 1.5;

  color: var(--color-text-muted);
}

/* Close button */

.feedback-close {
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;
  padding: 0;

  border: 0;
  border-radius: 50%;

  background: transparent;
  color: var(--color-text-muted);

  font-size: 1rem;
  line-height: 1;

  cursor: pointer;

  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.feedback-close:hover {
  background: var(--color-background);
  color: var(--color-text);
}

/* Form */

#feedback-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#feedback-form label {
  margin-top: 6px;

  font-size: 0.85rem;
  font-weight: 700;

  color: var(--color-text);
}

/* Inputs */

#feedback-form input,
#feedback-form textarea {
  width: 100%;
  box-sizing: border-box;

  padding: 11px 12px;

  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);

  background: var(--color-background);
  color: var(--color-text);

  font: inherit;
  font-size: 0.9rem;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#feedback-form input:focus,
#feedback-form textarea:focus {
  outline: none;

  border-color: var(--color-primary);

  box-shadow: 0 0 0 3px
    color-mix(in srgb, var(--color-primary) 15%, transparent);
}

#feedback-form textarea {
  min-height: 130px;

  line-height: 1.5;

  resize: vertical;
}

/* Status */

.feedback-status {
  min-height: 20px;

  margin-top: 4px;

  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Send button */

#send-feedback {
  align-self: flex-end;

  min-width: 140px;

  margin-top: 6px;

  padding: 11px 18px;

  border: 0;
  border-radius: var(--radius-md);

  background: var(--color-primary);
  color: #ffffff;

  font-size: 0.9rem;
  font-weight: 700;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

#send-feedback:hover:not(:disabled) {
  transform: translateY(-1px);
}

#send-feedback:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* =========================================================
   AI Chat Panel
========================================================= */

.ai-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 78px;
  z-index: 1000;

  display: flex;
  flex-direction: column;

  width: min(390px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 110px));

  box-sizing: border-box;

  overflow: hidden;

  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);

  box-shadow: var(--shadow-md);
}

.ai-chat-panel[hidden] {
  display: none;
}

/* =========================================================
   AI Chat Header
========================================================= */

.ai-chat-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 16px;

  padding: 18px 20px;

  border-bottom: 1px solid var(--color-border);
}

.ai-chat-panel__header strong {
  display: block;

  color: var(--color-text);
  font-size: 1rem;
  font-weight: 700;
}

.ai-chat-panel__header p {
  margin: 4px 0 0;

  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.ai-chat-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 auto;

  width: 32px;
  height: 32px;

  padding: 0;

  border: 0;
  border-radius: 8px;

  background: transparent;
  color: var(--color-text-muted);

  font-size: 1rem;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.ai-chat-panel__close:hover {
  background: var(--color-background);
  color: var(--color-text);
}

/* =========================================================
   Messages
========================================================= */

.ai-chat-panel__messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;

  min-height: 0;

  padding: 18px;

  overflow-y: auto;
}

/* =========================================================
   Chat Form
========================================================= */

.ai-chat-panel__form {
  display: flex;
  align-items: center;

  gap: 8px;

  padding: 12px;

  border-top: 1px solid var(--color-border);
}

.ai-chat-panel__form input {
  min-width: 0;
  flex: 1;

  height: 42px;

  box-sizing: border-box;

  padding: 0 13px;

  border: 1px solid var(--color-border);
  border-radius: 10px;

  background: var(--color-background);
  color: var(--color-text);

  font: inherit;
  font-size: 0.9rem;

  outline: none;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.ai-chat-panel__form input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 10%);
}

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

.ai-chat-panel__form button {
  display: flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 auto;

  width: 42px;
  height: 42px;

  padding: 0;

  border: 0;
  border-radius: 10px;

  background: var(--color-primary);
  color: #ffffff;

  font-size: 1.1rem;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.ai-chat-panel__form button:hover {
  transform: translateY(-1px);
}

/* =========================================================
   AI Chat Messages
========================================================= */

.ai-chat-message {
  display: flex;
  width: 100%;
}

.ai-chat-message--user {
  justify-content: flex-end;
}

.ai-chat-message--assistant {
  justify-content: flex-start;
}

.ai-chat-message__bubble {
  max-width: 82%;

  padding: 10px 13px;

  border-radius: 14px;

  font-size: 0.9rem;
  line-height: 1.5;

  overflow-wrap: anywhere;
}

.ai-chat-message--user .ai-chat-message__bubble {
  background: var(--color-primary);
  color: #ffffff;

  border-bottom-right-radius: 4px;
}

.ai-chat-message--assistant .ai-chat-message__bubble {
  background: var(--color-background);
  color: var(--color-text);

  border: 1px solid var(--color-border);

  border-bottom-left-radius: 4px;
}

.ai-chat-message__loading {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
}

.ai-chat-message__loading span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: ai-chat-loading 1.4s infinite ease-in-out;
}

.ai-chat-message__loading span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-chat-message__loading span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ai-chat-loading {
  0%,
  60%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ========================================
   Mobile
======================================== */

@media (max-width: 600px) {
  .site-tools__container {
    right: 16px;
    bottom: 16px;
  }

  .site-tools__button {
    width: 44px;
    height: 44px;
  }

  .ai-chat-panel {
    left: 16px;
    right: 16px;
    bottom: 72px;

    width: auto;
    height: min(560px, calc(100vh - 90px));

    box-sizing: border-box;
  }

  .ai-chat-panel__header {
    padding: 16px;
  }

  .ai-chat-panel__messages {
    padding: 14px;
  }

  .ai-chat-panel__form {
    padding: 10px;
  }

  .feedback-panel {
    left: 16px;
    right: 16px;
    bottom: 72px;
    width: auto;
    max-height: calc(100vh - 90px);
    box-sizing: border-box;
  }
}
