/* ============================================================
   Portaria Digital — Colégio Salesiano São José
   Tema: azul claro + branco
   ============================================================ */

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-700: #1d4ed8;
  --primary-900: #1e3a8a;

  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-700: #b45309;
  --amber-600: #d97706;
  --rose-50: #fef2f2;
  --rose-700: #b91c1c;
  --slate-200: #e2e8f0;
  --slate-700: #334155;
  --zinc-100: #f4f4f5;
  --zinc-500: #71717a;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; width: 100%; }

/* ---------- Header ---------- */
.site-header {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.logo { width: 40px; height: 40px; object-fit: contain; }
.brand-name { font-weight: 600; font-size: 1rem; line-height: 1.2; }
.brand-sub { font-size: 0.75rem; color: var(--text-muted); }

.header-nav { display: flex; align-items: center; gap: 0.75rem; }
.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 8px 4px 4px;
  cursor: pointer; font: inherit;
}
.user-trigger:hover { background: var(--border-light); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-100); color: var(--primary-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600;
}
.user-name { font-size: 0.875rem; font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { font-size: 0.7rem; color: var(--text-muted); }

.dropdown {
  display: none;
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 220px; z-index: 200; overflow: hidden;
}
.dropdown.show { display: block; }
.dropdown-header { padding: 0.75rem 1rem; }
.dropdown-name { font-weight: 600; font-size: 0.9rem; }
.dropdown-email { font-size: 0.75rem; color: var(--text-muted); }
.dropdown-role { font-size: 0.75rem; color: var(--primary); margin-top: 4px; }
.dropdown hr { border: 0; border-top: 1px solid var(--border); }
.dropdown-item {
  display: block; padding: 0.6rem 1rem;
  text-decoration: none; color: var(--text); font-size: 0.875rem;
}
.dropdown-item:hover { background: var(--border-light); }
.dropdown-item.danger { color: var(--rose-700); }

/* ---------- Main ---------- */
.main-content { flex: 1; padding: 1.5rem 1rem; }

.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; font: inherit;
  font-size: 0.875rem; font-weight: 500; text-decoration: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-100); color: var(--primary-700); }
.btn-secondary:hover { background: var(--primary-200); }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); }
.btn-danger { background: var(--rose-700); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-amber { background: var(--amber-600); color: #fff; }
.btn-amber:hover { background: var(--amber-700); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid; gap: 0.75rem; margin-bottom: 1.5rem;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(5, 1fr); } }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.stat-label { font-size: 0.75rem; color: var(--text-muted); }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-top: 4px; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem; overflow-x: auto;
}
.tab {
  padding: 0.6rem 1rem; border: none; background: none;
  font: inherit; font-size: 0.875rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer; text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--primary); }

/* ---------- Filter chips ---------- */
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  font-size: 0.75rem; font-weight: 500; cursor: pointer;
  text-decoration: none; color: var(--text);
}
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-count { font-size: 0.7rem; opacity: 0.8; }

/* ---------- Cards de autorização ---------- */
.auth-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  position: relative; overflow: hidden;
  margin-bottom: 0.75rem; transition: box-shadow 0.15s;
}
.auth-card:hover { box-shadow: var(--shadow-md); }
.auth-card.live { border-color: var(--amber-600); background: var(--amber-50); }
.auth-card.cancelled { opacity: 0.6; }
.auth-card .stripe {
  position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 999px;
}
.auth-card .stripe.servico { background: var(--amber-600); }
.auth-card .stripe.visita { background: var(--primary); }
.auth-card-body { padding-left: 0.5rem; display: flex; justify-content: space-between; gap: 1rem; }
.auth-card-main { flex: 1; min-width: 0; }
.auth-card-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.25rem; }
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  border: 1px solid; font-size: 0.7rem; font-weight: 500;
}
.badge-type-servico { background: var(--amber-100); color: var(--amber-700); border-color: #fde68a; }
.badge-type-visita { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-200); }
.badge-status-AUTORIZADO { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-200); }
.badge-status-CHECKIN { background: var(--amber-100); color: var(--amber-700); border-color: #fde68a; }
.badge-status-CHECKOUT { background: var(--slate-200); color: var(--slate-700); border-color: #cbd5e1; }
.badge-status-RECUSADO { background: var(--rose-50); color: var(--rose-700); border-color: #fecaca; }
.badge-status-CANCELADO { background: var(--zinc-100); color: var(--zinc-500); border-color: #e4e4e7; }

.live-dot { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; color: var(--amber-600); font-weight: 500; }
.live-dot::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--amber-600);
  box-shadow: 0 0 0 4px rgba(217,119,6,0.2); animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.auth-name {
  font-size: 1rem; font-weight: 600; margin-bottom: 0.15rem;
  color: var(--text); text-decoration: none; display: block;
}
.auth-name:hover { color: var(--primary); }
.auth-purpose { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: 0.75rem; color: var(--text-muted); }
.auth-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }
.auth-time { text-align: right; }
.auth-time-start { font-size: 0.875rem; font-weight: 600; }
.auth-time-end { font-size: 0.7rem; color: var(--text-muted); }
.auth-actions { display: flex; gap: 0.4rem; align-items: center; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 3rem 1.5rem;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--border-light);
}
.empty-state-icon { font-size: 2rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.875rem; max-width: 28rem; margin: 0 auto 1rem; }

/* ---------- Login ---------- */
.login-wrapper { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .login-wrapper { grid-template-columns: 1fr 1fr; } }

.login-panel {
  background: var(--primary-50);
  color: var(--primary-900);
  padding: 2.5rem; display: none;
  position: relative; overflow: hidden;
  flex-direction: column; justify-content: space-between;
}
@media (min-width: 1024px) { .login-panel { display: flex; } }
.login-panel::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(59,130,246,0.12) 1px, transparent 0);
  background-size: 22px 22px;
}
.login-panel > * { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.login-brand .logo { width: 48px; height: 48px; }
.login-brand-name { font-size: 1.125rem; font-weight: 600; }
.login-brand-sub { font-size: 0.75rem; color: var(--primary-700); }
.login-title { font-size: 1.875rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-title-sub { font-size: 1.25rem; color: var(--primary-700); margin-bottom: 1.5rem; }
.login-desc { color: var(--primary-700); font-size: 0.875rem; line-height: 1.6; margin-bottom: 2rem; max-width: 28rem; }
.login-features { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.login-features li { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
.login-feature-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,0.7); color: var(--primary-700);
  display: flex; align-items: center; justify-content: center;
}
.login-copyright { font-size: 0.75rem; color: var(--primary-700); }

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; background: var(--bg); }
.login-form-card { width: 100%; max-width: 28rem; }
.login-form-mobile-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
@media (min-width: 1024px) { .login-form-mobile-brand { display: none; } }
.login-form-mobile-brand .logo { width: 44px; height: 44px; }
.login-form-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-form-sub { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ---------- Forms ---------- */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; }
.form-label .req { color: var(--rose-700); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 0.875rem; background: var(--card);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-textarea { min-height: 70px; resize: vertical; }
.form-error { color: var(--rose-700); font-size: 0.75rem; margin-top: 0.25rem; }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } .form-grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

.type-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.type-option {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem; cursor: pointer; text-align: left; background: var(--card);
  font: inherit; transition: all 0.15s;
}
.type-option:hover { border-color: var(--primary); }
.type-option.selected { border-color: var(--primary); background: var(--primary-50); }
.type-option-title { font-weight: 600; font-size: 0.875rem; display: flex; justify-content: space-between; }
.type-option-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

.companion-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.companion-tag {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--border-light); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.25rem 0.6rem; font-size: 0.75rem;
}
.companion-tag button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 0.9rem; line-height: 1; }
.companion-tag button:hover { color: var(--rose-700); }
.companion-input-row { display: flex; gap: 0.5rem; }

/* ---------- Detail ---------- */
.detail-section { background: var(--border-light); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; margin-bottom: 1rem; }
.detail-section-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 0.25rem; }
.detail-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
.detail-row { display: flex; gap: 0.6rem; align-items: flex-start; }
.detail-row-icon { color: var(--text-muted); margin-top: 2px; }
.detail-row-label { font-size: 0.7rem; color: var(--text-muted); }
.detail-row-value { font-size: 0.875rem; font-weight: 500; word-break: break-word; }

.audit-grid { display: grid; gap: 0.75rem; }
@media (min-width: 640px) { .audit-grid { grid-template-columns: 1fr 1fr; } }
.audit-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.audit-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.audit-value { font-weight: 500; font-size: 0.875rem; }

.readonly-notice {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  border: 1px dashed var(--border); background: var(--border-light);
  border-radius: var(--radius); padding: 0.6rem; font-size: 0.85rem; color: var(--text-muted);
  text-align: center;
}

/* ---------- Agenda (date strip) ---------- */
.date-strip-wrapper { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.date-strip { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 4px; flex: 1; }
.date-cell {
  flex-shrink: 0; width: 64px; padding: 0.5rem 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); cursor: pointer; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text); font: inherit;
}
.date-cell:hover { border-color: var(--primary); }
.date-cell.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.date-cell.today::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.date-cell.active.today::after { background: #fff; }
.date-cell .weekday { font-size: 0.6rem; text-transform: uppercase; opacity: 0.7; }
.date-cell .daynum { font-size: 1.1rem; font-weight: 700; }
.date-cell .dot { width: 6px; height: 6px; border-radius: 50%; }
.date-cell .dot.has { background: var(--primary); }
.date-cell.active .dot.has { background: #fff; }
.strip-nav { background: none; border: none; cursor: pointer; padding: 0.5rem; font-size: 1.2rem; color: var(--text-muted); }
.strip-nav:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---------- Flash ---------- */
.flash {
  position: fixed; top: 1rem; right: 1rem; z-index: 1000;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem; border-radius: var(--radius);
  box-shadow: var(--shadow-md); max-width: 24rem; font-size: 0.875rem;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }
.flash button { background: none; border: none; cursor: pointer; font-size: 1.2rem; line-height: 1; color: inherit; opacity: 0.7; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: var(--rose-50); color: var(--rose-700); border: 1px solid #fecaca; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto; background: var(--border-light);
  border-top: 1px solid var(--border); padding: 1rem;
}
.footer-inner {
  display: flex; flex-direction: column; gap: 0.5rem;
  align-items: center; justify-content: space-between;
  font-size: 0.75rem; color: var(--text-muted);
}
@media (min-width: 640px) { .footer-inner { flex-direction: row; } }
.footer-brand { display: flex; align-items: center; gap: 0.5rem; }
.logo-sm { width: 20px; height: 20px; object-fit: contain; }

/* ---------- Tables (staff) ---------- */
.staff-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-bottom: 0.75rem;
}
.staff-info { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.staff-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.staff-avatar.admin { background: var(--primary-100); color: var(--primary-700); }
.staff-avatar.gestor { background: var(--primary-50); color: var(--primary-700); }
.staff-avatar.porteiro { background: var(--border-light); color: var(--text-muted); }
.staff-name { font-weight: 600; }
.staff-email { font-size: 0.85rem; color: var(--text-muted); }
.staff-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: var(--rose-50); color: var(--rose-700); border: 1px solid #fecaca; }
.alert-info { background: var(--primary-50); color: var(--primary-700); border: 1px solid var(--primary-200); }

/* ---------- Loading ---------- */
.loading { display: flex; justify-content: center; padding: 3rem; color: var(--text-muted); }

/* ---------- Search input ---------- */
.search-wrapper { position: relative; margin-bottom: 1rem; }
.search-wrapper::before { content: '🔍'; position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); font-size: 0.9rem; opacity: 0.5; }
.search-input { padding-left: 2.2rem; }

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.font-medium { font-weight: 500; }
