/* =========================================================
   RaceTime — Running Race Management Platform
   Global stylesheet for login + client area (director portal)
   Path: /athletes/styles.css
   ========================================================= */

/* ---------- CSS Reset / Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #0b0c10, #0d1117 45%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  /* Palette (dark, professional) */
  --bg: #0b0c10;
  --bg-elev: #0f1218;
  --card: #111317;
  --muted: #98a2b3;
  --text: #e5e7eb;
  --subtle: #cbd5e1;
  --border: #23262d;

  /* Accent & states */
  --accent: #2563eb;         /* primary */
  --accent-weak: #1e40af;    /* darker hover */
  --accent-soft: #1d4ed81a;  /* subtle background */
  --ok: #16a34a;             /* success */
  --warn: #d97706;           /* warning */
  --danger: #ef4444;         /* error */

  --danger-bg: #3b0a0a;
  --danger-br: #5c1717;

  /* Shadow */
  --shadow-1: 0 8px 24px rgba(0,0,0,.25);
  --shadow-2: 0 14px 36px rgba(0,0,0,.35);

  /* Radius & spacing */
  --radius: 16px;
  --radius-sm: 10px;
  --pad: 16px;
  --gap: 12px;
}

/* ---------- Typography ---------- */
h1, h2, h3 { color: var(--text); margin: .2rem 0 .6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p { margin: .25rem 0 .75rem; line-height: 1.5; }
small, .tiny { font-size: .85rem; }
.muted { color: var(--muted); }

/* ---------- Layout helpers ---------- */
.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-1);
}

/* ---------- Top bar (client area) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #0d1117;
  backdrop-filter: saturate(140%) blur(6px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .2px;
}
.brand .logo {
  display: inline-flex;
  height: 70px;
  border-radius: 8px;
}
.user {
  color: var(--muted);
  font-size: .95rem;
}

/* ---------- Navigation (optional) ---------- */
.navbar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.navbar a, .navbar button.nav {
  color: var(--subtle);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.navbar a:hover, .navbar button.nav:hover {
  background: var(--accent-soft);
  color: var(--text);
}
.navbar .active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--border);
}

/* ---------- Hero / section spacing ---------- */
.hero h1 { margin: .2rem 0 .2rem; font-size: 1.7rem; }
.hero .muted { margin-top: .2rem; }
.section { margin-top: 1.25rem; }

/* ---------- Tiles / modules ---------- */
.tile {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform .08s ease, border-color .08s ease, box-shadow .12s ease;
}
.tile:hover {
  border-color: #2c3340;
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.tile h2 { margin: .1rem 0 .35rem; }
.tile p { margin: 0; color: var(--muted); }
.tile .actions { margin-top: 1rem; }

/* ---------- Buttons ---------- */
button, .btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: .7rem .95rem;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
button:hover, .btn:hover { background: var(--accent-weak); }
button:active, .btn:active { transform: translateY(1px); }
button[disabled], .btn[disabled] {
  background: #334155;
  color: #a3a3a3;
  cursor: not-allowed;
}

.flash_success{
  background-color: #2e7d32;
  color: #e9ebe5;
  width: 100%;
  padding: 5px;
  border-radius: 10px;
  font-size: 24px;

  /* Center on page */
  margin: 0 auto;        /* horizontal centering */
  display: block;        /* ensure it's treated as a block */

  /* Center text inside */
  text-align: center;
}

/* Button variants */
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: #2c3340;
}
.btn-danger {
  background: var(--danger);
}
.btn-success {
  background: var(--ok);
}
.btn-warn {
  background: var(--warn);
  color: #111;
}

/* ---------- Forms ---------- */
form { display: grid; gap: .7rem; margin-top: .75rem; }
label { font-size: .95rem; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="tel"],
select, textarea {
  width: 100%;
  padding: .7rem .8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  outline: none;
}
textarea { min-height: 120px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: #2c3340;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.form-row {
  display: grid;
  gap: 12px;
}
.form-2 { grid-template-columns: 1fr 1fr; }
.form-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 780px) {
  .form-2, .form-3 { grid-template-columns: 1fr; }
}

/* Input add-ons (icons/hints) */
.input-wrap {
  position: relative;
}
.input-wrap .hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .9rem;
}

/* ---------- Alerts / badges ---------- */
.alert {
  background: var(--danger-bg);
  border: 1px solid var(--danger-br);
  color: #ffd9d9;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
}
.notice {
  background: rgba(37, 99, 235, .12);
  border: 1px solid #1e40af;
  color: #e0ecff;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.ok {
  background: rgba(22, 163, 74, .16);
  border: 1px solid #166534;
  color: #dcfce7;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--subtle);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: .8rem;
}
.badge.success { border-color: #155e34; color: #22c55e; }
.badge.warn    { border-color: #7c5209; color: #f59e0b; }
.badge.danger  { border-color: #6b1111; color: #ef4444; }

/* ---------- Tables (client area) ---------- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: #0f1420;
  color: var(--subtle);
  font-weight: 600;
  font-size: .92rem;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #0f1218; }

/* ---------- Panels / widgets ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.panel h3 { margin-top: 0; }

/* ---------- Footer (optional) ---------- */
.footer {
  color: var(--muted);
  font-size: .9rem;
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  margin-top: 24px;
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.right { text-align: right; }
.center-text { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: .5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.p-0 { padding: 0 !important; }
.p-1 { padding: .5rem !important; }
.p-2 { padding: 1rem !important; }

/* ---------- Forms: inline help & errors ---------- */
.help { color: var(--muted); font-size: .85rem; }
.error-text { color: var(--danger); font-size: .9rem; }

/* ---------- Login-specific tweaks ---------- */
.login-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: .5rem;
}
.login-brand .logo {
  height: 70px; border-radius: 9px;
}

/* ---------- Focus-visible for accessibility ---------- */
:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.4);
  outline-offset: 2px;
}
/* =========================================================
   Event Control Buttons — Open / Close Registrations
   ========================================================= */

.btn-event {
  font-weight: 600;
  border-radius: 12px;
  padding: .65rem 1.1rem;
  transition: background .15s ease, transform .05s ease;
}

/* --- Close registrations --- */
.btn-event.close {
  background: var(--danger);
  color: #fff;
}
.btn-event.close:hover {
  background: #b91c1c; /* slightly darker red */
}
.btn-event.close:active {
  transform: translateY(1px);
}

/* --- Reopen registrations --- */
.btn-event.reopen {
  background: var(--ok);
  color: #fff;
}
.btn-event.reopen:hover {
  background: #15803d; /* darker green */
}
.btn-event.reopen:active {
  transform: translateY(1px);
}
/* =========================================================
   Export Modal (popup)
   ========================================================= */

/* Backdrop layer */
.modal-backdrop{
  position: fixed;
  inset: 0;
  display: none;                 /* JS sets to flex when open */
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  z-index: 1000;
  animation: modalFadeIn .12s ease-out;
}

/* Modal card */
.modal{
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(520px, 92vw);
  max-height: 88vh;
  padding: 16px 18px;
  box-shadow: var(--shadow-2);
  animation: modalSlideUp .14s ease-out;
  overflow: auto;                /* scroll if content exceeds max-height */
}

.modal h3{ margin: 0 0 6px 0; }
.modal p.small{ margin: 0 0 10px 0; }

/* Make form controls comfy inside modal */
.modal label{ display:block; margin-bottom: 6px; }
.modal select,
.modal input[type="text"]{
  width: 100%;
  padding: .6rem .7rem;
}

/* Button row spacing inside modal */
.modal .btn{ min-width: 110px; }

/* Outline button variant (used by Cancel) */
.btn.outline{
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.outline:hover{
  background: var(--accent-soft);
  border-color: #2c3340;
}

/* Optional: smaller button size */
.btn.small{
  padding: .5rem .7rem;
  border-radius: 10px;
  font-size: .92rem;
}

/* Utility classes used in markup */
.small{ font-size: .9rem; }
.dim{ color: var(--subtle); }

/* Animations */
@keyframes modalFadeIn{
  from{ opacity: 0; } to{ opacity: 1; }
}
@keyframes modalSlideUp{
  from{ transform: translateY(6px); opacity: 0; }
  to{ transform: translateY(0); opacity: 1; }
}

/* Mobile tweaks */
@media (max-width: 480px){
  .modal{ width: 94vw; padding: 14px 14px; }
}
/* --- Form controls hardening for dark theme --- */
.card label { display:block; margin-bottom:12px; }
.card label > input,
.card label > select,
.card label > textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.15);
  background: #111;       /* match dark card */
  color: #eee;
}
.card label > input::placeholder { color: #889; }
.card label > select {
  -webkit-appearance: none;
  appearance: none;
  background-image: none; /* avoid mismatched native arrows on dark bg */
}

/* Two-up rows that don’t break small screens */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
}

/* Improve focus visibility */
.card label > input:focus,
.card label > select:focus,
.card label > textarea:focus {
  outline: 2px solid #2d6cdf;
  outline-offset: 0;
  border-color: #2d6cdf;
}

/* Date input icon visibility on dark background */
input[type="date"] {
  color-scheme: dark;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.google-icon {
  display: inline-flex;
  align-items: center;
}
a[href="/athletes/register.php"] {
    color: #fff !important;
}

a[href="/athletes/register.php"]:hover {
    color: #e6e6e6 !important;
}

/* ---------- Top bar: mobile layout for runner area ---------- */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 10px;
    padding: 10px 14px;
  }

  /* Target the first child wrapper (brand + navbar) */
  .topbar > div:first-child {
    display: flex;          /* already inline, but safe to repeat */
    flex-wrap: wrap;        /* allow brand + nav to wrap */
    gap: 8px;
    flex: 1 1 100%;         /* take full width on small screens */
  }

  .brand {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .brand .logo {
    height: 48px;
    border-radius: 6px;
  }

  /* Nav drops to its own line, full width, scrollable if many items */
  .navbar {
    flex: 1 1 100%;
    order: 2;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .navbar a,
  .navbar button.nav {
    padding: 6px 10px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  /* User block stacks beneath brand+nav */
  .user {
    flex: 1 1 100%;
    text-align: left;
    font-size: 0.85rem;
    margin-left: 0;
    margin-top: 4px;
  }

  .user .btn {
    margin-top: 6px;        /* small breathing room from badges */
  }
}
/* ---------- Responsive table wrappers ---------- */

/* General horizontal scrolling wrapper */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

/* For very wide tables (many columns) – allow horizontal scroll but
   keep panel/container as the "block" visually */
.table-wrap .table {
  min-width: 720px;   /* adjust if needed */
}

/* Variant with vertical max-height (for the big race list) */
.table-wrap.scroll-y {
  max-height: 420px;
  overflow-y: auto;
}
