/* =========================================================================
   Certificate Studio — design system
   Premium "award studio" aesthetic: cool paper surfaces, indigo-violet
   primary, warm gold accent, Plus Jakarta Sans UI + Fraunces display.
   ========================================================================= */

:root {
  /* Ink & neutrals */
  --ink: #14152b;
  --ink-soft: #3a3b52;
  --muted: #71728c;
  --faint: #9a9bb2;
  --line: #e8e7f0;
  --line-strong: #d7d6e4;
  --bg: #f4f3f9;
  --surface: #ffffff;
  --surface-2: #faf9fd;

  /* Brand */
  --primary: #5446e6;
  --primary-600: #4538cf;
  --primary-700: #392db0;
  --primary-50: #eeebfe;
  --primary-100: #e0dcfd;
  --accent: #e0a23a;
  --accent-soft: #f8ecd4;

  /* Status */
  --success: #16a34a;
  --success-bg: #e7f6ee;
  --danger: #e0483b;
  --danger-bg: #fdecea;
  --warn: #c87d04;
  --warn-bg: #fbf0d8;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(20, 21, 43, .06), 0 1px 3px rgba(20, 21, 43, .05);
  --shadow-md: 0 4px 12px rgba(20, 21, 43, .08), 0 2px 4px rgba(20, 21, 43, .04);
  --shadow-lg: 0 18px 48px rgba(20, 21, 43, .16), 0 6px 16px rgba(20, 21, 43, .08);
  --shadow-pop: 0 24px 60px rgba(20, 21, 43, .22);
  --grad-brand: linear-gradient(135deg, #7b6bf3 0%, #5446e6 45%, #3a2db4 100%);
  --grad-soft: linear-gradient(135deg, #f3f0ff 0%, #faf7ff 100%);

  /* Geometry */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --font-ui: 'Google Sans', 'Product Sans', 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Google Sans', 'Product Sans', 'Roboto', system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

::selection { background: var(--primary-100); }

h1, h2, h3, h4 { line-height: 1.18; color: var(--ink); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(84, 70, 230, .28);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-600); box-shadow: 0 10px 22px rgba(84, 70, 230, .34); }

.btn-outline { border-color: var(--line-strong); background: var(--surface); color: var(--ink-soft); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.95); }

.btn-danger-soft { background: var(--danger-bg); color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: #fbded9; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }
/* Keep inline SVG icons inside buttons at a sensible size (they have no
   intrinsic width/height, so otherwise they balloon to fill the button). */
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-icon svg { width: 18px; height: 18px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.label .req { color: var(--danger); margin-left: 2px; }

.input, .textarea, .select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371728c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; min-height: 0; }
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Password field with show/hide eye */
.pw-field { position: relative; }
.pw-field .input { padding-right: 42px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.pw-eye:hover { background: var(--surface-2); color: var(--ink); }
.pw-eye svg { width: 18px; height: 18px; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 22px; background: var(--line-strong); border-radius: 999px; transition: background .18s; }
.switch .thumb { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .18s; }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track + .thumb { transform: translateX(18px); }

/* ---------- Image picker ---------- */
.img-pick { position: relative; width: 110px; height: 110px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); cursor: pointer; overflow: hidden; transition: border-color .15s, background .15s; }
.img-pick:hover { border-color: var(--primary); background: var(--primary-50); }
.img-pick.has { border-style: solid; border-color: var(--line); background: #fff; }
.img-pick.loading { opacity: .6; pointer-events: none; }
.img-pick img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.img-pick .img-add { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.img-pick .img-add svg { width: 22px; height: 22px; opacity: .8; }
.img-pick .img-x { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(20,21,43,.6); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.img-pick .img-x:hover { background: var(--danger); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.primary { background: var(--primary-50); color: var(--primary-600); border-color: transparent; }
.badge.neutral { background: #eef0f4; color: var(--muted); border-color: transparent; }
.badge.role-admin { background: #efe9ff; color: #6b4bd8; border-color: transparent; }
.badge.role-event_manager { background: #e3f1ff; color: #2b76c4; border-color: transparent; }
.badge.role-team_member { background: #e9f6ef; color: #1d9a5b; border-color: transparent; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--primary-50);
  color: var(--primary-600);
  border: 1px solid var(--primary-100);
}
.chip .x { cursor: pointer; opacity: .6; font-weight: 700; }
.chip .x:hover { opacity: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--ink-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .strong { color: var(--ink); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 21, 43, .42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  width: 100%; max-width: 520px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  transform: translateY(12px) scale(.985);
  transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.modal-overlay.open .modal { transform: none; }
.modal.lg { max-width: 760px; }
.modal.xl { max-width: 1000px; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-head h3 { font-size: 18px; }
.modal-head .sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Toast ---------- */
#toast-host { position: fixed; bottom: 22px; right: 22px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 380px;
  transform: translateX(120%); opacity: 0;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .3s;
}
.toast.show { transform: none; opacity: 1; }
.toast.success { background: #14693f; }
.toast.error { background: #b5392d; }
.toast .ic { font-size: 16px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 17px; }
.empty p { max-width: 380px; margin: 0 auto 18px; font-size: 14px; }

/* ---------- Spinner ---------- */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--line-strong); border-top-color: var(--primary); }
.spinner-lg { width: 38px; height: 38px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 60px; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.hidden { display: none !important; }
.grow { flex: 1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =========================================================================
   App shell (dashboard + event pages)
   ========================================================================= */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: 64px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad-brand);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 14px rgba(84,70,230,.35);
}
.brand .mark svg { width: 19px; height: 19px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; display: block; }
.topbar .spacer { flex: 1; }

.usermenu { position: relative; }
.usermenu .trigger { display: flex; align-items: center; gap: 9px; padding: 5px 9px 5px 5px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.usermenu .trigger:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad-brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.usermenu .who { text-align: left; line-height: 1.15; }
.usermenu .who .n { display: block; font-size: 13px; font-weight: 700; }
.usermenu .who .r { display: block; font-size: 11px; color: var(--muted); text-transform: capitalize; }
@media (max-width: 600px) { .usermenu .who { display: none; } }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  width: 210px; padding: 7px; opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .15s, transform .15s; z-index: 60;
}
.dropdown.open { opacity: 1; transform: none; pointer-events: auto; }
.dropdown .item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px; font-size: 14px; color: var(--ink-soft); width: 100%; background: none; border: none; text-align: left; }
.dropdown .item:hover { background: var(--surface-2); color: var(--ink); }
.dropdown .item svg { width: 16px; height: 16px; flex-shrink: 0; }
.dropdown .item.danger { color: var(--danger); }
.dropdown .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dropdown .head { padding: 9px 11px 7px; }
.dropdown .head .n { font-weight: 700; font-size: 14px; }
.dropdown .head .e { font-size: 12px; color: var(--muted); }

.nav-tabs { display: flex; gap: 4px; }
.nav-tabs a { padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); transition: background .15s, color .15s; }
.nav-tabs a:hover { background: var(--surface-2); color: var(--ink); }
.nav-tabs a.active { background: var(--primary-50); color: var(--primary-600); }

.content { flex: 1; padding: 30px 24px 60px; max-width: 1240px; margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.site-footer { padding: 22px; color: var(--faint); font-size: 13px; border-top: 1px solid var(--line); }
.powered { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--faint); font-size: 13px; }
.powered a { display: inline-flex; align-items: center; transition: opacity .15s; }
.powered a:hover { opacity: .7; }
.powered-logo { height: 19px; width: auto; display: block; }

/* ---------- Event cards grid ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.event-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .18s ease, border-color .18s ease;
  display: flex; flex-direction: column; cursor: pointer;
}
.event-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.event-card { padding: 18px; }
.event-card .ec-top { display: flex; align-items: center; gap: 13px; margin-bottom: 13px; }
.event-card .ec-logo { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); padding: 6px; flex-shrink: 0; }
.event-card .ec-logo-ph { display: grid; place-items: center; color: var(--primary); background: var(--primary-50); border-color: var(--primary-100); }
.event-card .ec-logo-ph svg { width: 24px; height: 24px; }
.event-card .ec-titles { min-width: 0; flex: 1; }
.event-card h3 { font-size: 16.5px; letter-spacing: -.01em; }
.event-card .ec-date { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.event-card .ec-date svg { width: 14px; height: 14px; }
.event-card .desc { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.event-card .meta { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.event-card .meta .m { display: flex; align-items: center; gap: 6px; }
.event-card .meta svg { width: 15px; height: 15px; opacity: .8; }

/* ---------- copy link bar ---------- */
.linkbar { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 6px 6px 12px; }
.linkbar code { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
