/* =========================================================
   RaceTime — Running Race Management Platform
   Global stylesheet for login + client area (director portal)
   Path: /members/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: var(--pad);
  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 ---------- */
.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; }

/* ---------- Team Captain link ---------- */
a.cptn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem .7rem;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--subtle);
  text-decoration: none;
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .06s ease;
}
a.cptn:hover {
  background: var(--accent-soft);
  color: var(--text);
  border-color: #2c3340;
}
a.cptn:active {
  transform: translateY(1px);
}

/* container to center the cptn button */
.div-cptn {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: .5rem 0;
}

/* ---------- 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;
  pointer-events: none;
  transform: none !important;
}

/* 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; }

/* ---------- Aligned button row ---------- */
.btn-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- 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;
  align-items: center; /* ensure buttons align on same line */
}
.form-2 { grid-template-columns: 1fr 1fr; }
.form-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 640px) { /* adjusted breakpoint */
  .form-3 { grid-template-columns: 1fr; }
}

/* Input add-ons */
.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: #946108; color: #fbbf24; }
.badge.danger { border-color: #6b1111; color: #ef4444; }

/* ---------- Tables ---------- */
.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 tbody tr:hover td { background: #0f1218; }

/* ---------- Panels ---------- */
.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 ---------- */
.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: 50px;
  border-radius: 9px;
}

/* ---------- Focus-visible ---------- */
:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.4);
  outline-offset: 2px;
}

/* =========================================================
   Event Control Buttons
   ========================================================= */
.btn-event {
  font-weight: 600;
  border-radius: 12px;
  padding: .65rem 1.1rem;
  transition: background .15s ease, transform .05s ease;
}
.btn-event.close {
  background: var(--danger);
  color: #fff;
}
.btn-event.close:hover { background: #b91c1c; }
.btn-event.reopen {
  background: var(--ok);
  color: #fff;
}
.btn-event.reopen:hover { background: #15803d; }

/* =========================================================
   Export Modal
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  z-index: 1000;
  animation: modalFadeIn .12s ease-out;
}
.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;
}
.modal h3 { margin: 0 0 6px 0; }
.modal p.small { margin: 0 0 10px 0; }
.modal label { display: block; margin-bottom: 6px; }
.modal select, .modal input[type="text"] {
  width: 100%;
  padding: .6rem .7rem;
}
.modal .btn { min-width: 110px; }

.btn.outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.outline:hover {
  background: var(--accent-soft);
  border-color: #2c3340;
}
.btn.small {
  padding: .5rem .7rem;
  border-radius: 10px;
  font-size: .92rem;
}

.small { font-size: .9rem; }
.dim { color: var(--subtle); }

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

@media (max-width: 480px) {
  .modal { width: 94vw; padding: 14px 14px; }
}
a {
    color: #ff0000;   /* your preferred color */
}

/* ---------- 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 */
  }
}
