/* ==========================================================================
   Saraiva.AI - Componente de IA Conversacional
   Estilo editorial, integrado ao layout da pagina
   Design system: fundo #0D0D0D, texto #F5F5F3, accent #B8FF3D, fonte Inter
   ========================================================================== */

/* Importa Inter do Google Fonts caso nao esteja carregada */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---- Variaveis CSS (sobreescritas pelo JS via theme) ---- */
:root {
  --sc-bg: #0D0D0D;
  --sc-surface: #111111;
  --sc-accent: #B8FF3D;
  --sc-text: #F5F5F3;
  --sc-text-muted: #999999;
  --sc-user-bg: #1A1A1A;
  --sc-border: #222222;
  --sc-radius: 8px;
}

/* ---- Secao principal ---- */
.sc-section {
  width: 100%;
  min-height: 500px;
  background: linear-gradient(180deg, var(--sc-surface) 0%, var(--sc-bg) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px 40px;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--sc-text);
  position: relative;
}

/* ---- Container centralizado ---- */
.sc-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 400px;
}

/* ---- Header da secao ---- */
.sc-header {
  text-align: center;
  margin-bottom: 40px;
}

.sc-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--sc-text);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.sc-header p {
  font-size: 0.875rem;
  color: var(--sc-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ---- Area de mensagens ---- */
.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar customizada */
.sc-messages::-webkit-scrollbar {
  width: 4px;
}

.sc-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sc-messages::-webkit-scrollbar-thumb {
  background: var(--sc-border);
  border-radius: 2px;
}

/* ---- Mensagem base ---- */
.sc-message {
  display: flex;
  gap: 12px;
  opacity: 0;
  transform: translateY(12px);
  animation: sc-fadeSlideUp 0.3s ease forwards;
}

@keyframes sc-fadeSlideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Mensagem da IA ---- */
.sc-message--ai {
  align-self: flex-start;
  max-width: 90%;
}

.sc-message--ai .sc-message__avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(184, 255, 61, 0.1);
  border-radius: 50%;
  margin-top: 2px;
  user-select: none;
}

.sc-message--ai .sc-message__content {
  padding: 0 0 0 14px;
  border-left: 2px solid rgba(184, 255, 61, 0.3);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--sc-text);
}

/* ---- Mensagem do usuario ---- */
.sc-message--user {
  align-self: flex-end;
  max-width: 80%;
  flex-direction: row-reverse;
}

.sc-message--user .sc-message__content {
  background: var(--sc-user-bg);
  padding: 12px 16px;
  border-radius: var(--sc-radius);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--sc-text);
}

/* ---- Typing indicator ---- */
.sc-typing {
  display: flex;
  gap: 12px;
  align-self: flex-start;
  align-items: center;
  opacity: 0;
  animation: sc-fadeSlideUp 0.2s ease forwards;
}

.sc-typing__avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(184, 255, 61, 0.1);
  border-radius: 50%;
  user-select: none;
}

.sc-typing__dots {
  display: flex;
  gap: 5px;
  padding-left: 14px;
}

.sc-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sc-accent);
  opacity: 0.3;
  animation: sc-dotPulse 1.2s ease-in-out infinite;
}

.sc-typing__dot:nth-child(2) {
  animation-delay: 0.2s;
}

.sc-typing__dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes sc-dotPulse {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ---- Area de input ---- */
.sc-input-area {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--sc-border);
  margin-top: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sc-input-area--hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: absolute;
}

.sc-input-wrap {
  flex: 1;
  position: relative;
}

.sc-input {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 16px;
  background: var(--sc-user-bg);
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius);
  color: var(--sc-text);
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sc-input::placeholder {
  color: var(--sc-text-muted);
}

.sc-input:focus {
  border-color: rgba(184, 255, 61, 0.4);
  box-shadow: 0 0 0 3px rgba(184, 255, 61, 0.08);
}

.sc-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sc-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sc-accent);
  border: none;
  border-radius: var(--sc-radius);
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.sc-send-btn:hover {
  opacity: 0.85;
}

.sc-send-btn:active {
  transform: scale(0.95);
}

.sc-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.sc-send-btn svg {
  width: 20px;
  height: 20px;
  color: #0D0D0D;
}

/* ---- Success state ---- */
.sc-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 0 16px;
  opacity: 0;
  animation: sc-fadeSlideUp 0.5s ease 0.2s forwards;
}

.sc-success__icon {
  width: 56px;
  height: 56px;
}

.sc-success__icon circle {
  fill: none;
  stroke: var(--sc-accent);
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: sc-circleStroke 0.6s ease forwards;
}

.sc-success__icon path {
  fill: none;
  stroke: var(--sc-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: sc-checkStroke 0.3s ease 0.5s forwards;
}

@keyframes sc-circleStroke {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes sc-checkStroke {
  to {
    stroke-dashoffset: 0;
  }
}

.sc-success__text {
  font-size: 0.9375rem;
  color: var(--sc-text-muted);
  text-align: center;
  line-height: 1.5;
}

.sc-success__action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--sc-accent);
  border-radius: var(--sc-radius);
  color: var(--sc-accent);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.sc-success__action:hover {
  background: var(--sc-accent);
  color: #0D0D0D;
}

/* ---- Resumo de agendamento ---- */
.sc-schedule-summary {
  background: var(--sc-user-bg);
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius);
  padding: 20px;
  width: 100%;
  max-width: 400px;
}

.sc-schedule-summary__row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.875rem;
}

.sc-schedule-summary__label {
  color: var(--sc-text-muted);
}

.sc-schedule-summary__value {
  color: var(--sc-text);
  font-weight: 500;
}

/* ---- Responsividade ---- */

/* Tablet */
@media (max-width: 768px) {
  .sc-section {
    padding: 40px 20px 32px;
  }

  .sc-container {
    max-width: 100%;
  }

  .sc-header h2 {
    font-size: 1.25rem;
  }

  .sc-message--ai,
  .sc-message--user {
    max-width: 95%;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .sc-section {
    padding: 32px 16px 0;
    min-height: calc(100dvh - 60px);
  }

  .sc-container {
    min-height: auto;
    flex: 1;
  }

  .sc-header {
    margin-bottom: 24px;
  }

  .sc-messages {
    padding-bottom: 16px;
  }

  .sc-input-area {
    position: sticky;
    bottom: 0;
    background: var(--sc-bg);
    padding: 12px 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    margin-top: auto;
    border-top: 1px solid var(--sc-border);
  }

  .sc-message--ai .sc-message__content,
  .sc-message--user .sc-message__content {
    font-size: 0.875rem;
  }
}
