:root {
  --bg-1: #07111f;
  --bg-2: #0b1b2f;
  --card: rgba(10, 18, 31, 0.84);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e8eefc;
  --muted: #9fb0cb;
  --green: #a6ff4d;
  --green-2: #67e8a3;
  --blue: #67b7ff;
  --violet: #8b7bff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 16px;
  --max: 1120px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(103, 184, 255, 0.16), transparent 30%),
    radial-gradient(circle at right top, rgba(166, 255, 77, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
}

a { color: inherit; text-decoration: none; }

.shell {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  position: sticky;
  top: 16px;
  z-index: 30;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(7, 17, 31, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button-inline {
  padding: 10px 14px;
  min-height: 42px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

.brand-meta {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 2px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand-logo img {
  width: 124%;
  height: 124%;
  object-fit: contain;
  display: block;
  transform: scale(1.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 0.92rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
  margin-bottom: 24px;
}

.hero-panel, .card, .chat-container {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-panel {
  padding: 28px;
}

.flow-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flow-hero-icon {
  width: 112px;
  height: 112px;
  padding: 12px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.flow-hero-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 16px;
}

.hero-kicker {
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero h1 {
  margin: 12px 0 14px;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
  line-height: 1.6;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.card {
  padding: 22px;
  min-height: 210px;
  display: flex;
  flex-direction: column;
}

.card h2 {
  margin: 14px 0 10px;
  font-size: 1.3rem;
}

.card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.card .button {
  margin-top: auto;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon-pill {
  display: inline-flex;
  width: 80px;
  height: 80px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(166, 255, 77, 0.22), rgba(103, 183, 255, 0.18));
  overflow: hidden;
  flex-shrink: 0;
  box-sizing: border-box;
}

.icon-pill img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 12px;
}

.history-icon {
  width: 72px;
  height: 72px;
  padding: 8px;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.history-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 12px;
}

.shell {
  padding-top: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

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

.button.primary {
  color: #08121d;
  background: linear-gradient(135deg, var(--green), var(--green-2));
}

.button.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
}

.button.ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--card-border);
}

.workspace {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
  align-items: start;
}

.flow-panel {
  padding: 24px;
}

.flow-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.flow-title h2 {
  margin: 0;
  font-size: 1.45rem;
}

.flow-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.chat-container {
  padding: 20px;
  min-height: 520px;
}

.flow-chat {
  position: relative;
}

.flow-chat::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), transparent 55%);
}

#botfit-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
  min-height: 100%;
}

.message {
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.5;
  max-width: 85%;
  white-space: pre-wrap;
}

.message.bot {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
}

.message.action {
  background: linear-gradient(135deg, rgba(103, 183, 255, 0.18), rgba(139, 123, 255, 0.18));
  border: 1px solid rgba(103, 183, 255, 0.22);
}

.message.user {
  align-self: flex-end;
  background: rgba(166, 255, 77, 0.12);
  border: 1px solid rgba(166, 255, 77, 0.25);
}

.message.loading {
  opacity: 0.85;
  font-style: italic;
}

.option-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  width: 100%;
  min-height: 48px;
}

.option-button:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.option-button:hover {
  border-color: rgba(166, 255, 77, 0.4);
  background: rgba(166, 255, 77, 0.08);
}

.option-button-secondary {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.training-days {
  display: grid;
  gap: 16px;
  margin: 20px 0;
}

.training-day-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  padding: 0;
}

.training-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  padding: 16px 18px;
  margin: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.training-day-header > div {
  display: grid;
  gap: 4px;
}

.training-day-header::-webkit-details-marker {
  display: none;
}

.training-day-header span {
  color: var(--muted);
  font-size: 0.88rem;
}

.training-exercises-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  padding: 16px 18px 18px;
}

.training-exercises-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 18px;
}

.training-exercise-card {
  display: flex;
  gap: 16px;
  align-items: center;
  width: 100%;
  min-width: 0;
  border-radius: 16px;
  padding: 14px;
  background: rgba(5, 9, 18, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.training-thumb {
  width: 180px;
  max-width: 200px;
  flex: 0 0 180px;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.training-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.training-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 18px;
  min-height: 160px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed rgba(255, 255, 255, 0.14);
}

.training-exercise-content {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.training-exercise-content strong {
  color: var(--text);
}

.training-exercise-content span {
  color: var(--muted);
  font-size: 0.95rem;
}

.training-exercise-content small {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  line-height: 1.4;
}

@media (max-width: 700px) {
  .training-exercise-card {
    flex-direction: column;
    align-items: stretch;
  }

  .training-thumb {
    width: 100%;
    max-width: none;
    flex-basis: auto;
    max-height: 200px;
  }
}

.plan-list {
  display: grid;
  gap: 16px;
}

.history-layout {
  display: grid;
  gap: 22px;
}

.history-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
}

.section-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.history-card {
  overflow: hidden;
  min-height: auto;
}

.history-card-summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 18px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.history-card-summary::-webkit-details-marker {
  display: none;
}

.history-card-summary-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.history-card-summary-main h2 {
  margin: 3px 0 0;
}

.history-card-eyebrow {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-card-summary-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-card-body {
  display: grid;
  gap: 16px;
  padding: 0 18px 18px;
}

.history-plan-days {
  display: grid;
  gap: 12px;
}

.history-plan-text {
  display: none;
}

.history-summary {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.history-blocks {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.history-block {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.history-block span {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.history-block strong {
  color: var(--text);
  font-weight: 600;
}

.history-plan-text pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.65;
}

.history-plan-text {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.history-card-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-form input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 0 14px;
}

.footer {
  margin-top: 24px;
  padding-top: 18px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.empty-state {
  min-height: auto;
}

.history-card {
  min-height: auto;
}

.theme-personal .accent { color: var(--green); }
.theme-nutricionista .accent { color: var(--blue); }
.theme-ambos .accent { color: var(--violet); }

.theme-personal .hero-panel,
.theme-personal .card,
.theme-personal .chat-container {
  box-shadow: 0 18px 60px rgba(103, 255, 77, 0.06), var(--shadow);
}

.theme-nutricionista .hero-panel,
.theme-nutricionista .card,
.theme-nutricionista .chat-container {
  box-shadow: 0 18px 60px rgba(103, 183, 255, 0.06), var(--shadow);
}

.theme-ambos .hero-panel,
.theme-ambos .card,
.theme-ambos .chat-container {
  box-shadow: 0 18px 60px rgba(139, 123, 255, 0.06), var(--shadow);
}

@media (max-width: 920px) {
  .hero, .flow-grid, .workspace { grid-template-columns: 1fr; }
  .header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .message { max-width: 100%; }
  .option-group { grid-template-columns: 1fr; }
  .option-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto;
    transition: none !important;
    animation: none !important;
  }
}


/* Correção cards de exercícios - evitar sobreposição */
.training-exercises-list,
.training-exercises-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 14px;
  width: 100%;
}

.training-exercise-card {
  display: grid !important;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  width: 100%;
  overflow: hidden;
}

.training-exercise-content {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.training-exercise-content strong,
.training-exercise-content span,
.training-exercise-content small {
  display: block;
  max-width: 100%;
}

.training-thumb {
  width: 180px;
  min-width: 180px;
  max-width: 180px;
}

/* Mobile */
@media (max-width: 700px) {
  .training-exercise-card {
    grid-template-columns: 1fr !important;
  }

  .training-thumb {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}
