/* MENTOR IA — Componentes base
   Carregar DEPOIS de tokens.css. Mobile-first. */

/* ============== TIPOGRAFIA ============== */
.h1 { font-size: var(--text-3xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); letter-spacing: -0.02em; margin: 0; }
.h2 { font-size: var(--text-2xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); letter-spacing: -0.01em; margin: 0; }
.h3 { font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: var(--leading-snug); margin: 0; }
.h4 { font-size: var(--text-lg); font-weight: var(--weight-semibold); line-height: var(--leading-snug); margin: 0; }
.text-sm  { font-size: var(--text-sm); }
.text-xs  { font-size: var(--text-xs); }
.text-mute { color: var(--color-text-mute); }
.text-soft { color: var(--color-text-soft); }
.text-bold { font-weight: var(--weight-bold); }
.text-medium { font-weight: var(--weight-medium); }
.text-center { text-align: center; }

@media (min-width: 768px) {
  .h1 { font-size: var(--text-4xl); }
  .h2 { font-size: var(--text-3xl); }
  .h3 { font-size: var(--text-2xl); }
}

/* ============== BUTTON ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-brand);
  color: var(--color-brand-on);
  border-color: var(--color-brand);
}
.btn-primary:hover:not(:disabled) { background: var(--color-brand-hover); border-color: var(--color-brand-hover); }

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-bg-soft); }

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--color-bg-mute); }

.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.btn-sm { min-height: 36px; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.btn-lg { min-height: 52px; padding: var(--space-4) var(--space-6); font-size: var(--text-lg); }
.btn-block { width: 100%; }
.btn-icon { min-width: var(--touch-min); padding: var(--space-2); }
.btn-loading { position: relative; pointer-events: none; }
.btn-loading::after {
  content: "";
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: var(--space-2);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============== INPUT / FORM ============== */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-soft);
}
.field-hint { font-size: var(--text-xs); color: var(--color-text-mute); }
.field-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: 2px; }

.input, .textarea, .select {
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-base); /* >=16px evita zoom iOS */
  line-height: var(--leading-normal);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-mute); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}
.input.error, .textarea.error { border-color: var(--color-danger); }
.input.error:focus, .textarea.error:focus { box-shadow: var(--shadow-focus-danger); }

.textarea { min-height: 120px; resize: vertical; line-height: var(--leading-relaxed); }

.select { appearance: none; padding-right: var(--space-10); background-image:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-3) center; background-size: 16px; }

/* ============== CARD ============== */
.card {
  background: var(--color-bg-elev);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out);
}
.card-clickable { cursor: pointer; }
.card-clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin: 0; }
.card-body { /* default */ }
.card-footer { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }

@media (min-width: 768px) {
  .card { padding: var(--space-6); }
}

/* ============== BADGE ============== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--color-bg-mute);
  color: var(--color-text-soft);
}
.badge-brand   { background: var(--color-brand-soft);   color: var(--color-brand-hover); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info    { background: var(--color-info-soft);    color: var(--color-info); }
.badge-xp { background: #fef3c7; color: var(--color-xp); }
.badge-streak { background: var(--color-danger-soft); color: var(--color-streak); }

/* ============== MODAL ============== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: var(--z-overlay);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fadeIn var(--duration-base) var(--ease-out);
}
.modal {
  background: var(--color-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  display: flex; flex-direction: column;
  animation: slideUp var(--duration-slow) var(--ease-out);
  z-index: var(--z-modal);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-title { font-size: var(--text-xl); font-weight: var(--weight-bold); margin: 0; }
.modal-close {
  background: transparent; border: 0;
  width: var(--touch-min); height: var(--touch-min);
  border-radius: var(--radius-pill);
  font-size: 24px; color: var(--color-text-soft);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--color-bg-mute); }
.modal-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex; gap: var(--space-3); justify-content: flex-end;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: var(--space-6); }
  .modal { border-radius: var(--radius-xl); max-height: 80vh; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============== TOAST ============== */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--space-4));
  left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-2);
  width: calc(100% - var(--space-8));
  max-width: 420px;
  pointer-events: none;
}
@media (min-width: 768px) {
  .toast-container { bottom: var(--space-6); right: var(--space-6); left: auto; transform: none; }
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-text);
  color: var(--color-text-invert);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  pointer-events: auto;
  animation: slideUp var(--duration-base) var(--ease-out);
}
.toast-success { background: var(--color-success); }
.toast-danger  { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); color: #1f2937; }
.toast-info    { background: var(--color-info); }

/* ============== EMPTY STATE ============== */
.empty {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  max-width: 420px;
  margin: 0 auto;
}
.empty-icon { font-size: 56px; margin-bottom: var(--space-4); }
.empty-title { font-size: var(--text-xl); font-weight: var(--weight-bold); margin: 0 0 var(--space-2); }
.empty-text { color: var(--color-text-soft); margin: 0 0 var(--space-5); line-height: var(--leading-relaxed); }

/* ============== SKELETON (loading state) ============== */
.skeleton {
  background: linear-gradient(90deg,
    var(--color-bg-mute) 25%,
    var(--color-bg-soft) 50%,
    var(--color-bg-mute) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; width: 100%; }
.skeleton-title { height: 24px; width: 60%; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============== STATS GRID ============== */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); gap: var(--space-4); } }
.stat {
  background: var(--color-bg-elev);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.stat-label { font-size: var(--text-xs); color: var(--color-text-mute); text-transform: uppercase; letter-spacing: 0.05em; font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); line-height: 1; color: var(--color-text); }
.stat-trend { font-size: var(--text-xs); margin-top: var(--space-1); }
.stat-trend-up { color: var(--color-success); }
.stat-trend-down { color: var(--color-danger); }

/* ============== TOOLTIP (CSS only) ============== */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-text-invert);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-fast);
  z-index: var(--z-tooltip);
}
@media (hover: hover) {
  [data-tooltip]:hover::after { opacity: 1; }
}

/* ============== PROGRESS ============== */
.progress { width: 100%; height: 8px; background: var(--color-bg-mute); border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-brand); transition: width var(--duration-slow) var(--ease-out); border-radius: inherit; }
.progress-success .progress-fill { background: var(--color-success); }
.progress-warning .progress-fill { background: var(--color-warning); }
.progress-xp .progress-fill { background: linear-gradient(90deg, var(--color-xp), #fbbf24); }

/* ============== BOTTOM NAV (mobile) ============== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  z-index: var(--z-sticky);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: var(--text-xs);
  color: var(--color-text-mute);
  padding: var(--space-2);
  text-decoration: none;
}
.bottom-nav a.active { color: var(--color-brand); font-weight: var(--weight-semibold); }
.bottom-nav-icon { font-size: 22px; line-height: 1; }
@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}

/* ============== SIDEBAR (desktop) ============== */
.sidebar {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  padding: var(--space-5);
  overflow-y: auto;
  z-index: var(--z-sticky);
}
.sidebar-section { margin-bottom: var(--space-6); }
.sidebar-section-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-mute); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 var(--space-3); margin-bottom: var(--space-2); }
.sidebar a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  margin-bottom: 2px;
}
.sidebar a:hover { background: var(--color-bg-mute); color: var(--color-text); }
.sidebar a.active { background: var(--color-brand-soft); color: var(--color-brand-hover); }
.sidebar-icon { width: 20px; text-align: center; }
@media (min-width: 1024px) {
  .sidebar { display: block; }
  .layout-content { margin-left: var(--sidebar-width); padding-bottom: 0; }
}

/* ============== LAYOUT ============== */
.layout-content {
  padding: var(--space-4);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
  min-height: 100dvh;
}
.container { max-width: var(--container-max); margin: 0 auto; }
.container-narrow { max-width: var(--container-narrow); margin: 0 auto; }

/* ============== UTILITÁRIOS ============== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); } .gap-6 { gap: var(--space-6); }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); } .mb-8 { margin-bottom: var(--space-8); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ============== CHAT BUBBLES (clean modern) ============== */
.bubble { max-width: 80%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); font-size: var(--text-base); line-height: var(--leading-normal); word-wrap: break-word; }
.bubble-user { background: var(--color-brand); color: white; border-bottom-right-radius: var(--radius-sm); margin-left: auto; }
.bubble-bot  { background: var(--color-bg-mute); color: var(--color-text); border-bottom-left-radius: var(--radius-sm); }
.bubble-typing { display: inline-flex; gap: 4px; padding: var(--space-3) var(--space-4); background: var(--color-bg-mute); border-radius: var(--radius-lg); }
.bubble-typing span { width: 8px; height: 8px; background: var(--color-text-mute); border-radius: 50%; animation: typing 1.4s infinite; }
.bubble-typing span:nth-child(2) { animation-delay: 0.2s; }
.bubble-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ============== CELEBRAÇÕES ============== */
.celebrate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: var(--z-toast);
}
.celebrate-card {
  background: var(--color-bg);
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: pop var(--duration-slow) var(--ease-out);
}
.celebrate-icon { font-size: 64px; margin-bottom: var(--space-3); }
.celebrate-title { font-size: var(--text-2xl); font-weight: var(--weight-bold); margin: 0 0 var(--space-2); }
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
