/* ==========================================================================
   Growarq Cloud - Design Tokens & Stylesheet
   Replicação visual de alta fidelidade da interface do Glide / Growarq Cloud
   ========================================================================== */

:root {
  --primary: #3B47C6;
  --primary-hover: #2E3AA8;
  --primary-light: #EFF2FE;
  --primary-border: #C7D2FE;
  
  --bg-app: #F7F7F8;
  --bg-sidebar: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F8FAFC;
  --bg-card-img: #F3F4F6;
  --bg-input: #F3F4F6;
  --bg-input-focus: #FFFFFF;
  
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --text-on-dark: #FFFFFF;
  
  --border-light: #E5E7EB;
  --border-subtle: #F3F4F6;
  --border-focus: #3B47C6;
  
  --badge-free-text: #2563EB;
  --badge-free-bg: #EFF6FF;
  --badge-locked-text: #D97706;
  --badge-locked-bg: #FEF3C7;
  
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 10px 20px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --sidebar-width: 250px;
    
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: 'Plus Jakarta Sans', var(--font-sans);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Sidebar Navigation (Glide Style)
   ========================================================================== */
.sidebar {
  width: 248px;
  min-width: 248px;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid #ECEDF0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 8px;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 4px 6px 20px;
  text-decoration: none;
}

.sidebar-logo {
  height: 28px;
  width: auto;
  display: block;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 20px;
}

/* Rótulos das seções (BIBLIOTECA, FERRAMENTAS, MINHA CONTA) */
.sidebar .pg-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #6B7280;
  padding: 0 8px;
  margin: 0 0 4px;
}

.sidebar-divider {
  height: 1px;
  background-color: #ECEDF0;
  margin: 0 8px 20px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  stroke: currentColor;
  flex-shrink: 0;
  color: #6B7280;
}

.nav-item:hover {
  background-color: #F3F4F6;
  color: #111827;
}

.nav-item.active {
  background-color: #EEEFF3;
  color: #111827;
  font-weight: 600;
}

.nav-item.active svg {
  color: #3B47C6;
}

.nav-item.disabled {
  opacity: 0.55;
  cursor: default;
}

/* User Profile in Sidebar Footer */
.sidebar-footer {
  padding: 10px 4px 0;
  border-top: 1px solid #ECEDF0;
}

.user-profile-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.user-profile-btn:hover {
  background-color: #F3F4F6;
}

.user-profile-btn.active {
  background-color: #EEEFF3;
}

/* Avatar com iniciais (igual ao plugin) */
.user-avatar-iniciais {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #051c2c;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1.5px rgba(5, 28, 44, 0.2);
}
.user-profile-btn.active .user-avatar-iniciais { box-shadow: 0 0 0 2.5px #051c2c; }

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 3rem 4rem 3rem;
  max-width: 1360px;
  margin: 0 auto;
  overflow-y: auto;
}

/* Banner Component */
.header-banner {
  width: 100%;
  aspect-ratio: 1260 / 200;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  margin-bottom: 2rem;
  background-color: #051C2C;
  box-shadow: var(--shadow-sm);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 0 6.6%;
  --hb-cor: #699BEA;
}

/* Nuvens: SVG da padronagem usado como máscara, pintado com a cor da área */
.header-banner .hb-nuvens {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 58%;
  background-color: var(--hb-cor);
  /* As nuvens somem aos poucos na borda esquerda: nada aparece cortado ao meio */
  -webkit-mask-image: url(assets/banners/nuvens-cabecalho.svg), linear-gradient(to right, transparent 0, #000 30%);
  -webkit-mask-size: auto 420%, 100% 100%;
  -webkit-mask-position: left center, 0 0;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: source-in;
  mask-image: url(assets/banners/nuvens-cabecalho.svg), linear-gradient(to right, transparent 0, #000 30%);
  mask-size: auto 420%, 100% 100%;
  mask-position: left center, 0 0;
  mask-repeat: no-repeat;
  mask-composite: intersect;
  pointer-events: none;
}

.header-banner .hb-titulo {
  position: relative;
  font-family: Outfit, Inter, system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(28px, 3.6vw, 52px);
  line-height: 1;
  letter-spacing: -0.01em;
  color: #FFFFFF;
}

.header-banner .hb-logo {
  position: relative;
  height: clamp(16px, 1.6vw, 22px);
  width: auto;
  align-self: flex-start;
  display: block;
}

/* Segmented Sub-Tabs (Pills) */
/* Page Typography */
.page-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.page-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 2rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ==========================================================================
   Authentication Overlay (Supabase OTP via Resend)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background-color: #070F1E;
  background-image: radial-gradient(circle at 50% 20%, rgba(59, 71, 198, 0.18) 0%, transparent 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.4);
  padding: 2.25rem 2rem;
  text-align: center;
  position: relative;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.auth-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.auth-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 0 0.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background-color: #F9FAFB;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus {
  background-color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 71, 198, 0.15);
}

.form-input.otp-input {
  font-family: monospace;
  font-size: 1.4rem;
  letter-spacing: 0.4em;
  text-align: center;
}

.auth-btn-primary {
  width: 100%;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background-color: var(--primary);
  color: #FFFFFF;
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.auth-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-alert-box {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
  display: none;
}

.auth-alert-error {
  background-color: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
}

.auth-alert-info {
  background-color: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
}

.auth-secondary-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.auth-footer-terms {
  margin-top: 1.5rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.auth-footer-terms a {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: #111827;
  color: #FFFFFF;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  animation: slideUp 0.2s ease-out;
}

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

/* ==========================================================================
   Responsivo: em telas menores a barra lateral vira só ícones (igual ao Glide)
   ========================================================================== */
.sidebar-logo-icone { display: none; width: 34px; height: 34px; }

@media (max-width: 1024px) {
  .sidebar { width: 72px; min-width: 72px; padding: 16px 10px; }
  .sidebar-brand { justify-content: center; padding: 4px 0 16px; }
  .sidebar-logo { display: none; }
  .sidebar-logo-icone { display: block; }
  .sidebar .pg-nav-label { display: none; }
  .sidebar-nav-group { margin-bottom: 12px; }
  .nav-item { justify-content: center; padding: 0; min-height: 40px; }
  .nav-item-content { gap: 0; }
  .nav-item-content > span,
  .nav-item .nav-ext { display: none; }
  .sidebar-divider { margin: 0 6px 12px; }
  .sidebar-footer { padding: 10px 0 0; }
  .user-profile-btn { justify-content: center; padding: 4px 0; }
  .user-info { display: none; }
  .main-content { padding: 24px 24px 48px; }
}

@media (max-width: 560px) {
  .sidebar { width: 60px; min-width: 60px; padding: 12px 6px; }
  .main-content { padding: 16px 14px 40px; }
  .header-banner { margin-bottom: 1.25rem; border-radius: 10px; }
}

/* ==========================================================================
   Login (design canvas)
   ========================================================================== */
.auth-overlay { background: linear-gradient(rgba(247,247,248,.5), rgba(247,247,248,.5)), #F7F7F8 url(assets/banners/fundo-login.jpg) center / cover no-repeat; backdrop-filter: none; padding: 32px; }
.auth-card { max-width: 400px; background: #FFFFFF; border: 1px solid #ECEDF0; border-radius: 18px; box-shadow: 0 2px 6px rgba(17,24,39,.05), 0 24px 60px -12px rgba(5,28,44,.22), 0 48px 100px -32px rgba(59,71,198,.25); padding: 36px 32px 24px; display: flex; flex-direction: column; gap: 18px; text-align: left; }
.auth-header { gap: 18px; margin: 0; }
.auth-logo { height: 34px; width: auto; max-width: 100%; box-shadow: none; object-fit: contain; margin: 0 auto; border-radius: 0; }
.auth-desc { text-align: center; font-size: 14px; line-height: 1.55; color: #4B5563; margin: 0; }
.auth-card .form-group { gap: 4px; }
.auth-card .form-label { font-size: 14px; font-weight: 600; color: #111827; }
.auth-ajuda { display: block; font-size: 13px; color: #6B7280; margin-bottom: 6px; }
.auth-card .form-input { font-family: inherit; height: 46px; padding: 0 14px; border: 1px solid #D9DBE1; border-radius: 10px; background: #F7F7F8; font-size: 15px; }
.auth-card .form-input:focus { background: #fff; border-color: #3B47C6; box-shadow: 0 0 0 3px rgba(59,71,198,.15); outline: none; }
.auth-btn-primary { font-family: inherit; height: 48px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #3B47C6, #2E3AA8); color: #fff; font-size: 15px; font-weight: 700; box-shadow: 0 8px 18px -6px rgba(59,71,198,.55); }
.auth-footer-terms { border-top: 1px solid #ECEDF0; padding-top: 14px; margin-top: 0; text-align: center; font-size: 12px; line-height: 1.5; color: #9CA0AA; }
.auth-footer-terms a { color: #4B5563; }

/* Complete seus dados */
#cadastro-overlay { overflow-y: auto; }
#cadastro-overlay .auth-card { max-width: 460px; }
#cadastro-overlay .gc-campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#cadastro-overlay select.form-input { -webkit-appearance: none; appearance: none; padding-right: 42px; background: #F7F7F8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 16px; cursor: pointer; }
@media (max-width: 480px) { #cadastro-overlay .gc-campos-2 { grid-template-columns: 1fr; } }
.cad-carregando { margin: 0; padding: 12px 20px; border-radius: 999px; background: #FFFFFF; border: 1px solid #ECEDF0; box-shadow: 0 2px 6px rgba(17,24,39,.05); font-size: 14px; font-weight: 500; color: #4B5563; }

/* ==========================================================================
   Controle Anti-FOUC (Flash of Unauthenticated Content)
   ========================================================================== */
html.auth-pendente-login #auth-overlay {
  display: flex !important;
}

html.auth-pendente-login .sidebar,
html.auth-pendente-login .main-content {
  visibility: hidden !important;
}

