/* ============================================================
   DESIGN SYSTEM — Gestão de Voluntários
   Tema: Institucional refinado, sóbrio, confiável
   ============================================================ */

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

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --bg-card:     #171b26;
  --bg-input:    #1e2334;
  --border:      #2a3050;
  --border-soft: #1e2334;

  --text:        #e8eaf0;
  --text-soft:   #8892a4;
  --text-dim:    #4a5568;

  --accent:      #c9a96e;       /* dourado suave — espiritual */
  --accent-soft: rgba(201,169,110,0.12);
  --accent-dim:  rgba(201,169,110,0.06);

  --success:     #4caf7d;
  --error:       #e05c5c;
  --info:        #5c8ee0;
  --warning:     #e0a85c;

  --role-admin:   #c9a96e;
  --role-editor:  #5c8ee0;
  --role-manager: #b07de0;
  --role-user:    #4caf7d;

  --radius:      8px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);

  --font-display: 'Crimson Pro', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --nav-w: 220px;
}

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

html { font-size: 15px; }

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

/* ── Layout principal ──────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
}

.page-content {
  padding: 2.5rem 3rem;
  overflow-x: hidden;
}

/* ── Navegação ─────────────────────────────────────────────── */
#main-nav {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 2rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.4rem 2rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 1.5rem;
}

.nav-cross {
  color: var(--accent);
  font-size: 1.4rem;
}

.nav-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.nav-links {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  transition: all 0.15s ease;
  letter-spacing: 0.01em;
}

.nav-link:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 500;
}

.nav-icon {
  font-size: 0.7rem;
  opacity: 0.6;
}

.nav-link.active .nav-icon { opacity: 1; }

.nav-user {
  padding: 1.25rem 1.25rem 0;
  border-top: 1px solid var(--border-soft);
  margin-top: auto;
}

.nav-user-info {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
}

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

.nav-user-role {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.role-admin   { color: var(--role-admin); }
.role-editor  { color: var(--role-editor); }
.role-manager { color: var(--role-manager); }
.role-user    { color: var(--role-user); }

.nav-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 1rem 0.75rem 0.25rem;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-soft);
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-soft);
  margin-top: 0.25rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ── Stat cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--bg-input);
}

th {
  text-align: left;
  padding: 0.875rem 1.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  vertical-align: middle;
}

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

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover { background: var(--accent-dim); }

.td-soft { color: var(--text-soft); font-size: 0.82rem; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-admin   { background: rgba(201,169,110,0.15); color: var(--role-admin); }
.badge-editor  { background: rgba(92,142,224,0.15);  color: var(--role-editor); }
.badge-manager { background: rgba(176,125,224,0.15); color: var(--role-manager); }
.badge-user    { background: rgba(76,175,125,0.15);  color: var(--role-user); }
.badge-area    { background: var(--accent-dim); color: var(--text-soft); border: 1px solid var(--border); }

/* ── Botões ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0f1117;
}
.btn-primary:hover:not(:disabled) { background: #d4b47a; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(224,92,92,0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(224,92,92,0.1);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-signout {
  width: 100%;
  padding: 0.45rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-signout:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ── Formulários ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

select option { background: var(--bg-card); }

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
}

.checkbox-item input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(1rem);
  transition: all 0.25s ease;
  min-width: 240px;
}

.toast.show { opacity: 1; transform: translateX(0); }

.toast-success { background: rgba(76,175,125,0.15); border: 1px solid rgba(76,175,125,0.3); color: var(--success); }
.toast-error   { background: rgba(224,92,92,0.15);  border: 1px solid rgba(224,92,92,0.3);  color: var(--error); }
.toast-info    { background: rgba(92,142,224,0.15); border: 1px solid rgba(92,142,224,0.3); color: var(--info); }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-soft);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

/* ── Animações ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* ── Utilitários ───────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-1        { gap: 0.5rem; }
.gap-2        { gap: 1rem; }
.mt-1         { margin-top: 0.5rem; }
.mt-2         { margin-top: 1rem; }
.text-soft    { color: var(--text-soft); }
.text-accent  { color: var(--accent); }

/* ── Página de login ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport height para mobile */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(201,169,110,0.06) 0%, transparent 70%);
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-cross {
  color: var(--accent);
  font-size: 2rem;
  margin-bottom: 1.25rem;
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem;
  background: #fff;
  color: #333;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-google:hover { background: #f5f5f5; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }

.btn-google svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
}

.login-error {
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: rgba(224,92,92,0.1);
  border: 1px solid rgba(224,92,92,0.25);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.85rem;
  display: none;
}

.login-error.show { display: block; }

/* ── Responsive — Mobile first ─────────────────────────────── */

/* Hamburguer button — só aparece em mobile */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all 0.15s;
}
.nav-toggle:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 768px) {

  /* Layout: nav em cima, conteúdo em baixo */
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  /* Nav horizontal com hamburguer */
  #main-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
    gap: 0;
  }

  .nav-brand {
    padding: 0;
    border-bottom: none;
    margin-bottom: 0;
  }

  /* Links e user info: escondidos por defeito, abrem com hamburguer */
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }

  .nav-links.open { display: flex; }

  .nav-section-label {
    padding: 0.75rem 0.5rem 0.2rem;
  }

  .nav-user {
    display: none;
  }

  /* Hamburguer visível */
  .nav-toggle { display: block; }

  /* Info do utilizador dentro do menu mobile */
  .nav-user-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.5rem;
    border-top: 1px solid var(--border-soft);
    margin-top: 0.5rem;
  }

  .nav-user-mobile-info {
    display: flex;
    flex-direction: column;
  }

  .nav-user-mobile-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
  }

  .nav-user-mobile-role {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  /* Conteúdo */
  .page-content {
    padding: 1.25rem 1rem;
  }

  /* Page header em coluna */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .page-header .btn { width: 100%; justify-content: center; }

  /* Stats grid — 2 colunas em mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Tabelas — scroll horizontal */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table { min-width: 500px; }

  /* Modais — full width */
  .modal {
    width: 95%;
    max-width: 95%;
    margin: 1rem;
    padding: 1.5rem 1.25rem;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Painéis laterais — full screen em mobile */
  .side-panel {
    max-width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
  }

  /* Botões em linha — empilhar em mobile */
  .flex.gap-1 { flex-wrap: wrap; }

  /* Cards de evento — empilhar botões */
  .event-card {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .event-card > div:last-child {
    width: 100%;
  }

  .event-card .btn {
    width: 100%;
    justify-content: center;
  }

  /* Checkin stats — scroll horizontal */
  .checkin-stats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 0.75rem 1rem;
  }

  .checkin-stat { min-width: 70px; }

  /* Reports total card */
  .total-card [style*="display:flex"] {
    flex-direction: column !important;
    gap: 1rem !important;
  }

  .total-card [style*="border-left"] {
    border-left: none !important;
    border-top: 1px solid var(--border) !important;
    padding-left: 0 !important;
    padding-top: 0.75rem !important;
  }
}

/* Extra pequeno — phones estreitos */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.8rem; }
  .page-title { font-size: 1.6rem; }
}
