/* 513 AI Assistant — Widget Styles v1.1.1 */

:root {
  --aai-red:        #c0392b;
  --aai-red-dark:   #a93226;
  --aai-black:      #1a1a1a;
  --aai-gray:       #6b6b6b;
  --aai-gray-light: #f5f5f5;
  --aai-border:     #e8e8e8;
  --aai-white:      #ffffff;
  --aai-shadow:     0 8px 40px rgba(0,0,0,0.14);
  --aai-radius:     16px;
  --aai-font:       'Georgia', 'Times New Roman', serif;
  --aai-font-ui:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --aai-z:          99999;
  --aai-width:      380px;
  --aai-height:     560px;
}

/* ── Container ── */
.aai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--aai-z);
  font-family: var(--aai-font-ui);
}

/* ── Trigger Button ── */
.aai-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--aai-black);
  color: var(--aai-white);
  border: none;
  border-radius: 50px;
  padding: 14px 20px 14px 16px;
  cursor: pointer;
  font-family: var(--aai-font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}
.aai-trigger:hover {
  background: var(--aai-red);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(192,57,43,0.35);
}
.aai-trigger:active {
  transform: translateY(0);
}
.aai-trigger-icon {
  display: flex;
  align-items: center;
}
.aai-trigger-label {
  font-size: 13px;
  letter-spacing: 0.04em;
}

/* ── Panel ── */
.aai-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: var(--aai-width);
  height: var(--aai-height);
  background: var(--aai-white);
  border-radius: var(--aai-radius);
  box-shadow: var(--aai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--aai-border);
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.aai-panel.aai-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Panel Header ── */
.aai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--aai-border);
  background: var(--aai-white);
  flex-shrink: 0;
}
.aai-panel-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.aai-panel-logo {
  width: 36px;
  height: 36px;
  background: var(--aai-black);
  color: var(--aai-white);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--aai-font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.aai-panel-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.aai-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--aai-black);
  line-height: 1.2;
}
.aai-panel-subtitle {
  font-size: 11px;
  color: var(--aai-gray);
  line-height: 1.2;
}
.aai-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--aai-gray);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.aai-panel-close:hover {
  color: var(--aai-black);
  background: var(--aai-gray-light);
}

/* ── Messages ── */
.aai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.aai-messages::-webkit-scrollbar {
  width: 4px;
}
.aai-messages::-webkit-scrollbar-track {
  background: transparent;
}
.aai-messages::-webkit-scrollbar-thumb {
  background: var(--aai-border);
  border-radius: 4px;
}

/* ── Message Bubbles ── */
.aai-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: aai-fade-in 0.2s ease;
}
@keyframes aai-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.aai-msg--assistant {
  align-self: flex-start;
}
.aai-msg--user {
  align-self: flex-end;
}
.aai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
}
.aai-msg--assistant .aai-msg-bubble {
  background: var(--aai-gray-light);
  color: var(--aai-black);
  border-bottom-left-radius: 4px;
}
.aai-msg--user .aai-msg-bubble {
  background: var(--aai-black);
  color: var(--aai-white);
  border-bottom-right-radius: 4px;
}
.aai-msg-bubble strong {
  font-weight: 600;
}
.aai-msg-bubble em {
  font-style: italic;
}

/* ── Typing Indicator ── */
.aai-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--aai-gray-light);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.aai-typing span {
  width: 6px;
  height: 6px;
  background: var(--aai-gray);
  border-radius: 50%;
  animation: aai-bounce 1.2s infinite;
}
.aai-typing span:nth-child(2) { animation-delay: 0.2s; }
.aai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Limit / Error notices ── */
.aai-notice {
  text-align: center;
  font-size: 12px;
  color: var(--aai-gray);
  padding: 8px 16px;
  background: #fff8f8;
  border-radius: 8px;
  border: 1px solid #fce4e4;
}
.aai-notice--error {
  color: var(--aai-red);
}

/* ── Input Area ── */
.aai-input-area {
  border-top: 1px solid var(--aai-border);
  padding: 12px 14px 10px;
  background: var(--aai-white);
  flex-shrink: 0;
}
.aai-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--aai-gray-light);
  border-radius: 12px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--aai-border);
  transition: border-color 0.15s;
}
.aai-input-wrap:focus-within {
  border-color: var(--aai-black);
}
.aai-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--aai-font-ui);
  font-size: 16px;
  color: var(--aai-black);
  resize: none;
  outline: none;
  min-height: 20px;
  max-height: 100px;
  line-height: 1.5;
}
.aai-input::placeholder {
  color: #aaa;
}
.aai-send-btn {
  background: var(--aai-black);
  color: var(--aai-white);
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.aai-send-btn:hover {
  background: var(--aai-red);
}
.aai-send-btn:active {
  transform: scale(0.95);
}
.aai-send-btn:disabled {
  background: var(--aai-border);
  cursor: not-allowed;
}

/* ── Footer bar ── */
.aai-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 2px;
}
.aai-msg-counter {
  font-size: 11px;
  color: #bbb;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .aai-widget {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  /* Panel devine bottom-sheet full-width, ancorat jos */
  .aai-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    /* 60% din viewport — lasă loc pentru tastatură (~40-45%) */
    height: 60vh;
    height: 60dvh;
    border-radius: 20px 20px 0 0;
    /* slide-in de jos în loc de fade+scale */
    transform: translateY(100%);
    opacity: 1;
  }
  .aai-panel.aai-open {
    transform: translateY(0);
    opacity: 1;
  }

  .aai-trigger-label {
    display: none;
  }
  .aai-trigger {
    border-radius: 50%;
    padding: 14px;
    margin-left: auto;
    width: 52px;
    height: 52px;
    justify-content: center;
  }
}
