/* ==========================================================================
   TC Strava Challenges — Enterprise Styles
   Version: 4.0.0
   ========================================================================== */

/* ==========================================================================
   1) Shell — Background isolation from theme
   ========================================================================== */
.tcsc-shell {
  background: #f6f7f9;
  border-top: 1px solid #e6e8ec;
  border-bottom: 1px solid #e6e8ec;
  padding: 26px 16px;
}

/* ==========================================================================
   2) Neutral .tcsc container — No mega card
   ========================================================================== */
.tcsc {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  color: var(--tcsc-text, #1e293b);
}

/* ==========================================================================
   3) Typography hierarchy
   ========================================================================== */
.tcsc > h3 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--tcsc-text, #1e293b);
}

.tcsc > h4,
.tcsc h4 {
  margin: 22px 0 10px;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--tcsc-text, #1e293b);
}

.tcsc > p,
.tcsc p {
  margin: 0 0 10px;
  color: var(--tcsc-text-muted, #64748b);
  font-size: 14px;
}

.tcsc p strong {
  color: var(--tcsc-text, #1e293b);
}

.tcsc > h4 > a,
.tcsc h4 > a {
  color: inherit;
  text-decoration: none;
}

.tcsc > h4 > a:hover,
.tcsc h4 > a:hover {
  text-decoration: underline;
}

.tcsc > h4 > a small,
.tcsc h4 > a small,
.tcsc h4 small {
  display: inline-block;
  margin-left: 8px;
  font-weight: 500;
  font-size: 12px;
  color: var(--tcsc-text-muted, #64748b);
}

/* ==========================================================================
   4) Buttons — Normalized sizing
   ========================================================================== */
.tcsc .button,
.tcsc a.button,
.tcsc button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--tcsc-border, #e2e8f0);
  background: #fff;
  color: #0f172a;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tcsc .button:hover,
.tcsc a.button:hover,
.tcsc button.button:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  text-decoration: none;
}

.tcsc .button:focus,
.tcsc a.button:focus,
.tcsc button.button:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

/* Primary button */
.tcsc .button-primary,
.tcsc a.button-primary,
.tcsc button.button-primary {
  background: var(--tcsc-primary, #2563eb);
  border-color: var(--tcsc-primary, #2563eb);
  color: #fff;
}

.tcsc .button-primary:hover,
.tcsc a.button-primary:hover,
.tcsc button.button-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

/* First button in a button pair — make it primary */
.tcsc > p a.button:first-child {
  background: var(--tcsc-primary, #2563eb);
  border-color: var(--tcsc-primary, #2563eb);
  color: #fff;
}

.tcsc > p a.button:first-child:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

/* Delete button */
.tcsc .button-link-delete,
.tcsc button.button-link-delete {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.tcsc .button-link-delete:hover,
.tcsc button.button-link-delete:hover {
  background: #fee2e2;
  border-color: #f87171;
}

/* ==========================================================================
   5) Panel style for .tcsc-table-wrapper
   ========================================================================== */
.tcsc .tcsc-table-wrapper {
  background: #fff;
  border: 1px solid var(--tcsc-border, #e2e8f0);
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0 0;
  overflow: visible;
}

/* Leaderboard may need horizontal scroll on desktop */
.tcsc .tcsc-table-wrapper--leaderboard {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   6) Front-end table restyle — Override widefat/striped
   ========================================================================== */
.tcsc table.widefat,
.tcsc table.widefat.striped {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
  border: 0;
  margin: 0;
}

.tcsc table.widefat thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tcsc-text-muted, #64748b);
  background: var(--tcsc-background-alt, #f8fafc);
  padding: 10px 12px;
  border-bottom: 1px solid var(--tcsc-border, #e2e8f0);
  white-space: nowrap;
  font-weight: 600;
  text-align: left;
}

.tcsc table.widefat thead th a {
  color: inherit;
  text-decoration: none;
}

.tcsc table.widefat thead th a:hover {
  text-decoration: underline;
}

.tcsc table.widefat thead th small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.7;
  margin-top: 2px;
}

.tcsc table.widefat tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--tcsc-border, #e2e8f0);
  font-size: 14px;
  vertical-align: middle;
  background: transparent !important;
  color: var(--tcsc-text, #1e293b);
}

.tcsc table.widefat tbody tr:last-child td {
  border-bottom: 0;
}

/* Kill admin striping */
.tcsc table.widefat.striped tbody tr:nth-child(odd) td,
.tcsc table.widefat.striped tbody tr:nth-child(even) td {
  background: transparent !important;
}

/* Hover state */
.tcsc table.widefat tbody tr:hover td {
  background: var(--tcsc-background-hover, #f1f5f9) !important;
}

/* Rank column */
.tcsc .tcsc-rank {
  width: 48px;
  font-weight: 700;
  text-align: center;
  color: var(--tcsc-text-muted, #64748b);
}

/* Time column — monospace for alignment */
.tcsc .tcsc-time {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  white-space: nowrap;
}

/* Links in tables */
.tcsc table.widefat tbody td a {
  color: var(--tcsc-primary, #2563eb);
  text-decoration: none;
}

.tcsc table.widefat tbody td a:hover {
  text-decoration: underline;
}

/* Empty cell */
.tcsc .tcsc-empty-cell {
  text-align: center;
  color: var(--tcsc-text-muted, #64748b);
  font-style: italic;
  padding: 24px 12px !important;
}

/* ==========================================================================
   7) Badges
   ========================================================================== */
.tcsc-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tcsc-badge-count {
  background: #eff6ff;
  color: #2563eb;
}

.tcsc-badge-cleared {
  background: #ecfdf5;
  color: #059669;
}

.tcsc-badge-pending {
  background: #f1f5f9;
  color: #64748b;
}

/* ==========================================================================
   8) Activity picker
   ========================================================================== */
.tcsc-activity-picker {
  background: #fff;
  border: 1px solid var(--tcsc-border, #e2e8f0);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

.tcsc-activity-picker .tcsc-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.tcsc-activity-picker select {
  min-width: 200px;
  max-width: 100%;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border: 1px solid var(--tcsc-border, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  color: var(--tcsc-text, #1e293b);
}

.tcsc-activity-picker select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.tcsc-activity-picker input[type="text"] {
  flex: 1;
  min-width: 200px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border: 1px solid var(--tcsc-border, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  color: var(--tcsc-text, #1e293b);
}

.tcsc-activity-picker input[type="text"]:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
  border-color: #2563eb;
}

.tcsc-activity-picker input[type="text"]::placeholder {
  color: #94a3b8;
}

.tcsc-activity-picker .tcsc-help {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--tcsc-text-muted, #64748b);
}

.tcsc-activity-picker form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--tcsc-border, #e2e8f0);
}

/* ==========================================================================
   9) Notices
   ========================================================================== */
.tcsc-notice {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 10px;
  border-left: 4px solid #3b82f6;
  background: #eff6ff;
  font-size: 13px;
  color: var(--tcsc-text, #1e293b);
}

.tcsc-notice.tcsc-error {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.tcsc-notice.tcsc-warn {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

/* ==========================================================================
   10) Actions column
   ========================================================================== */
.tcsc-actions {
  white-space: nowrap;
}

.tcsc-actions form {
  display: inline-block;
  margin-right: 6px;
}

.tcsc-actions form:last-child {
  margin-right: 0;
}

/* ==========================================================================
   11) Empty state
   ========================================================================== */
.tcsc-empty {
  text-align: center;
  padding: 20px;
  color: var(--tcsc-text-muted, #64748b);
  font-size: 14px;
}

/* ==========================================================================
   E1) Mobile — Segment tables become row cards
   ========================================================================== */
@media (max-width: 768px) {
  .tcsc-shell {
    padding: 16px 12px;
  }

  .tcsc > h3 {
    font-size: 18px;
  }

  .tcsc h4 {
    font-size: 14px;
    margin: 18px 0 8px;
  }

  .tcsc .tcsc-table-wrapper {
    padding: 8px;
    border-radius: 12px;
  }

  /* Segment tables: row card layout */
  .tcsc .tcsc-table-wrapper--segment table.widefat thead {
    display: none;
  }

  .tcsc .tcsc-table-wrapper--segment table.widefat tbody tr {
    display: block;
    border: 1px solid var(--tcsc-border, #e2e8f0);
    border-radius: 10px;
    padding: 12px;
    margin: 8px 0;
    background: #fff;
  }

  .tcsc .tcsc-table-wrapper--segment table.widefat tbody tr:hover {
    background: #fff !important;
  }

  .tcsc .tcsc-table-wrapper--segment table.widefat tbody td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: 0;
    font-size: 13px;
  }

  .tcsc .tcsc-table-wrapper--segment table.widefat tbody td::before {
    content: attr(data-label);
    flex: 0 0 80px;
    color: var(--tcsc-text-muted, #64748b);
    font-weight: 600;
    font-size: 12px;
  }

  .tcsc .tcsc-table-wrapper--segment table.widefat tbody td:first-child {
    padding-top: 0;
  }

  .tcsc .tcsc-table-wrapper--segment table.widefat tbody td:last-child {
    padding-bottom: 0;
  }

  /* Hide rank on mobile cards — redundant */
  .tcsc .tcsc-table-wrapper--segment table.widefat tbody td.tcsc-rank {
    display: none;
  }

  /* ==========================================================================
     E2) Leaderboard on mobile — Hide segment columns
     ========================================================================== */
  .tcsc .tcsc-table-wrapper--leaderboard table.widefat thead th.tcsc-segment-col,
  .tcsc .tcsc-table-wrapper--leaderboard table.widefat tbody td.tcsc-segment-col {
    display: none !important;
  }

  /* Leaderboard keeps table layout but with tighter spacing */
  .tcsc .tcsc-table-wrapper--leaderboard table.widefat thead th,
  .tcsc .tcsc-table-wrapper--leaderboard table.widefat tbody td {
    padding: 8px 6px;
    font-size: 12px;
  }

  .tcsc .tcsc-table-wrapper--leaderboard table.widefat thead th {
    font-size: 10px;
  }

  /* Activity picker responsive */
  .tcsc-activity-picker {
    padding: 12px;
  }

  .tcsc-activity-picker .tcsc-row {
    flex-direction: column;
    align-items: stretch;
  }

  .tcsc-activity-picker select,
  .tcsc-activity-picker input[type="text"] {
    min-width: 100%;
  }

  /* Buttons in actions column stack on mobile */
  .tcsc-actions form {
    display: block;
    margin: 0 0 6px;
  }

  .tcsc-actions form:last-child {
    margin-bottom: 0;
  }
}

/* ==========================================================================
   Extra small screens
   ========================================================================== */
@media (max-width: 480px) {
  .tcsc .button,
  .tcsc a.button,
  .tcsc button.button {
    width: 100%;
    justify-content: center;
  }

  .tcsc > p a.button {
    margin-bottom: 8px;
  }

  .tcsc > p a.button:last-child {
    margin-bottom: 0;
  }
}
