/* Agro Asystent Widget — frontend styles
   Brand colors injected via CSS custom properties from JS:
   --agrohit-primary, --agrohit-secondary
*/

#agrohit-widget-root {
  --agrohit-primary: #72BF44;
  --agrohit-secondary: #5C6A7A;
  --agrohit-bg: #ffffff;
  --agrohit-text: #2c3338;
  --agrohit-muted: #6c7780;
  --agrohit-border: #e5e7eb;
  --agrohit-radius: 16px;
  --agrohit-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--agrohit-text);
}

#agrohit-widget-root *,
#agrohit-widget-root *::before,
#agrohit-widget-root *::after {
  box-sizing: border-box;
}

/* ===================================================================
   LAUNCHER (floating button)
   =================================================================== */

.agrohit-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: var(--agrohit-primary);
  box-shadow: var(--agrohit-shadow);
  cursor: pointer;
  z-index: 999998;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}

.agrohit-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.25);
}

.agrohit-launcher:active {
  transform: scale(0.96);
}

.agrohit-launcher--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}

.agrohit-launcher__logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  padding: 4px;
  pointer-events: none;
}

.agrohit-launcher__pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--agrohit-primary);
  opacity: 0.7;
  animation: agrohit-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes agrohit-pulse {
  0%   { transform: scale(0.92); opacity: 0.7; }
  70%  { transform: scale(1.25); opacity: 0;   }
  100% { transform: scale(1.25); opacity: 0;   }
}

/* ===================================================================
   PANEL (chat window)
   =================================================================== */

.agrohit-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 40px);
  background: var(--agrohit-bg);
  border-radius: var(--agrohit-radius);
  box-shadow: var(--agrohit-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.agrohit-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.agrohit-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #72BF44 0%, #619e3a 100%); /* fallback for browsers without color-mix() */
  background: linear-gradient(135deg, var(--agrohit-primary) 0%, color-mix(in srgb, var(--agrohit-primary) 80%, var(--agrohit-secondary) 20%) 100%);
  color: #fff;
  flex-shrink: 0;
}

.agrohit-panel__logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
  object-fit: cover;
}

.agrohit-panel__title {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.agrohit-panel__title strong {
  font-size: 15px;
  font-weight: 600;
}

.agrohit-panel__subtitle {
  font-size: 12px;
  opacity: 0.85;
}

.agrohit-panel__close {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.agrohit-panel__close:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ===================================================================
   MESSAGES
   =================================================================== */

.agrohit-panel__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agrohit-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: agrohit-fade-in 0.25s ease;
}

@keyframes agrohit-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.agrohit-msg--assistant {
  align-self: flex-start;
}

.agrohit-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.agrohit-msg__avatar {
  width: 28px;
  height: 28px !important;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--agrohit-primary);
  padding: 2px;
  object-fit: cover;
}

.agrohit-msg__bubble {
  background: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--agrohit-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.agrohit-msg--user .agrohit-msg__bubble {
  background: var(--agrohit-primary);
  color: #fff;
  border-color: var(--agrohit-primary);
}

.agrohit-msg__bubble p {
  margin: 0 0 6px 0;
}

.agrohit-msg__bubble p:last-child {
  margin-bottom: 0;
}

.agrohit-msg__bubble ul {
  margin: 6px 0;
  padding-left: 20px;
}

.agrohit-msg__bubble li {
  margin-bottom: 4px;
}

.agrohit-msg__bubble strong {
  font-weight: 600;
}

.agrohit-msg__bubble a {
  color: var(--agrohit-primary);
  text-decoration: underline;
  font-weight: 500;
}

.agrohit-msg--user .agrohit-msg__bubble a {
  color: #fff;
  text-decoration: underline;
}

/* Typing indicator */
.agrohit-typing {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}

.agrohit-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--agrohit-secondary);
  opacity: 0.5;
  animation: agrohit-typing-bounce 1.2s ease-in-out infinite;
}

.agrohit-typing span:nth-child(2) { animation-delay: 0.15s; }
.agrohit-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* ===================================================================
   FORM
   =================================================================== */

.agrohit-panel__form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--agrohit-border);
  flex-shrink: 0;
}

.agrohit-panel__input {
  flex: 1 1 auto;
  border: 1px solid var(--agrohit-border);
  border-radius: 22px;
  padding: 10px 16px;
  font: inherit;
  outline: none;
  background: #f8f9fa;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.agrohit-panel__input:focus {
  border-color: var(--agrohit-primary);
  background: #fff;
}

.agrohit-panel__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.agrohit-panel__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--agrohit-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.agrohit-panel__send:hover:not(:disabled) {
  background: #5aaa2f; /* fallback for browsers without color-mix() */
  background: color-mix(in srgb, var(--agrohit-primary) 85%, #000 15%);
}

.agrohit-panel__send:active:not(:disabled) {
  transform: scale(0.94);
}

.agrohit-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===================================================================
   FOOTER (AI disclaimer)
   =================================================================== */

.agrohit-panel__footer {
  font-size: 11px;
  color: var(--agrohit-muted);
  padding: 8px 14px;
  background: #fff;
  border-top: 1px solid var(--agrohit-border);
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
}

/* ===================================================================
   MOBILE (full-screen panel)
   =================================================================== */

@media (max-width: 480px) {
  .agrohit-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .agrohit-launcher {
    right: 16px;
    bottom: 16px;
    width: 58px;
    height: 58px;
  }

  .agrohit-launcher__logo {
    width: 40px;
    height: 40px;
  }
}

/* High z-index safety against site themes */
@media (min-width: 481px) {
  .agrohit-panel {
    transform-origin: bottom right;
  }
}
