/* SET-BC Forms Hub — matches ProD / staff form theme */

:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-muted: #F9F9F9;
  --border: #D2D2D2;
  --divider: #E5E5E5;
  --text: #222222;
  --text-title: #3C3C3C;
  --text-muted: #595959;
  --focus: #2EB79F;
  --focus-glow: rgba(46, 183, 159, 0.25);
  --primary: #2F6F9E;
  --primary-hover: #275d85;
  --secondary-bg: #F5F5F5;
  --secondary-border: #D2D2D2;
  --secondary-text: #444444;
  --badge-bg: #E8F2F8;
  --badge-text: #1e4d6b;
  --app-max: 1100px;
  --gutter: 30px;
  --btn-radius: 8px;
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  z-index: 20;
}
.skip-link:focus { top: 12px; }

a { color: var(--primary); }
a:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.nav-auth-btn:focus-visible,
.nav-sign-out-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-glow);
}

.app-header {
  background: #fff;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 0 0;
}

.app-container {
  width: 100%;
  max-width: var(--app-max);
  margin-inline: auto;
  padding-inline: calc(var(--gutter) + env(safe-area-inset-left, 0px)) calc(var(--gutter) + env(safe-area-inset-right, 0px));
}

.header-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.header-logo-img {
  height: 52px;
  width: auto;
  display: block;
  object-fit: contain;
}

.header-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-title);
}

.header-nav { display: flex; gap: 4px; flex-wrap: wrap; }

.nav-link,
.nav-auth-btn,
.nav-sign-out-btn {
  color: var(--text-muted);
  text-decoration: none;
  padding: 10px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 4px;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-link:hover,
.nav-auth-btn:hover,
.nav-sign-out-btn:hover { color: var(--text); background: var(--surface-muted); }
.nav-link.active {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
  border-radius: 0;
}

.app-main {
  flex: 1;
  padding-block: 24px 48px;
}

.hero h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-title);
  margin-bottom: 8px;
}
.hero p { margin-bottom: 8px; max-width: 68ch; }
.muted { color: var(--text-muted); }

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-title);
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}

.card-grid {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.id-badge {
  align-self: flex-start;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.form-card h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 6px;
}

.card-desc {
  color: var(--text-muted);
  font-size: 15px;
  flex: 1;
  margin-bottom: 14px;
}

.card-actions { margin-bottom: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  min-height: 44px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }


/* ── Card top: badge + admin pill row ─────────────────────────────── */
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.card-top .id-badge { margin-bottom: 0; }

/* ── Admin pill ───────────────────────────────────────────────────── */
.admin-pill {
  flex: 0 0 auto;
  align-self: flex-start;
  background: #FEF3C7;
  color: #92400E;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.admin-pill:hover { background: #FDE68A; color: #78350F; }

/* ── My Applications / Submitted section ─────────────────────────── */
.submitted-msg {
  font-size: 15px;
  max-width: 68ch;
  margin-top: 8px;
}
.submitted-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.submitted-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
}
.submitted-app-badge {
  flex: 0 0 auto;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.submitted-item-link {
  font-weight: 600;
  flex: 1 1 auto;
}
.submitted-item-date {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  margin-left: auto;
}
.submitted-unavail {
  margin-top: 12px;
  font-size: 13px;
}


.app-footer {
  border-top: 1px solid var(--divider);
  padding: 16px 0 calc(20px + env(safe-area-inset-bottom, 0px));
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  :root { --gutter: 20px; }
  .header-title-row {
    align-items: stretch;
    gap: 8px;
    padding-bottom: 8px;
  }
  .page-title { width: 100%; }
  .header-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .nav-link,
  .nav-auth-btn,
  .nav-sign-out-btn {
    width: 100%;
    justify-content: center;
    padding-inline: 10px;
  }
  .app-main { padding-block: 18px 36px; }
  .card-actions .btn { width: 100%; }
}

@media (max-width: 400px) {
  .header-nav { grid-template-columns: 1fr; }
}

@media (min-width: 640px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .card-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* Re-assert shell gutters last */
.app-container {
  padding-inline: calc(var(--gutter) + env(safe-area-inset-left, 0px)) calc(var(--gutter) + env(safe-area-inset-right, 0px));
}

/* =========================================================================
   Auth nav additions
   ========================================================================= */

.nav-user-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.nav-user-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* =========================================================================
   Form card top row (id-badge + admin pill)
   ========================================================================= */

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-top .id-badge {
  margin-bottom: 0;
}

/* =========================================================================
   Admin pill
   ========================================================================= */

.admin-pill {
  align-self: flex-start;
  background: #E4F5EF;
  color: #1a6a54;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 10px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.6;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.admin-pill:hover {
  background: #C4EAD9;
  color: #124d3c;
}

.admin-pill:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-glow);
}

/* =========================================================================
   Auth modal
   ========================================================================= */

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-modal[hidden] { display: none; }

.modal-inner {
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px 28px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-muted); color: var(--text); }

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal-desc strong { color: var(--text); }

.modal-error {
  font-size: 14px;
  color: #b91c1c;
  background: #fff1f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

/* Auth form fields */
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-title);
  margin-bottom: 6px;
}

.field-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  margin-bottom: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.field-otp {
  letter-spacing: 10px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn-full { width: 100%; }

.modal-footer-links {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  padding: 6px 4px;
  border-radius: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--primary-hover); }
.link-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* =========================================================================
   My submitted applications section
   ========================================================================= */

.my-apps-section[hidden] { display: none; }

.app-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.app-loading,
.app-empty {
  color: var(--text-muted);
  font-size: 15px;
  padding: 16px 0;
}

.app-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--focus);
  border-radius: 8px;
  align-items: start;
}

.app-item-top {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-status {
  font-size: 12px;
  font-weight: 700;
  color: #1a6a54;
  background: #E4F5EF;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.app-title {
  grid-column: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-title);
}

.app-view-link {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.app-view-link:hover { text-decoration: underline; }

/* =========================================================================
   Responsive adjustments for new elements
   ========================================================================= */

@media (max-width: 760px) {
  .nav-user-email { max-width: 140px; font-size: 12px; }

  .modal-inner {
    padding: 24px 18px 20px;
    border-radius: 10px;
  }

  .app-item {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .app-view-link {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-width: 400px) {
  .modal-footer-links { flex-direction: column; gap: 4px; }
}
