/* ============================================================
   MARCENEIRO.A.I — Design System v5.0
   Visual moderno, escuro premium com tons de madeira e dourado
   ============================================================ */

/* --- Variáveis globais --- */
:root {
  /* Cores principais */
  --bg: #0f0f13;
  --bg-card: #1a1a24;
  --bg-elevated: #22222e;
  --bg-input: #16161f;
  
  /* Madeira & Dourado */
  --wood-900: #2a1810;
  --wood-800: #3d2518;
  --wood-700: #5c3a24;
  --wood-600: #7a5033;
  --wood-500: #9b6b42;
  --gold-100: #fff8e7;
  --gold-200: #ffe5a0;
  --gold-300: #f3d087;
  --gold-400: #e8b94a;
  --gold-500: #d4a030;
  
  /* Texto */
  --text: #f0ece4;
  --text-secondary: #a8a4a0;
  --text-tertiary: #706c68;
  
  /* Feedback */
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  
  /* Bordas & Sombras */
  --border: rgba(255,255,255,0.06);
  --border-focus: var(--gold-400);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px rgba(232,185,74,0.15);
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.25s;
  
  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-height: 64px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- Tipografia --- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

.section-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-400);
}

.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }

/* --- Utilitários --- */
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }

/* ============================================================
   TELA DE LOGIN / CADASTRO (index.html)
   ============================================================ */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f0f13 0%, #1a1520 50%, #0f0f13 100%);
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-glow);
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-bottom: 28px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}

/* Tabs Login/Cadastro */
.login-toggle {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}
.login-toggle button {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.login-toggle button.active {
  background: var(--gold-400);
  color: var(--wood-900);
  box-shadow: var(--shadow-sm);
}

/* Formulários */
.login-form { display: none; }
.login-form.active { display: block; }

.login-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.92rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color var(--duration) var(--ease);
}
.login-form input:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 3px rgba(232,185,74,0.1);
}
.login-form input::placeholder { color: var(--text-tertiary); }

/* Força da senha */
.pwd-strength-container {
  display: none;
  margin-top: -8px;
  margin-bottom: 10px;
}
.pwd-strength-bars {
  display: flex;
  height: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
  gap: 2px;
}
.pwd-strength-bar {
  flex: 1;
  border-radius: 2px;
  transition: background 0.3s var(--ease);
}
.pwd-strength-text {
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 4px;
  display: block;
  transition: color 0.3s var(--ease);
}

/* Botões */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  color: var(--wood-900);
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.btn-secondary:hover { background: var(--bg-card); border-color: var(--gold-400); }

.btn-outline {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: var(--gold-400);
  font-weight: 600;
  font-size: 0.85rem;
  border: 1px solid var(--gold-400);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.btn-outline:hover { background: rgba(232,185,74,0.1); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--gold-400);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  transition: color var(--duration);
}
.btn-ghost:hover { color: var(--gold-300); }

.btn-block { display: block; width: 100%; }
.btn-sm { padding: 8px 14px !important; font-size: 0.8rem !important; }

.btn-google {
  width: 100%;
  padding: 12px;
  background: #fff;
  color: #333;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--duration) var(--ease);
}
.btn-google:hover { background: #f5f5f5; box-shadow: var(--shadow-sm); }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-tertiary);
  font-size: 0.8rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Feedback */
.feedback {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 8px;
}
.feedback.show { display: block; }
.feedback.success { background: rgba(52,211,153,0.1); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.feedback.error { background: rgba(248,113,113,0.1); color: var(--error); border: 1px solid rgba(248,113,113,0.2); }
.feedback.warning { background: rgba(251,191,36,0.1); color: var(--warning); border: 1px solid rgba(251,191,36,0.2); }

/* ============================================================
   APP PRINCIPAL (app.html)
   ============================================================ */

/* --- Header do App --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15,15,19,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header .logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .logo-area img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.app-header .logo-area span {
  font-size: 1rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-400), var(--wood-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--wood-900);
  cursor: pointer;
}

/* --- Conteúdo com scroll --- */
.app-content {
  padding: 16px;
  padding-bottom: calc(var(--tab-height) + 24px + var(--safe-bottom));
  max-width: 800px;
  margin: 0 auto;
}

/* --- Tab Bar inferior --- */
.tab-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(15,15,19,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  height: var(--tab-height);
  padding-bottom: var(--safe-bottom);
}
.tab-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration) var(--ease);
  padding: 6px 0;
}
.tab-nav button .tab-icon { font-size: 1.25rem; }
.tab-nav button.active { color: var(--gold-400); }
.tab-nav button:hover { color: var(--text-secondary); }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   CARDS & COMPONENTES
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all var(--duration) var(--ease);
}
.card:hover { border-color: rgba(255,255,255,0.1); }

/* --- Grid de catálogo --- */
.catalogo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.catalogo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
}
.catalogo-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-400), var(--wood-500));
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.catalogo-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold-400);
}
.catalogo-card:hover::before { opacity: 1; }

.catalogo-card img, .catalogo-card svg {
  width: 100%;
  height: 90px;
  object-fit: contain;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.catalogo-card p {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.catalogo-card .card-dims {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* --- Detalhe do móvel --- */
#detalhe-movel-container {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.3s var(--ease);
}
#detalhe-movel-container.visible {
  display: flex;
}

.movel-preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

#movel-imagem-wrapper {
  width: 100%;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}
#movel-imagem-wrapper svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Seletor de cores */
#seletor-cores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.cor-btn {
  width: 42px;
  height: 42px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
}
.cor-btn:hover { border-color: var(--gold-400); transform: scale(1.1); }
.cor-btn.selected { border-color: var(--gold-400); box-shadow: 0 0 0 2px var(--gold-400); }
.cor-btn span {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Botões de ação IA */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.action-buttons button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.btn-optimize {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  color: var(--wood-900);
}
.btn-optimize:hover { opacity: 0.9; }
.btn-aesthetic {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border) !important;
}
.btn-aesthetic:hover { border-color: var(--gold-400) !important; }

/* Resultado da IA */
.ia-resultado-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}
.ia-resultado-container h4 {
  font-size: 0.95rem;
  color: var(--gold-400);
  margin-bottom: 8px;
}
.ia-resultado-container h5 {
  font-size: 0.85rem;
  color: var(--gold-300);
  margin-top: 12px;
  margin-bottom: 6px;
}
.ia-resultado-container ul {
  list-style: none;
  padding: 0;
}
.ia-resultado-container li {
  padding: 8px 12px;
  margin-bottom: 4px;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--gold-400);
}
.ia-resultado-container p {
  font-size: 0.88rem;
  margin: 4px 0;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s var(--ease);
}
.modal-overlay.hidden { display: none; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color var(--duration);
}
.modal-close:hover { color: var(--text); }

/* ============================================================
   INPUT / FORM GLOBAL
   ============================================================ */
.input-group { margin-bottom: 12px; }
.input-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input-group input, .input-group select, .input-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--duration) var(--ease);
}
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 3px rgba(232,185,74,0.08);
}

.form-row {
  display: flex;
  gap: 12px;
}

/* ============================================================
   INFO BOXES
   ============================================================ */
.info-box {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.info-box .info-icon { font-size: 1.2rem; flex-shrink: 0; }
.info-box-success { border-color: rgba(52,211,153,0.2); background: rgba(52,211,153,0.06); }
.info-box-warning { border-color: rgba(251,191,36,0.2); background: rgba(251,191,36,0.06); }
.info-box-info { border-color: rgba(96,165,250,0.2); background: rgba(96,165,250,0.06); }

/* ============================================================
   PLANO / CONTA
   ============================================================ */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-gratuito { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.plan-plus { background: rgba(96,165,250,0.15); color: var(--info); }
.plan-profissional { background: rgba(232,185,74,0.15); color: var(--gold-400); }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold-400);
}
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ============================================================
   PWA BANNER
   ============================================================ */
.pwa-banner {
  display: none;
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 12px);
  left: 16px;
  right: 16px;
  z-index: 60;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--gold-400);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: slideUp 0.4s var(--ease);
}
.pwa-banner.show { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (min-width: 768px) {
  .catalogo-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }
  #movel-imagem-wrapper { height: 360px; }
  .login-card { padding: 36px 32px; }
  .app-content { padding: 24px; padding-bottom: calc(var(--tab-height) + 32px + var(--safe-bottom)); }
}

@media (max-width: 480px) {
  .catalogo-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .catalogo-card { padding: 10px 8px; }
  .catalogo-card img, .catalogo-card svg { height: 70px; }
  .form-row { flex-direction: column; gap: 0; }
  .action-buttons { flex-direction: column; }
  #detalhe-movel-container { gap: 12px; }
}

/* ============================================================
   PÁGINAS AUXILIARES (sucesso, falha, pendente, privacidade)
   ============================================================ */
.status-icon { font-size: 4rem; margin-bottom: 16px; }
.status-card { max-width: 380px; text-align: center; }
.policy-card { max-width: 640px; text-align: left; }
.policy-card h3 { font-size: 1rem; color: var(--gold-400); margin-bottom: 6px; }
.policy-section { display: flex; flex-direction: column; gap: 16px; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.7; }
.policy-footer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }
.copyright { margin-top: 20px; font-size: 0.72rem; color: var(--text-tertiary); }
.btn-link { display: block; text-decoration: none; text-align: center; }

/* ============================================================
   ADMIN DASHBOARD
   ============================================================ */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-elevated);
  color: var(--gold-400);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }
