/* =====================================================
   Olímpiadas Escolares Inscrições — Main CSS
   ===================================================== */

:root {
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --gold: #f59e0b;
  --gold-dark: #d97706;
  --sidebar-bg: #0f2044;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--text); }

/* ── App Layout ── */
.app-body { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: width .25s ease, transform .25s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo { width: 36px; height: 36px; flex-shrink: 0; }

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  background: linear-gradient(135deg, #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap;
  margin-bottom: 2px;
}

.nav-item:hover {
  color: white;
  background: rgba(255,255,255,.08);
}

.nav-item.active {
  color: white;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(26,86,219,.4);
}

.nav-item i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 10px; color: rgba(255,255,255,.5); }

.badge-role-super_admin { color: var(--gold) !important; }
.badge-role-admin { color: #a5b4fc !important; }
.badge-role-user { color: rgba(255,255,255,.5) !important; }

.logout-btn {
  color: rgba(255,255,255,.4);
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
  transition: all .2s;
}
.logout-btn:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all .2s;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text); }

.topbar-search { flex: 1; max-width: 400px; }

.search-wrapper { position: relative; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-wrapper input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  transition: all .2s;
  outline: none;
}

.search-wrapper input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}
.search-results.show { display: block; }
.search-result-item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  transition: background .15s;
}
.search-result-item:hover { background: var(--bg); }
.search-result-item:last-child { border-bottom: none; }

.topbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* ── Flash Messages ── */
.flash-container { padding: 12px 24px 0; }
.flash-container .alert { border-radius: var(--radius); border: none; }

/* ── Content Wrapper ── */
.content-wrapper { padding: 24px; flex: 1; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Cards ── */
.card-modern {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-modern-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-modern-header h5 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.card-modern-body { padding: 20px; }

/* ── Stat Cards ── */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-blue .stat-icon { background: rgba(26,86,219,.1); color: var(--primary); }
.stat-gold .stat-icon { background: rgba(245,158,11,.1); color: var(--gold); }
.stat-green .stat-icon { background: rgba(34,197,94,.1); color: var(--success); }
.stat-red .stat-icon { background: rgba(239,68,68,.1); color: var(--danger); }

.stat-number { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── Form Cards ── */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all .2s;
  overflow: hidden;
}
.form-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #c7d8f5; }

.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.form-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}

.form-card-body { padding: 0 16px 12px; }
.form-card-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; color: var(--text); }
.form-card-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.form-card-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }

.form-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Badges ── */
.status-ativo { background: rgba(34,197,94,.15); color: #16a34a; border: none; }
.status-encerrado { background: rgba(100,116,139,.15); color: #475569; border: none; }

.badge-role-super_admin { background: rgba(245,158,11,.15); color: var(--gold-dark); }
.badge-role-admin { background: rgba(99,102,241,.15); color: #4f46e5; }
.badge-role-user { background: rgba(100,116,139,.15); color: #475569; }

/* ── Tables ── */
.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.table td { padding: 12px 16px; vertical-align: middle; font-size: 14px; }
.table-hover tbody tr:hover { background: rgba(26,86,219,.03); }
.btn-xs { padding: 3px 8px; font-size: 12px; }

/* ── Auth ── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f2044 0%, #1a56db 100%);
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { width: 56px; height: 56px; margin-bottom: 12px; }

.auth-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.2;
}
.auth-title span { color: var(--primary); }
.auth-subtitle { font-size: 14px; color: var(--text-muted); margin: 0; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.btn-google {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  transition: all .2s;
}
.btn-google:hover { background: var(--bg); box-shadow: var(--shadow-md); }
.google-icon { flex-shrink: 0; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--primary); font-weight: 500; }

/* ── Buttons ── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ── Log items ── */
.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.log-item:last-child { border-bottom: none; }
.log-icon { color: var(--primary); font-size: 10px; }
.log-action { font-size: 13px; font-weight: 500; }
.log-time { font-size: 11px; }

/* ── Avatar ── */
.user-avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Empty State ── */
.empty-state { color: var(--text-muted); }

/* ── Landing Page ── */
.landing-page { min-height: 100vh; background: linear-gradient(160deg, #f8faff 0%, #eef4ff 100%); }

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 48px;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.landing-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text);
}
.landing-nav-actions { display: flex; gap: 8px; }

.landing-hero {
  display: flex;
  align-items: center;
  gap: 48px;
  padding: 80px 48px;
  max-width: 1100px;
  margin: 0 auto;
}

.landing-hero-content { flex: 1; }

.hero-badge {
  display: inline-block;
  background: rgba(26,86,219,.1);
  color: var(--primary);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.hero-title { font-size: 48px; font-weight: 800; line-height: 1.1; margin: 0 0 16px; color: var(--text); }
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.hero-subtitle { font-size: 18px; color: var(--text-muted); margin: 0 0 32px; max-width: 500px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-visual { flex: 1; display: flex; justify-content: center; }

.hero-card-preview {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 320px;
  overflow: hidden;
}
.preview-header {
  display: flex; gap: 6px; padding: 12px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.preview-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.preview-dot.red { background: #ef4444; }
.preview-dot.yellow { background: #f59e0b; }
.preview-dot.green { background: #22c55e; }
.preview-body { padding: 20px; }
.preview-form-title { font-weight: 700; font-size: 14px; margin-bottom: 16px; color: var(--primary); }
.preview-field {
  height: 10px; background: var(--border); border-radius: 6px; margin-bottom: 10px; width: 100%;
  animation: pulse 2s ease-in-out infinite alternate;
}
.preview-field.short { width: 60%; }
.preview-field.medium { width: 80%; }
.preview-btn {
  background: var(--primary); color: white; border-radius: 8px; padding: 10px;
  text-align: center; font-size: 12px; font-weight: 600; margin-top: 16px;
}
@keyframes pulse { from { opacity: .6; } to { opacity: 1; } }

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  padding: 0 48px 80px;
  max-width: 1100px;
  margin: 0 auto;
}
.feature-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all .2s;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.feature-icon { font-size: 32px; margin-bottom: 12px; }
.feature-card h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; color: var(--text); }
.feature-card p { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.6; }

/* ── Error pages ── */
.error-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 40px;
  background: var(--bg);
}
.error-code {
  font-size: 120px; font-weight: 800;
  color: var(--primary); line-height: 1; margin-bottom: 16px;
  opacity: .15;
}

/* ── Sidebar collapsed (mobile) ── */
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
.sidebar-collapsed .sidebar-title,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .nav-section-label,
.sidebar-collapsed .user-details { display: none; }
.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed); }

/* ── Toast ── */
.app-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: white;
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(20px);
  opacity: 0;
  transition: all .3s ease;
  max-width: 340px;
}
.app-toast.show { transform: translateY(0); opacity: 1; }
.app-toast.toast-success { border-color: var(--success); }
.app-toast.toast-danger { border-color: var(--danger); }
.app-toast.toast-warning { border-color: var(--warning); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .content-wrapper { padding: 16px; }
  .hero-title { font-size: 32px; }
  .landing-hero { flex-direction: column; padding: 40px 24px; }
  .landing-nav { padding: 12px 20px; }
  .landing-features { padding: 0 24px 40px; }
  .hero-visual { display: none; }
}

/* ── Upload area ── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: rgba(26,86,219,.04);
}
.upload-area p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* ── Fields List ── */
.fields-list { display: flex; flex-direction: column; gap: 8px; }

.field-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: grab;
  transition: all .2s;
}
.field-item:hover { box-shadow: var(--shadow-md); border-color: #c7d8f5; }

.field-drag-handle { color: var(--text-muted); cursor: grab; }
.field-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(26,86,219,.1); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.field-info { flex: 1; }
.field-name { font-size: 14px; font-weight: 600; }
.field-meta { font-size: 12px; color: var(--text-muted); }
.field-actions { display: flex; gap: 6px; }
.field-required { font-size: 10px; background: rgba(239,68,68,.1); color: var(--danger); padding: 2px 6px; border-radius: 4px; }

/* ── Form label required ── */
.form-label.required::after { content: ' *'; color: var(--danger); }

/* ── Sticky sidebar on desktop ── */
@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
}
