/*
 * FormBuilder Platform — Design System & Theme
 * Diretório: /home1/maislive/form.mais.live/assets/css/theme.css
 * Gerado em: 11/06/2026 09:48 (Brasília, UTC-3)
 */

/* ============================================================
   1. VARIÁVEIS — altere aqui para mudar o tema global
   ============================================================ */
:root {
  /* Cores de fundo (dark theme) */
  --bg:       #0c0d10;   /* fundo principal */
  --bg2:      #13151a;   /* cards, sidebar, modais */
  --bg3:      #1a1d24;   /* inputs, hover, painéis */

  /* Bordas */
  --border:   #252830;   /* borda padrão */
  --border2:  #2e323d;   /* borda hover/focus */

  /* Texto */
  --text:     #e8eaf0;   /* texto principal */
  --text2:    #9399a8;   /* texto secundário (labels, meta) */
  --text3:    #5a6070;   /* texto terciário (placeholders, datas) */

  /* Cores de destaque */
  --accent:   #4f7bff;   /* azul principal (botões, links, active) */
  --accent2:  #7c9fff;   /* azul claro (gradientes, logo) */
  --green:    #2dd98f;   /* sucesso / publicado */
  --red:      #ff5a72;   /* erro / excluir / arquivado */
  --yellow:   #ffd166;   /* aviso / pausado / estrelas */

  /* Tipografia */
  --font:     'DM Sans', sans-serif;    /* corpo do texto */
  --font2:    'Syne', sans-serif;       /* títulos, logo, valores */

  /* Geometria */
  --radius:   12px;   /* raio de cards e modais */
  --radius2:  8px;    /* raio de botões e inputs */
  --sidebar:  240px;  /* largura da sidebar */
  --shadow:   0 4px 24px rgba(0, 0, 0, .4);

  /* Animações */
  --trans:    .18s ease;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  background: var(--bg); /* garante que cantos e margens acompanham o tema */
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .3s ease, color .3s ease;
}
input, textarea, select, button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ============================================================
   3. LAYOUT GERAL
   ============================================================ */
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width .22s ease, transform .22s ease;
  overflow: hidden;
}
/* Sidebar colapsada no desktop */
.sidebar.collapsed {
  width: 56px;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-nav {
  overflow: hidden;
  /* Tooltips saem por cima via z-index, não precisam de overflow:visible no nav */
}
.sidebar.collapsed .sidebar-footer { opacity: 1; pointer-events: auto; }


/* Esconder textos, secções e badges */
.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-badge { display: none; }

/* Logo colapsado */
.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
  flex-direction: column;
}
.sidebar.collapsed .logo-icon { margin: 0; flex-shrink: 0; }
.sidebar.collapsed .sidebar-logo > span { display: none; }
.sidebar.collapsed .sidebar-collapse-btn {
  margin: 4px 0 0 0;
  width: 30px; height: 22px;
}

/* Nav-item centrado no modo ícone */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  position: relative;
}

/* Ícone do nav-item no collapsed */
.sidebar.collapsed .nav-item svg { margin: 0; flex-shrink: 0; opacity: 1; }

/* Tooltip ao hover — usa JS para posicionar via fixed */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: fixed;
  left: 62px;
  background: var(--bg3);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 9999;
  /* top é calculado por JS via --tooltip-y, fallback 50% não funciona em fixed */
  top: var(--tooltip-y, 50%);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* Footer colapsado */
.sidebar.collapsed .sidebar-footer { padding: 10px 0; align-items: center; }
.sidebar.collapsed .user-card { justify-content: center; padding: 6px 0; }
.sidebar.collapsed .user-card svg { display: none; }
.sidebar-logo {
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
/* Botão de colapso dentro do logo */
.sidebar-collapse-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--bg3); color: var(--text); }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { color: #fff; }
.logo-text {
  font-family: var(--font2);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.3px;
}
.logo-form    { color: var(--text); }
.logo-builder { color: var(--accent); font-weight: 800; }

/* Nav */
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius2);
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--trans);
  position: relative;
  user-select: none;
}
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active {
  color: var(--text);
  background: rgba(79, 123, 255, .12);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}

/* Sidebar footer / user card */
.sidebar-footer { padding: 16px 10px; border-top: 1px solid var(--border); }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius2);
  cursor: pointer;
  transition: background var(--trans);
  color: var(--text);
}
.user-card:hover { background: var(--bg3); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.user-role { font-size: 11px; color: var(--text2); }

/* Main area */
.main { flex: 1; min-width: 0; overflow-x: hidden; margin-left: var(--sidebar); display: flex; flex-direction: column; transition: margin-left .22s ease, background .3s ease; background: var(--bg); }
.sidebar-collapsed-layout .main { margin-left: 56px; }
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 50;
  background: var(--bg3);
  backdrop-filter: blur(12px);
  color: var(--text);
}
.topbar-title { font-family: var(--font2); font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { flex: 1; padding: 28px; max-width: 1200px; width: 100%; color: var(--text); box-sizing: border-box; overflow-x: hidden; }

/* Pages */
.page { display: none; width: 100%; box-sizing: border-box; }
.page.active { display: block; animation: fadeUp .25s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   4. COMPONENTES
   ============================================================ */

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--trans);
  white-space: nowrap;
  user-select: none;
}
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover {
  background: #3d6ae8;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 123, 255, .35);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #e04060; }
.btn-success { background: var(--green); color: #0c0d10; }
.btn-success:hover { background: #25c47e; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.btn-icon { padding: 8px; aspect-ratio: 1; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; color: var(--text); }
.card-sm { padding: 14px 16px; }
.card:hover { border-color: var(--border2); transition: border-color var(--trans); }

/* Badges de status */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 99px; }
.badge-draft     { background: rgba(90, 96, 112, .2);  color: var(--text3); }
.badge-published { background: rgba(45, 217, 143, .15); color: var(--green); }
.badge-archived  { background: rgba(255, 90, 114, .12); color: var(--red); }
.badge-paused    { background: rgba(255, 209, 102, .12); color: var(--yellow); }

/* Inputs */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border var(--trans);
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text3); }
.input-label { font-size: 12.5px; color: var(--text2); margin-bottom: 6px; display: block; font-weight: 500; }
.input-group { margin-bottom: 16px; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239399a8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* Modais */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .65);
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
.modal-overlay.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 520px;
  animation: slideUp .2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-lg { max-width: 820px; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-title { font-family: var(--font2); font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   5. DASHBOARD — STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--trans);
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.stat-card::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; }
.stat-card.accent::after { background: var(--accent); }
.stat-card.green::after  { background: var(--green); }
.stat-card.yellow::after { background: var(--yellow); }
.stat-card.red::after    { background: var(--red); }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon.accent { background: rgba(79, 123, 255, .15); color: var(--accent); }
.stat-icon.green  { background: rgba(45, 217, 143, .12); color: var(--green); }
.stat-icon.yellow { background: rgba(255, 209, 102, .12); color: var(--yellow); }
.stat-icon.red    { background: rgba(255, 90, 114, .12);  color: var(--red); }
.stat-value { font-family: var(--font2); font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text2); margin-top: 4px; }

/* ============================================================
   6. LISTA DE FORMULÁRIOS
   ============================================================ */
.forms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.form-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--trans);
  position: relative;
  overflow: hidden;
}
.form-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(79, 123, 255, .12);
}
.form-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.form-card-title { font-family: var(--font2); font-size: 15px; font-weight: 600; line-height: 1.3; }
.form-card-desc {
  font-size: 13px; color: var(--text2); margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.form-card-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text3); }
.form-card-meta span { display: flex; align-items: center; gap: 4px; }
.form-card-actions { display: flex; gap: 6px; opacity: 0; transition: opacity var(--trans); }
.form-card:hover .form-card-actions { opacity: 1; }
.form-card-actions .btn { padding: 5px 10px; font-size: 11.5px; }
.form-date { font-size: 11.5px; color: var(--text3); margin-top: 10px; }

/* ============================================================
   7. EDITOR DE FORMULÁRIO (BUILDER)
   ============================================================ */

/* O builder ocupa toda a área abaixo da topbar, sem depender do .content */
#page-builder {
  position: fixed !important;
  top: 56px !important;
  left: var(--sidebar);
  right: 0 !important;
  bottom: 0 !important;
  height: calc(100vh - 56px) !important;
  max-height: calc(100vh - 56px) !important;
  width: auto !important;  /* anula o width:100% de .page para left+right funcionar */
  margin: 0 !important;
  z-index: 40;  /* abaixo da topbar (z-index:50) */
  display: none;
  animation: none !important;  /* sem animação: transform quebraria o position:fixed (top viraria 0) */
  transform: none !important;
  transition: left .22s ease;
}
#page-builder.active {
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  animation: none !important;  /* idem: animação com transform reposiciona o fixed */
  transform: none !important;
}
.sidebar-collapsed-layout #page-builder { left: 56px; }
/* O builder vive no <body> durante a edição, então recebe a classe diretamente */
#page-builder.builder-sidebar-collapsed { left: 56px !important; }

.builder-layout {
  display: flex;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overflow: hidden;
}
.builder-panel {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  width: 260px;
  min-width: 260px;
  min-height: 0;
  flex-shrink: 0;
  transition: width .22s ease, min-width .22s ease;
  color: var(--text);
}
.builder-panel:last-child {
  border-right: none;
  border-left: 1px solid var(--border);
  width: 300px;
  min-width: 300px;
}
.builder-canvas {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow-y: auto;
  padding: 28px;
  color: var(--text);
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font2);
  font-size: 12px; font-weight: 600;
  color: var(--text2);
  letter-spacing: .5px;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

/* Botão de colapso dos painéis */
.panel-collapse-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  width: 24px; height: 24px;
  border-radius: 5px;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--trans);
}
.panel-collapse-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* panel collapse now handled by JS inline styles */

/* Lista de tipos de campo */
.field-types { padding: 10px; overflow-y: auto; flex: 1; }
.field-type-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius2);
  cursor: grab;
  transition: all var(--trans);
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
}
.field-type-item:hover { background: var(--bg3); color: var(--text); border-color: var(--border); }
.field-type-item:active { cursor: grabbing; }
.field-type-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}

/* Canvas central — formulário de pré-visualização */
.canvas-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
}
.canvas-form-header {
  padding: 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(79, 123, 255, .08), transparent);
}

/* Título e descrição editáveis */
.canvas-form-title {
  font-family: var(--font2);
  font-size: 22px; font-weight: 700;
  margin-bottom: 8px;
  outline: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text);
  width: 100%;
  display: block;
  cursor: text;
}
.canvas-form-title:hover { border-bottom-color: var(--border2); }
.canvas-form-title:focus { border-bottom-color: var(--accent); outline: none; }

.canvas-form-desc {
  font-size: 14px;
  outline: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text2);
  width: 100%;
  display: block;
  resize: none;
  cursor: text;
  line-height: 1.5;
}
.canvas-form-desc:hover { border-bottom-color: var(--border2); }
.canvas-form-desc:focus { border-bottom-color: var(--accent); outline: none; }

/* Campos no canvas */
.canvas-fields { padding: 20px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.canvas-field {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--trans);
  position: relative;
  background: var(--bg3);
}
.canvas-field:hover,
.canvas-field.selected { border-color: var(--accent); background: rgba(79, 123, 255, .05); }
.canvas-field-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.canvas-field-drag { color: var(--text3); cursor: grab; font-size: 16px; }
.canvas-field-label { font-size: 13px; font-weight: 500; flex: 1; color: var(--text); }
.canvas-field-type-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
  background: var(--bg2); border: 1px solid var(--border);
  font-size: 11px; font-weight: 700; color: var(--text2);
  font-family: var(--font2); line-height: 1;
}
.canvas-field-required { width: 6px; height: 6px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.canvas-field-actions { display: flex; gap: 4px; position: absolute; right: 10px; top: 8px; opacity: 0; transition: opacity var(--trans); }
.canvas-field:hover .canvas-field-actions { opacity: 1; }
/* Preview dos campos — inputs editáveis diretamente */
.canvas-field-preview { pointer-events: none; user-select: none; opacity: .85; }
.canvas-field-preview .canvas-preview-input {
  pointer-events: all !important;
  cursor: text;
  opacity: 1;
  background: transparent !important;
  border-color: var(--border) !important;
  color: var(--text2);
}
.canvas-field-preview .canvas-preview-input:hover {
  border-color: var(--border2) !important;
}
.canvas-field-preview .canvas-preview-input:focus {
  border-color: var(--accent) !important;
  background: rgba(79,123,255,.03) !important;
  outline: none;
}
.canvas-empty { text-align: center; padding: 40px 20px; color: var(--text3); font-size: 13.5px; }
.canvas-empty svg { margin-bottom: 10px; opacity: .35; display: block; margin-inline: auto; }

/* Painel de propriedades */
.props-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.props-title { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; }
.toggle-label { font-size: 13px; color: var(--text2); }
.toggle { width: 36px; height: 20px; background: var(--border2); border-radius: 99px; position: relative; cursor: pointer; transition: background var(--trans); flex-shrink: 0; }
.toggle.on { background: var(--accent); }
.toggle-dot { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: transform var(--trans); }
.toggle.on .toggle-dot { transform: translateX(16px); }

/* Drag states */
.drag-over { border: 2px dashed var(--accent) !important; background: rgba(79, 123, 255, .06) !important; }
.dragging  { opacity: .35; transform: scale(.98); }
.canvas-field.drag-over-field {
  border-color: var(--accent) !important;
  border-style: dashed !important;
  background: rgba(79, 123, 255, .08) !important;
  transform: scale(1.01);
}
/* Handle de arrasto mais visível */
.canvas-field-drag {
  font-size: 18px;
  line-height: 1;
  cursor: grab !important;
  color: var(--text3);
  padding: 0 4px;
  user-select: none;
}
.canvas-field-drag:active { cursor: grabbing !important; }
.canvas-field:hover .canvas-field-drag { color: var(--text2); }

/* ============================================================
   8. TABELAS
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11.5px; font-weight: 600;
  color: var(--text3);
  text-transform: uppercase; letter-spacing: .8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
td { padding: 16px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, .02); }
/* Linhas da tabela de respostas — mais altura */
#submissions-table tbody tr td { padding: 18px 16px; }
#submissions-table tbody tr:hover td { background: var(--bg3); }
/* Scrollbar da tabela de respostas — mais grossa e com mãozinha */
#submissions-table .table-wrap::-webkit-scrollbar { height: 10px; }
#submissions-table .table-wrap::-webkit-scrollbar-track { background: var(--bg2); border-radius: 99px; }
#submissions-table .table-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; border: 2px solid var(--bg2); }
#submissions-table .table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text3); }
#submissions-table .table-wrap { scrollbar-width: thick; scrollbar-color: var(--border2) var(--bg2); }
/* Cursor mãozinha quando mouse está na área da scrollbar (parte inferior do elemento) */
#submissions-table .table-wrap.on-scrollbar { cursor: pointer !important; }
.td-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

/* ============================================================
   9. ESTADOS VAZIOS
   ============================================================ */
.empty-state { text-align: center; padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  margin-bottom: 4px;
}
.empty-title { font-family: var(--font2); font-size: 17px; font-weight: 600; }
.empty-desc { font-size: 14px; color: var(--text2); max-width: 320px; }

/* ============================================================
   10. LOGIN
   ============================================================ */

/* Estado inicial: login visível, app oculto.
   O JS alterna entre os dois após verificar sessão. */
#login-page {
  position: fixed; inset: 0;
  background: var(--bg);
  align-items: center; justify-content: center;
  z-index: 9999;
  /* display é controlado pelo JS (flex | none) */
}
#app {
  /* display é controlado pelo JS (flex | none) */
}
.login-box { width: 100%; max-width: 400px; padding: 16px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { width: 50px; height: 50px; border-radius: 14px; margin: 0 auto 14px; font-size: 22px; }
.login-logo h1 { font-family: var(--font2); font-size: 24px; font-weight: 700; }
.login-logo p { font-size: 14px; color: var(--text2); margin-top: 4px; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.login-tabs { display: flex; gap: 2px; background: var(--bg3); border-radius: 8px; padding: 3px; margin-bottom: 24px; }
.login-tab { flex: 1; text-align: center; padding: 7px; border-radius: 6px; font-size: 13.5px; cursor: pointer; transition: all var(--trans); color: var(--text2); }
.login-tab.active { background: var(--bg2); color: var(--text); font-weight: 500; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.login-error { background: rgba(255, 90, 114, .1); border: 1px solid rgba(255, 90, 114, .25); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--red); margin-bottom: 16px; display: none; }
.login-error.show { display: block; }

/* ============================================================
   11. SEARCH, DROPDOWN, TOAST
   ============================================================ */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text3); }
.search-input { padding-left: 34px; }

.toast-container { position: fixed; bottom: 28px; right: 28px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--toast-color, var(--green));
  border-radius: 10px;
  padding: 14px 14px 14px 14px;
  font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25), 0 2px 8px rgba(0,0,0,.15);
  position: relative; overflow: hidden;
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1) both;
  background: linear-gradient(135deg, var(--toast-bg, rgba(45,217,143,.08)), var(--bg2) 60%);
}
.toast.toast-out { animation: toastOut .28s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); max-height: 100px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(24px) scale(.92); max-height: 0; margin-bottom: -10px; }
}
.toast-icon {
  color: var(--toast-color, var(--green));
  display: flex; align-items: center; flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--toast-bg, rgba(45,217,143,.15));
  justify-content: center;
}
.toast-msg { flex: 1; color: var(--text); font-weight: 500; line-height: 1.4; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 3px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.toast-close:hover { background: var(--bg3); color: var(--text); }
/* Barra de progresso */
.toast-progress {
  position: absolute; bottom: 0; left: 0;
  height: 3px; width: 100%;
  background: var(--toast-color, var(--green));
  opacity: .5;
  transform-origin: left;
  animation: toastProgress linear forwards;
}
@keyframes toastProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  min-width: 170px;
  z-index: 200;
  animation: fadeIn .12s ease;
  box-shadow: var(--shadow);
}
.dropdown-item { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 7px; font-size: 13px; cursor: pointer; transition: background var(--trans); color: var(--text2); }
.dropdown-item:hover { background: var(--bg3); color: var(--text); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: rgba(255, 90, 114, .1); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ============================================================
   12. RESPONSIVO
   ============================================================ */
.hamburger { display: none; }

/* Overlay escuro do sidebar (mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility .22s ease;
}
.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); z-index: 100; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger {
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text); cursor: pointer; padding: 4px;
  }
  .builder-layout { grid-template-columns: 1fr; height: auto; }
  .builder-panel, .builder-panel:last-child { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .input-row { grid-template-columns: 1fr; }
  /* Sidebar sempre expandido quando aberto no mobile (anular modo colapsado) */
  .sidebar.collapsed { width: 240px; }
  .sidebar.collapsed .sidebar-logo span,
  .sidebar.collapsed .nav-item span,
  .sidebar.collapsed .nav-section,
  .sidebar.collapsed .user-info { display: block; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 14px; }
}

/* Telas médias: leve redução do padding do canvas */
@media (min-width: 901px) and (max-width: 1100px) {
  .builder-panel { width: 220px; min-width: 220px; }
  .builder-panel:last-child { width: 260px; min-width: 260px; }
  .builder-canvas { padding: 16px; }
}

/* ── iPhone 8 Plus e telemóveis (≤520px) ── */
@media (max-width: 520px) {
  .content { padding: 16px 14px; }
  .forms-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-title { font-size: 15px; }

  /* Stat cards mais compactos */
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }
  .stat-icon { width: 36px; height: 36px; }

  /* Dashboard: empilhar as duas colunas */
  #page-dashboard > div[style*="grid-template-columns:1fr 1fr"],
  #page-dashboard > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Tabelas admin: scroll horizontal suave */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
  .table-wrap table { min-width: 640px; }
  th, td { padding: 10px 12px; font-size: 13px; }

  /* Toolbar de filtros: empilhar */
  #page-forms > div:first-child,
  #page-admin-users > div:first-child,
  #page-admin-forms > div:first-child,
  #page-submissions > div:first-child {
    flex-direction: column;
    align-items: stretch !important;
  }
  .search-wrap { width: 100% !important; min-width: 0 !important; }
  /* Select de formulário em Respostas: largura total no mobile */
  #subs-form-select { max-width: 100% !important; width: 100% !important; }
  .topbar-right .btn span,
  .topbar-actions .btn { font-size: 13px; }

  /* Modais ocupam quase toda a tela */
  .modal {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: 90vh;
    margin: 12px;
    border-radius: 14px;
  }
  .modal-body { max-height: 70vh; overflow-y: auto; }

  /* Cards de resposta empilhados */
  .subs-cards-grid { grid-template-columns: 1fr !important; }

  /* Lista de formulários: empilhar meta */
  .form-list-item { flex-wrap: wrap; gap: 8px; }
  .form-list-meta { width: 100%; justify-content: flex-start; }
  .form-list-status { width: auto; }
  .form-list-actions { opacity: 1; } /* sempre visível no touch */

  /* Botões com área de toque maior */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 32px; }

  /* Builder: aviso de melhor uso no desktop */
  .builder-layout { padding: 12px; }

  /* Configurações: presets de tema empilham */
  .theme-presets { flex-wrap: wrap; }
}

/* ── Telemóveis muito estreitos (≤380px, iPhone SE/8) ── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 14px 12px; }
  .topbar-title { font-size: 14px; }
}

/* ── BUILDER PANEL COLLAPSE ── */
.builder-panel.collapsed { overflow: hidden; border: none; min-width: 0; }
.panel-collapse-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--trans);
}
.panel-collapse-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* panel collapse now handled by JS inline styles */


/* ── Builder active mode ── */
/* Quando o builder está ativo, o #page-builder ocupa tudo abaixo da topbar */
#app.builder-active #page-builder {
  display: flex !important;
  flex-direction: column;
}
/* A topbar ainda aparece normalmente no builder */
#app.builder-active .topbar { position: sticky; top: 0; z-index: 50; background: var(--bg3); backdrop-filter: none; }

/* ── CONFIGURAÇÕES ── */
.theme-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 18px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--trans);
  min-width: 100px;
}
.theme-preset-btn:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.theme-preset-btn.active { border-color: var(--accent); background: rgba(79,123,255,.1); color: var(--text); }

.color-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.color-row label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}
.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.color-input-wrap input[type="color"] {
  width: 32px; height: 32px;
  border: 2px solid var(--border2);
  background: none;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
  /* Garantir que o input fica clicável acima de qualquer overlay */
  position: relative;
  z-index: 1;
  pointer-events: all;
  -webkit-appearance: none;
  appearance: none;
}
.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 4px; }
.color-input-wrap input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.color-input-wrap span {
  font-size: 12px;
  color: var(--text2);
  font-family: monospace;
  flex: 1;
}

/* ── Perfil de cores (botão com swatch + nome + actions) ── */
.profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--trans);
  position: relative;
}
.profile-btn:hover { border-color: var(--accent); color: var(--text); }
.profile-btn.active { border-color: var(--accent); background: rgba(79,123,255,.1); color: var(--text); }
.profile-btn .profile-swatches { display: flex; gap: 3px; }
.profile-btn .profile-swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.profile-btn .profile-delete {
  margin-left: 4px;
  width: 18px; height: 18px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: all .15s;
}
.profile-btn:hover .profile-delete { opacity: 1; }
.profile-btn .profile-delete:hover { background: rgba(255,90,114,.15); color: var(--red); }

/* ── Respostas — botão de ação ───────────────────────── */
.subs-action-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 7px; cursor: pointer; color: var(--text3); font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.subs-action-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Alternância de view ─────────────────────────────── */
.subs-view-btn { color: var(--text2); }
.subs-view-btn:hover { background: var(--bg3) !important; color: var(--text) !important; }
.subs-view-btn.active {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600;
}

/* ── Cards de respostas ──────────────────────────────── */
.subs-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
.subs-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; transition: box-shadow .2s;
}
.subs-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.subs-card-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: var(--bg3);
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.subs-card-num {
  background: var(--accent); color: #fff; border-radius: 20px;
  padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.subs-card-date { color: var(--text3); font-size: 11px; }
.subs-card-body { padding: 0; }
.subs-card-row {
  display: flex; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.subs-card-row:last-child { border-bottom: none; }
.subs-card-label {
  flex-shrink: 0; width: 40%; max-width: 180px;
  color: var(--text3); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
  padding-top: 1px; line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.subs-card-value { color: var(--text); line-height: 1.5; word-break: break-word; }
.subs-card-meta .subs-card-label, .subs-card-meta .subs-card-value { color: var(--text3); }

/* ── Campo de senha com olho ─────────────────────────── */
.pwd-wrap { position: relative; }
.pwd-wrap .input { padding-right: 42px; width: 100%; box-sizing: border-box; }
.pwd-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 4px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s;
}
.pwd-eye:hover { color: var(--text); }

/* ── Formulários — vista lista ───────────────────────── */
.forms-list { display: flex; flex-direction: column; gap: 8px; }
.form-list-item {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius2); padding: 14px 16px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.form-list-item:hover { border-color: var(--accent); background: var(--bg3); }
.form-list-status { flex-shrink: 0; width: 90px; }
.form-list-info { flex: 1; min-width: 0; }
.form-list-title { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-list-desc { font-size: 12px; color: var(--text3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-list-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; font-size: 12px; color: var(--text3); }
.form-list-meta span { display: flex; align-items: center; gap: 4px; }
.form-list-date { font-size: 11px; }
.form-list-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.form-list-item:hover .form-list-actions { opacity: 1; }

/* ============================================================
   FIX LAYOUT — garante conteúdo alinhado ao topo (robustez extra)
   ============================================================ */
.page.active {
  align-self: flex-start;
  margin-top: 0;
}
#main-content, .content {
  align-self: flex-start;
}

/* Logo do sidebar clicável (toggle) */
.sidebar-logo .logo-icon { transition: transform .15s, filter .15s; }
.sidebar-logo .logo-icon:hover { transform: scale(1.08); filter: brightness(1.1); }
.sidebar-logo .logo-icon:active { transform: scale(0.95); }

/* iOS: evitar zoom automático ao focar inputs (precisa font-size >= 16px) */
@media (max-width: 520px) {
  .input, input, textarea, select { font-size: 16px !important; }
  /* Manter alguns textos pequenos legíveis sem afetar inputs */
  .input-label { font-size: 13px; }
}