/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --color-primary:       #3b82f6;
  --color-primary-dark:  #2563eb;
  --color-primary-light: #eff6ff;
  --color-secondary:     #64748b;
  --color-success:       #10b981;
  --color-success-light: #d1fae5;
  --color-error:         #ef4444;
  --color-error-light:   #fee2e2;
  --color-info:          #0ea5e9;
  --color-info-light:    #e0f2fe;
  --color-muted:         #94a3b8;
  --color-border:        #e2e8f0;
  --color-bg:            #f1f5f9;
  --color-card:          #ffffff;
  --color-text:          #0f172a;
  --color-text-light:    #64748b;
  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.05), 0 10px 25px rgba(0,0,0,0.08);
  --nav-height: 64px;
  --header-height: 60px;
}

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

/* ─── Base ───────────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

@media (min-width: 640px) {
  header h1 { font-size: 1.4rem; }
}

/* ─── Page content spacing ───────────────────────────────────────────────── */
.container {
  padding-top: 20px;
  padding-bottom: 20px;
}

/* On mobile admin: push content above bottom nav */
body.has-bottom-nav .container {
  padding-bottom: calc(var(--nav-height) + 16px);
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
}

/* ─── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  .card { padding: 24px; }
}

/* ─── Admin Tabs ─────────────────────────────────────────────────────────── */

/* Mobile: fixed bottom nav */
.admin-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  height: var(--nav-height);
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 8px 4px;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  position: relative;
}

.tab-btn::before {
  content: attr(data-icon);
  font-size: 1.35rem;
  line-height: 1;
  display: block;
}

.tab-btn[data-tab="overview"]::before      { content: '⚙️'; }
.tab-btn[data-tab="workshops"]::before     { content: '🎯'; }
.tab-btn[data-tab="organizations"]::before { content: '🏛️'; }
.tab-btn[data-tab="participants"]::before  { content: '👥'; }
.tab-btn[data-tab="guide"]::before         { content: '📖'; }

.tab-btn.active {
  color: var(--color-primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
}

/* Desktop: top tab bar */
@media (min-width: 640px) {
  .admin-tabs {
    position: static;
    border-top: none;
    border-bottom: 1px solid var(--color-border);
    box-shadow: none;
    height: auto;
    padding: 0;
    background: transparent;
    gap: 4px;
    margin-bottom: 20px;
  }

  .tab-btn {
    flex: unset;
    flex-direction: row;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--color-text-light);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
  }

  .tab-btn::before {
    font-size: 1rem;
  }

  .tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--color-card);
  }

  .tab-btn.active::after { display: none; }

  .tab-btn:hover:not(.active) {
    color: var(--color-text);
    background: rgba(0,0,0,0.03);
  }

  body.has-bottom-nav .container {
    padding-bottom: 0;
  }
}

/* ─── Form ───────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--color-text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="time"] {
  font-size: 0.9rem;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

input::placeholder { color: var(--color-muted); }

.required { color: var(--color-error); }

.hint {
  font-size: 0.82rem;
  color: var(--color-text-light);
  margin-bottom: 14px;
  line-height: 1.5;
}

fieldset.priorities-fieldset {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

fieldset.priorities-fieldset legend {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 8px;
  color: var(--color-text);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: 0 4px 12px rgba(59,130,246,0.35);
}

.btn-secondary {
  background: white;
  color: var(--color-secondary);
  border: 1.5px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg);
  border-color: #cbd5e1;
}

.btn-danger {
  background: white;
  color: var(--color-error);
  border: 1.5px solid #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Full-width primary on mobile */
@media (max-width: 639px) {
  #registration-form .btn-primary,
  #login-btn {
    width: 100%;
  }
}

/* ─── Banners ────────────────────────────────────────────────────────────── */
.banner {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.banner-info {
  background: var(--color-info-light);
  border: 1px solid #bae6fd;
  color: #075985;
}

.banner-success {
  background: var(--color-success-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.banner-error {
  background: var(--color-error-light);
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.hidden { display: none !important; }

/* ─── Toggle ─────────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── Settings grid ──────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 500px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 760px) {
  .settings-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

/* ─── Stats box ──────────────────────────────────────────────────────────── */
.stats-box {
  margin-top: 16px;
  background: var(--color-primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 16px;
}

.stats-table td {
  padding: 4px 16px 4px 0;
  font-size: 0.875rem;
}

/* ─── Section header ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-header h2 { margin-bottom: 0; }

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--color-primary);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: 0.02em;
}

/* ─── Organizations ──────────────────────────────────────────────────────── */
.orgs-list { margin-bottom: 16px; }

.org-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  gap: 12px;
  transition: background 0.1s;
}

.org-row:nth-child(odd) { background: var(--color-bg); }
.org-row:hover { background: #e8f0fe; }

.org-name {
  font-size: 0.9rem;
  flex: 1;
}

.org-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.org-rename-input {
  flex: 1;
  padding: 6px 10px;
  min-height: 36px;
  font-size: 0.9rem;
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-sm);
  width: auto;
}

.orgs-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.orgs-add-row input {
  flex: 1;
  max-width: 320px;
}

/* ─── Workshops ──────────────────────────────────────────────────────────── */
.workshops-list { margin-bottom: 16px; }

.workshop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--radius-sm);
  gap: 12px;
  transition: background 0.1s;
}

.workshop-row:nth-child(odd) { background: var(--color-bg); }
.workshop-row:hover { background: #e8f0fe; }

.workshop-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

@media (min-width: 500px) {
  .workshop-row-info {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }
}

.workshop-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.workshop-desc {
  font-size: 0.82rem;
  color: var(--color-text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.workshop-slots-count {
  font-size: 0.78rem;
  color: var(--color-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.workshop-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Workshop edit form */
.workshop-edit-form { padding: 12px 0; }

.ws-form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

@media (min-width: 500px) {
  .ws-form-row { grid-template-columns: 1fr 1fr; }
}

.ws-form-row .form-group { margin-bottom: 0; }

.ws-slots-section { margin-bottom: 12px; }

.ws-slots-section > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.ws-slots-list { margin-bottom: 8px; }

.slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

@media (min-width: 500px) {
  .slot-row { flex-wrap: nowrap; }
}

.slot-row:last-child { border-bottom: none; }

.slot-index-label {
  font-size: 0.78rem;
  color: var(--color-muted);
  width: 44px;
  flex-shrink: 0;
}

.slot-time-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}

.slot-time-group input[type="time"] {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 38px;
}

.slot-time-sep {
  font-size: 1rem;
  color: var(--color-muted);
  flex-shrink: 0;
}

.slot-capacity-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.slot-capacity-group label {
  display: inline;
  margin-bottom: 0;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.slot-capacity-group input { width: 68px; min-height: 38px; }

.slot-assign-count {
  font-size: 0.75rem;
  color: var(--color-text-light);
  background: var(--color-bg);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.workshop-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.workshop-add-section {
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
  padding-top: 16px;
}

/* ─── Export ─────────────────────────────────────────────────────────────── */
.export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

@media (max-width: 500px) {
  .export-row { flex-direction: column; }
  .export-row .btn { text-align: center; }
}

/* ─── Participants ───────────────────────────────────────────────────────── */
.participants-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.participants-controls input[type="text"] {
  flex: 1;
  min-width: 140px;
}

.participants-controls select {
  width: auto;
  min-width: 140px;
  flex: 1;
}

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  margin: -1px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  background: var(--color-bg);
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  color: var(--color-text-light);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: #f8faff; }

th.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.th-sortable:hover { color: var(--color-text); }
th.th-sorted { color: var(--color-primary); }

.sort-icon {
  display: inline-block;
  width: 12px;
  font-size: 0.7rem;
  margin-left: 2px;
  color: var(--color-primary);
}

/* ─── Login & Registration forms ─────────────────────────────────────────── */
#login-section,
#registration-form {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  margin-top: 8px;
}

@media (min-width: 480px) {
  #login-section {
    max-width: 380px;
    padding: 32px;
  }

  #registration-form {
    max-width: 580px;
    padding: 32px;
  }
}

#login-section h2,
#registration-form h2 {
  margin-bottom: 20px;
  font-size: 1.15rem;
}

/* ─── User Guide ─────────────────────────────────────────────────────────── */
.guide-section h2 {
  margin-bottom: 20px;
  font-size: 1rem;
}

.guide-block {
  margin-bottom: 20px;
}

.guide-block:last-child { margin-bottom: 0; }

.guide-block h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.guide-block p {
  font-size: 0.875rem;
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: 6px;
}

.guide-block p:last-child { margin-bottom: 0; }

.guide-block ul,
.guide-steps {
  font-size: 0.875rem;
  color: var(--color-text-light);
  line-height: 1.6;
  padding-left: 20px;
  margin-top: 6px;
}

.guide-block ul li,
.guide-steps li {
  margin-bottom: 4px;
}

.guide-steps {
  counter-reset: none;
}

.guide-steps li { padding-left: 4px; }
