/* style.css — Mobile-first, sem dependências externas */
:root {
  --primary: #1e88e5;
  --primary-dark: #1565c0;
  --success: #2e7d32;
  --danger: #c62828;
  --warn: #ef6c00;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e1e5ee;
  --text: #1a2233;
  --muted: #697284;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg);
  min-height: 100vh;
  padding-bottom: 80px;
}

/* Cabeçalho */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--primary); color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.app-header h1 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.app-header .sub { font-size: 0.8rem; opacity: 0.85; }
.app-header .actions button { background: rgba(255,255,255,0.15); color: #fff; border: 0; padding: 8px 12px; border-radius: 6px; font-size: 0.85rem; }
.app-header .actions button:active { background: rgba(255,255,255,0.3); }

main { padding: 12px; max-width: 900px; margin: 0 auto; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 1rem; color: var(--text); }
.card .subtitle { color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }

/* Form */
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=month], input[type=time], input[type=number], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%;
  padding: 0 12px;
  font-size: 16px;
  line-height: normal;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  margin-bottom: 12px;
  height: 46px;
  box-sizing: border-box;
  font-family: inherit;
  vertical-align: middle;
  -webkit-appearance: none; appearance: none;
}
textarea {
  height: auto;
  min-height: 46px;
  padding: 10px 12px;
  line-height: 1.4;
  resize: vertical;
  -webkit-appearance: auto; appearance: auto;
}
select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23697284' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
/* Reset dos pseudo-elementos internos do WebKit/Blink para date/time/month —
   sem isto o Chrome/Safari acrescenta padding interno e o input fica mais alto
   que os restantes. */
input[type=date]::-webkit-date-and-time-value,
input[type=month]::-webkit-date-and-time-value,
input[type=time]::-webkit-date-and-time-value {
  text-align: left;
  padding: 0;
  margin: 0;
  min-height: 0;
  line-height: normal;
}
input[type=date]::-webkit-datetime-edit,
input[type=month]::-webkit-datetime-edit,
input[type=time]::-webkit-datetime-edit {
  padding: 0;
  line-height: normal;
}
input[type=date]::-webkit-datetime-edit-fields-wrapper,
input[type=month]::-webkit-datetime-edit-fields-wrapper,
input[type=time]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type=date]::-webkit-inner-spin-button,
input[type=month]::-webkit-inner-spin-button,
input[type=time]::-webkit-inner-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0; height: auto;
}
input[type=date]::-webkit-calendar-picker-indicator,
input[type=month]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator {
  opacity: 0.6; cursor: pointer; padding: 0; margin: 0;
}
/* Firefox: remover altura extra do spinner */
input[type=number] { -moz-appearance: textfield; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

button, .btn {
  display: inline-block; padding: 12px 16px; font-size: 1rem;
  background: var(--primary); color: #fff; border: 0; border-radius: 8px;
  cursor: pointer; text-decoration: none; text-align: center;
  font-weight: 500;
}
button:active, .btn:active { background: var(--primary-dark); }
button.secondary { background: #e9edf3; color: var(--text); }
button.danger { background: var(--danger); }
button.success { background: var(--success); }
button.warn { background: var(--warn); }
button.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
button.block, .btn.block { width: 100%; display: block; }
button.small { padding: 6px 10px; font-size: 0.85rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row.wrap { flex-wrap: wrap; }

/* Lista itens */
.list { list-style: none; padding: 0; margin: 0; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border-bottom: 1px solid var(--border);
  gap: 10px;
}
.list-item:last-child { border-bottom: 0; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .name { font-weight: 500; }
.list-item .info .meta { font-size: 0.8rem; color: var(--muted); }
.list-item .actions-cell { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* Toggle presente/ausente */
.presence-toggle {
  display: flex; gap: 6px;
}
.presence-toggle button {
  min-width: 44px; padding: 10px 12px; font-size: 0.85rem; font-weight: 600;
  border-radius: 8px;
}
.presence-toggle .p { background: #e9edf3; color: var(--muted); }
.presence-toggle .p.active { background: var(--success); color: #fff; }
.presence-toggle .f { background: #e9edf3; color: var(--muted); }
.presence-toggle .f.active { background: var(--danger); color: #fff; }
.presence-toggle .j { background: #e9edf3; color: var(--muted); }
.presence-toggle .j.active { background: var(--warn); color: #fff; }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }
.badge.ok { background: #d4edda; color: var(--success); }
.badge.warn { background: #fff3cd; color: var(--warn); }
.badge.no { background: #f8d7da; color: var(--danger); }
.badge.info { background: #e3f2fd; color: var(--primary-dark); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; margin-top: 8px; }
.stat { text-align: center; background: var(--bg); padding: 10px; border-radius: 8px; }
.stat .n { font-size: 1.3rem; font-weight: 700; }
.stat .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }

/* Toast */
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 8px;
  z-index: 100; opacity: 0; transition: opacity 0.2s;
  max-width: 90%; font-size: 0.9rem;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* Tabela mensal */
.tabela-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.mensal { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
table.mensal th, table.mensal td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
table.mensal th { background: #eef2f7; font-weight: 600; position: sticky; top: 0; }
table.mensal td.nome { text-align: left; position: sticky; left: 0; background: #fff; font-weight: 500; min-width: 140px; }
table.mensal td.p { background: #d4edda; color: var(--success); font-weight: 600; }
table.mensal td.f { background: #f8d7da; color: var(--danger); font-weight: 600; }
table.mensal td.j { background: #fff3cd; color: var(--warn); font-weight: 600; }
table.mensal td.none { color: var(--muted); }
table.mensal tfoot td { background: #eef2f7; font-weight: 600; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: #e9edf3; padding: 4px; border-radius: 8px; margin-bottom: 12px; }
.tabs button {
  flex: 1; background: transparent; color: var(--muted);
  padding: 8px; font-size: 0.85rem; font-weight: 500;
}
.tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 500px;
  padding: 20px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal h3 { margin-top: 0; }
@media (max-width: 600px) {
  /* Em ecrãs pequenos, manter folgas mas continuar centrado */
  .modal-backdrop { padding: 12px; }
}

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}
.login-box {
  background: #fff; padding: 30px 24px; border-radius: 14px; width: 100%; max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.login-box h1 { text-align: center; font-size: 1.3rem; margin: 0 0 4px; color: var(--primary-dark); }
.login-box .logo { text-align: center; font-size: 2.5rem; margin-bottom: 8px; }

/* Empty state */
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .icon { font-size: 2rem; margin-bottom: 8px; }

@media (min-width: 768px) {
  body { font-size: 15px; }
  main { padding: 20px; }
  table.mensal { font-size: 0.9rem; }
}
