/* ===== Base / layout ===== */
*, *::before, *::after { box-sizing: border-box; }

:root{
  --gutter: clamp(12px, 4vw, 20px);
}

/* sem vazamento lateral e com scroll vertical global */
html, body { overflow-x: hidden; overflow-y: auto; }

html {
  height: 100%;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding-inline: var(--gutter);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f1cf00 0%, #fefbd3 100%);
  background-attachment: fixed;
}

h1, h2, h3 { text-align: center; margin: 0 0 14px 0; }

/* ===== Estrutura de página ===== */
.page-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;   /* central no desktop */
  align-items: center;
  gap: 12px;
  padding: 24px 0;
}

.header-logo {
  display:block; width:clamp(160px, 50vw, 280px); height:auto; margin:0 auto 8px;
}

#login-area { width:100%; max-width:420px; }

/* ===== Inputs / botões ===== */
input, button, select.input-like {
  width:100%; margin:10px auto; padding:12px; font-size:16px; display:block;
  border:1px solid #cfd6e4; border-radius:10px; background:#fff; color:#1d2433;
}

select.input-like {
  appearance:none;
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path fill="%23909ab0" d="M7 10l5 5 5-5z"/></svg>');
  background-repeat:no-repeat; background-position:right 12px center; background-size:20px;
}

button {
  background:#e9bc00; color:#fff; border:none; font-weight:700; cursor:pointer;
}
button:disabled{ background:#fffaaa; cursor:not-allowed; }

.help-text { margin:8px 0 0; color:#233; font-size:12px; text-align:center; }

/* ===== Overlay de loading ===== */
#loading {
  position:fixed; inset:0; width:100svw; height:100svh;
  display:none; place-items:center; background:rgba(0,0,0,.35); z-index:10000;
}
#loading .loading-bubble {
  padding:12px 16px; background:#fff; border-radius:10px; font-weight:700;
  box-shadow:0 6px 18px rgba(0,0,0,.15); color:#000;
}

/* ===== Rodapé ===== */
.site-footer {
  margin:24px calc(var(--gutter) * -1) 0;
  background:#e9bc00; color:#fff;
}
.site-footer .footer-inner {
  max-width:1200px; margin:0 auto; padding:14px var(--gutter);
  text-align:center; line-height:1.5;
}
.site-footer a { color:#fff; text-decoration:underline; }
.site-footer a:hover { opacity:.9; }

@supports (padding: env(safe-area-inset-bottom)) {
  .site-footer .footer-inner { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* ===== Topbar corrigida (não usa 100vw para evitar overflow) ===== */
.topbar{
  width:auto;
  margin-left: calc(-1 * var(--gutter));
  margin-right: calc(-1 * var(--gutter));
  background:#e6b200;
  color:#000;
  font-weight:800;
  text-align:center;
  padding:12px 0;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}

/* ===== Overlay Global Reforçado ===== */
#global-loading {
  position: fixed;
  inset: 0;
  display: none;     /* controlado via setLoading() */
  place-items: center;
  z-index: 2147483647;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  will-change: backdrop-filter;
}
.global-loading-bubble {
  background: #fff;
  padding: 16px 22px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.20);
}

/* ===== Cupom / Destaques ===== */
#cupomBox {
  background: #d64545 !important;
  color: #fff !important;
  border-radius: 18px;
  padding: 14px 18px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
#cupomBox a { color:#fff; text-decoration:underline; }
#cupomBox a:hover { opacity:.8; }

/* ===== Modal Blur ===== */
.modal.show{
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  will-change: backdrop-filter;
}

/* ===== Labels ===== */
.field-label {
  display:block;
  text-align:center;
  width:100%;
  max-width:420px;
  margin:14px auto 6px;
  font-size:18px;
  font-weight:600;
  color:#1d2433;
}

/* ======== Professores – Tabela ======== */
#prof-exercicios { margin-left:auto; margin-right:auto; }

/* O scroll horizontal fica só aqui; a página continua rolando verticalmente */
#prof-exercicios .table-wrap {
  margin: 0 auto;
  max-width: 100%;
  overflow-x: auto;             /* arraste lateral da planilha */
  overflow-y: visible;          /* não bloqueia o scroll vertical da página */
  -webkit-overflow-scrolling: touch;
  border: 1px solid #eee;
  border-radius: 12px;

  /* permite que o navegador escolha a direção do gesto */
  touch-action: auto;
  overscroll-behavior: auto;
  cursor: grab;
}
#prof-exercicios .table-wrap:active { cursor: grabbing; }

/* layout auto para não encolher todas as colunas */
#exTable{
  border-collapse: collapse;
  table-layout: auto;     /* largura vem do conteúdo (Descrição é limitada via JS) */
  width: max-content;     /* tabela pode ser mais larga; scroll fica no wrap */
  min-width: 760px;       /* conforto no desktop */
}

/* ===== Mobile “mais compacto” ===== */
@media (max-width:480px){
  /* página deixa de ficar centralizada verticalmente — rolagem mais natural */
  .page-center{
    justify-content: flex-start;
    align-items: stretch;
  }
  .wrap{
    width: 100%;
    margin: 16px auto;
  }

  #exTable { min-width: 600px; } /* traz o scroll mais cedo no mobile */
  .cell-clip { max-width: 180px; }
  .btn-band { padding: 14px 12px; font-size: 15px; }
  .panel { padding: 14px; }
}

/* Estado visual "indisponível", porém clicável */
.btn-cta[aria-disabled="true"]{
  opacity: .8;
  filter: saturate(.7);
  cursor: pointer;          /* mantém clicável */
  pointer-events: auto;     /* garante clique mesmo com estilos herdados */
}
