/* ============================================================
   GLOBAL CSS — Minha Loja Virtual
   Variáveis, reset, tipografia, componentes base
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@700;800&family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Variáveis de cor ─────────────────────────────────────────
   TEMA CLARO — estrutura estilo Hotmart, marca M-Pesa (verde).
   Fundo branco, verde como cor de marca, dourado de destaque.
   ------------------------------------------------------------- */
:root {
  /* Superfícies */
  --bg-primary:    #FFFFFF;   /* fundo principal (páginas)            */
  --bg-secondary:  #F5F8F6;   /* faixas alternadas, inputs, hovers    */
  --bg-card:       #FFFFFF;   /* cartões                              */
  --bg-tint:       #EEFBF3;   /* tinta verde muito suave (destaques)  */
  --bg-input:      #F5F8F6;   /* fundo de campos de texto (claro)     */
  --bg-dark:       #0A1512;   /* blocos escuros pontuais (CTA/footer) */

  /* Marca */
  --accent-green:       #00A854;  /* verde M-Pesa ajustado p/ fundo claro (AA) */
  --accent-green-bright:#00E676;  /* verde vivo — realces, gráficos            */
  --accent-green-muted: #008F47;  /* hover                                      */
  --accent-gold:        #E8A400;  /* dourado destaque (legível em claro)        */

  /* Texto */
  --text-primary:   #0C1A14;   /* quase-preto esverdeado */
  --text-secondary: #55665D;   /* texto de apoio         */
  --text-muted:     #8A998F;   /* legendas, hints        */
  --text-on-dark:   #EAFBF1;   /* texto sobre blocos escuros */

  /* Linhas e estados */
  --border:        #E4EBE7;
  --border-strong: #D2DDD6;
  --border-active: #00A854;
  --danger:  #E03535;
  --success: #00A854;
  --warning: #E8A400;
  --info:    #2F6FE0;

  /* Tipografia */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Raios */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Sombras neutras e suaves (estilo Hotmart) */
  --shadow-sm: 0 1px 2px rgba(12, 26, 20, 0.05), 0 1px 3px rgba(12, 26, 20, 0.06);
  --shadow-md: 0 4px 16px rgba(12, 26, 20, 0.08);
  --shadow-lg: 0 12px 40px rgba(12, 26, 20, 0.12);
  --shadow-glow: 0 8px 24px rgba(0, 168, 84, 0.22);

  /* Transições */
  --transition: 200ms ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-green); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-green-muted); }
button, input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Tipografia ──────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.mono { font-family: var(--font-mono); }

/* Marca "KulaEasy": a 2ª parte ("Easy") em verde para o efeito bicolor.
   !important garante o contraste em qualquer contexto (nav, sidebar, footer). */
.logo-dot { color: var(--accent-green) !important; }
.logo-dot-bright { color: var(--accent-green-bright) !important; }

/* Logo em imagem (partials/logo.php). Quando o ficheiro existe, substitui o texto. */
.nav-logo { display: inline-flex; align-items: center; text-decoration: none; }
.logo-img { display: block; height: 38px; width: auto; }
/* Fallback em texto (enquanto não há ficheiro): "Kula" escuro + "Easy" verde */
.logo-txt { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem;
  letter-spacing: -0.03em; color: var(--text-primary); }
/* Em fundos escuros (footer), se o logo tiver fundo branco, dar-lhe um respiro */
.footer .logo-img, .mkt-footer .logo-img { border-radius: 6px; }

/* ── Botões ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(255,255,255,0.08);
  transition: opacity var(--transition);
}

.btn:hover::after { opacity: 1; }

.btn-primary {
  background: var(--accent-green);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--accent-green-muted);
  transform: translateY(-1px) scale(1.02);
  box-shadow: var(--shadow-glow);
  color: #FFFFFF;
}

.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--accent-green);
  border: 1.5px solid var(--accent-green);
}

.btn-secondary:hover {
  background: rgba(0, 230, 118, 0.08);
  transform: translateY(-1px);
  color: var(--accent-green);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #e63939;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: rgba(0, 230, 118, 0.05);
}

.btn-sm { padding: 8px 16px; font-size: 1.05rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 16px 32px; font-size: 1.1rem; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }
.btn-icon { padding: 10px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.card-sm { padding: 16px; border-radius: var(--radius-md); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Nota pequena por baixo de um badge de estado (não alarga a coluna) */
.estado-nota {
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 3px;
  white-space: nowrap;
  line-height: 1.2;
}
.estado-nota-orange { color: #9A6E00; }
.estado-nota-red    { color: var(--danger); }

.badge-green  { background: var(--bg-tint);            color: var(--accent-green-muted); }
.badge-gold   { background: rgba(232, 164, 0, 0.14);  color: #9A6E00; }
.badge-red    { background: rgba(224, 53, 53, 0.10);  color: var(--danger); }
.badge-gray   { background: var(--bg-secondary);       color: var(--text-secondary); }
.badge-orange { background: rgba(232, 164, 0, 0.14);  color: #9A6E00; }

/* ── Inputs ──────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1.05rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(0, 230, 118, 0.12);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6L8 10L12 6' stroke='%238A9E90' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-error {
  font-size: 1.05rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-hint {
  font-size: 1.05rem;
  color: var(--text-muted);
}

/* ── Tabelas ─────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem; /* ~14.8px: densidade adequada a tabelas */
}

.table th {
  background: var(--bg-secondary);
  padding: 11px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.7rem; /* ~12.6px: cabeçalho em maiúsculas compacto */
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

/* Valores monetários e numéricos nunca quebram linha */
.table td.mono,
.table th.mono { white-space: nowrap; }

/* Coluna de texto longo (nomes de produto) trunca com reticências
   em vez de empilhar em várias linhas e inchar a altura da linha */
.table td.col-trunc {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Colunas secundárias que se escondem em ecrãs mais estreitos,
   mantendo a tabela toda visível sem scroll horizontal.
   Breakpoint alto porque a sidebar (260px) reduz a área útil. */
@media (max-width: 1450px) {
  .table .col-opcional { display: none; }
}

/* Célula de acções — botões compactos (só ícone) que não esticam a coluna.
   O texto vive em .btn-label e é escondido aqui; fica no title (tooltip). */
.table td.table-acoes {
  white-space: nowrap;
  text-align: right;
}
.table td.table-acoes .btn {
  padding: 6px 9px;
  font-size: 0.95rem;   /* emoji um pouco maior por já não ter texto ao lado */
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 0;
}
.table td.table-acoes .btn:hover { border-color: var(--border-strong); background: var(--bg-secondary); }
.table td.table-acoes .btn-label { display: none; }
.table td.table-acoes form { display: inline; }
.table td.table-acoes > * + * { margin-left: 4px; }

.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--bg-tint); }
.table tbody tr:nth-child(even) { background: var(--bg-secondary); }
.table tbody tr:nth-child(even):hover { background: var(--bg-tint); }

/* ── Alertas ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: rgba(0, 230, 118, 0.1); border: 1px solid rgba(0, 230, 118, 0.3); color: var(--accent-green); }
.alert-danger  { background: rgba(255, 77, 77, 0.1);  border: 1px solid rgba(255, 77, 77, 0.3);  color: var(--danger); }
.alert-warning { background: rgba(255, 184, 0, 0.1);  border: 1px solid rgba(255, 184, 0, 0.3);  color: var(--warning); }
.alert-info    { background: rgba(74, 143, 231, 0.1); border: 1px solid rgba(74, 143, 231, 0.3); color: #4A8FE7; }

/* ── Paginação ───────────────────────────────────────────── */
.paginacao {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 20px 0;
}

.paginacao a,
.paginacao span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 500;
  transition: all var(--transition);
}

.paginacao a {
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.paginacao a:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: rgba(0, 230, 118, 0.08);
}

.paginacao .ativo {
  background: var(--accent-green);
  color: #FFFFFF;
  font-weight: 700;
}

/* ── Skeleton loaders ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-secondary) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text  { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 28px; margin-bottom: 12px; }
.skeleton-card  { height: 120px; border-radius: var(--radius-lg); }

/* ── Utilitários ─────────────────────────────────────────── */
.text-green   { color: var(--accent-green); }
.text-gold    { color: var(--accent-gold); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.font-mono    { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

.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; }
.mt-32 { margin-top: 32px; }

.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.w-full { width: 100%; }
.hidden { display: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ── Scrollbar personalizada ─────────────────────────────── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg-secondary); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Animações ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in  { animation: fadeIn 0.3s ease forwards; }
.animate-fade-up  { animation: fadeInUp 0.4s ease forwards; }
.spin { animation: spin 0.8s linear infinite; }

/* Reveal ao scroll (activado via JS) */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visivel {
  opacity: 1;
  transform: translateY(0);
}

/* ── Spinner de carregamento ─────────────────────────────── */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 20px; height: 20px; border-width: 2px; }

/* ── Toast / Notificações ────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.3s ease;
  font-size: 1.05rem;
}

.toast-success { border-left: 3px solid var(--accent-green); }
.toast-danger  { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }

/* ── Responsividade global ───────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .btn-lg { padding: 14px 24px; }
  .card { padding: 16px; }
  h1 { font-size: clamp(1.8rem, 6vw, 3rem); }
  h2 { font-size: clamp(1.4rem, 4vw, 2rem); }
}

/* ── Modal de confirmação (substitui o confirm() nativo) ──── */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-modal.aberto { display: flex; }

.confirm-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 26, 20, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease;
}

.confirm-modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px 22px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  animation: confirmModalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes confirmModalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.confirm-modal-icon {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: var(--bg-tint);
}
.confirm-modal.danger .confirm-modal-icon { background: rgba(224, 53, 53, 0.10); }

.confirm-modal-titulo {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.confirm-modal-msg {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 22px;
  white-space: pre-line; /* respeita as quebras de linha da mensagem */
}
.confirm-modal-acoes {
  display: flex;
  gap: 10px;
}
.confirm-modal-acoes .btn { flex: 1; justify-content: center; }

@media (max-width: 480px) {
  .confirm-modal-acoes { flex-direction: column-reverse; }
}
