/* ===========================================================
   BASE — PALETA PANGEIA METRICS (CLARO)
   =========================================================== */

:root {
  --bg-body: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-soft: #fafafa;
  --border-subtle: rgba(0, 0, 0, 0.08);

  --accent: #22c2b1;
  --accent-strong: #0ea5e9;

  --danger: #d62828;

  --text-main: #1e293b;
  --text-soft: #475569;
  --text-muted: #94a3b8;

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-body);
  font-family: "Inter", sans-serif;
  color: var(--text-main);
  width: 100%;
  overflow-x: hidden;
}

/* ===========================================================
   FIX PARA RESPONSIVIDADE (CRÍTICO)
   =========================================================== */

pre, code {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  display: block;
  background: #f1f5f9;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.08);
}

/* evita qualquer overflow de textos */
.panel, .card, .page-wrapper, .page-dashboard {
  word-break: break-word;
}



/* ===========================================================
   LAYOUT GLOBAL
   =========================================================== */

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 14px;
}

@media (min-width: 768px) {
  .page-wrapper {
    padding: 32px 24px;
  }
}

.page-footer {
  margin-top: auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 24px;
}

/* ===========================================================
   BRAND
   =========================================================== */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.brand-title strong {
  color: var(--accent);
  font-weight: 700;
}

/* ===========================================================
   BOTÕES
   =========================================================== */

button, .btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  color: white;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.15s ease, transform 0.08s ease;
  margin-top: 14px;
  margin-bottom: 10px;
}

.btn-primary:hover {
  background: #1ab4a3;
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-ghost {
  padding: 7px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: white;
  color: var(--text-soft);
  font-size: 0.88rem;
  transition: border 0.15s ease, color 0.15s ease;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===========================================================
   FORMULÁRIOS
   =========================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group-inline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .form-group-inline {
    flex-direction: row;
  }
  .form-group-inline .form-group {
    flex: 1;
  }
}

label {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-top: 5px;
  font-weight: 700;
}

input, textarea {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: white;
  font-size: 0.9rem;
  color: var(--text-main);
}

input:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
}

/* ===========================================================
   LOGIN / CADASTRO
   =========================================================== */

.page-auth {
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(0,0,0,0.06);
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: #f1f5f9;
  margin: 18px 0 12px;
}

.auth-toggle-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.auth-toggle-btn.active {
  background: var(--accent);
  color: white;
}

.auth-error {
  padding: 8px 12px;
  background: #ffe5e5;
  border: 1px solid #ffbaba;
  color: #b30000;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
}

.auth-error.auth-ok {
  background: #e7f9f0;
  border-color: #bbf7d0;
  color: #166534;
}

.auth-form {
  display: none;
  opacity: 0;
  transition: opacity .25s ease;
}

.auth-form.auth-form-active {
  display: block;
  opacity: 1;
}

.auth-description {
  margin-top: 12px;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.dev-cta {
  margin: 12px 0 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(34, 194, 177, 0.35);
  background: linear-gradient(180deg, #f0fffd 0%, #f8fffe 100%);
}

.dev-cta-title {
  margin: 0 0 4px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f766e;
}

.dev-cta-text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-soft);
}

.dev-cta-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-footer-note {
  margin-top: 12px;
  font-size: 0.84rem;
  color: var(--text-soft);
}

.forgot-form {
  margin-top: 10px;
}

.auth-inline-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-link,
.btn-link-anchor {
  border: none;
  background: transparent;
  padding: 0;
  color: #0f766e;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.btn-link-anchor {
  display: inline-block;
}

.btn-link:hover,
.btn-link-anchor:hover {
  color: #0b5c56;
}

/* ===========================================================
   DASHBOARD
   =========================================================== */

.page-dashboard {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 18px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0,0,0,0.06);
  padding: 20px 18px;
  box-shadow: var(--shadow-card);
}

.panel h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.panel-subtitle {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-top: 4px;
}

/* ===========================================================
   CARDS
   =========================================================== */

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: white;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: var(--shadow-card);
}

.card-title {
  font-weight: 600;
}

.card-body {
  color: var(--text-soft);
  font-size: 0.85rem;
  margin-top: 4px;
}

.empty-state {
  padding: 12px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px dashed rgba(0,0,0,0.1);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===========================================================
   STATUS
   =========================================================== */

.form-status.ok {
  background: #e7f9f0;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.form-status.error {
  background: #ffe5e5;
  border: 1px solid #ffbaba;
  color: #b30000;
}

/* ===========================================================
   ABAS DE LOGIN/CADASTRO
   =========================================================== */

.auth-tabs {
  display: flex;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  margin: 18px 0 18px;
}

.auth-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 0.92rem;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .2s ease, border-color .2s ease;
}

.auth-tab:hover {
  color: var(--accent);
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}


/* ===========================================================
   NOVO LAYOUT — DUAS COLUNAS EM CIMA + APPS EMBAIXO
   =========================================================== */

.top-two-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .top-two-cols {
    grid-template-columns: 1fr 1fr;
  }
}

/* Apps ocupando largura total */
.apps-full {
  grid-column: 1 / -1;
}

/* Cards flexíveis dos apps conectados */
.apps-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
}

/* Cada app vira um cartão responsivo */
.apps-flex .card {
  flex: 1 1 calc(33.33% - 14px);
  min-width: 260px;
  max-width: 100%;
}

/* Ajuste para telas menores */
@media (max-width: 700px) {
  .apps-flex .card {
    flex: 1 1 100%;
  }
}

/* apps ativos (verde claro suave) */
.card.card-active {
  background: #e8f7ec;
  border: 1px solid #c7ebd1;
}

/* apps revogados (preto & branco, apagado) */
.card.card-revoked {
  background: #f2f2f2;
  border: 1px solid #dcdcdc;
  filter: grayscale(1);
  opacity: 0.55;
}

/* AVATAR NO TOPO */
.avatar-wrapper {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ddd;
  cursor: pointer;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatar-fallback {
  width: 100%;
  height: 100%;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  background: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative; /* ESSENCIAL */
}

/* Menu do avatar */
.avatar-menu {
  position: absolute;
  top: 55px;
  right: 0;
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 0;
  width: 160px;
  display: none;
  flex-direction: column;
  z-index: 9999; /* opcional para garantir */
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.avatar-menu .menu-item {
  display: block;
  padding: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: inherit;
  text-decoration: none;
}

.avatar-menu .menu-item:hover {
  background: #f2f2f2;
}
