/* ===============================
   GLOBAL STYLES
=============================== */

* {
  box-sizing: border-box;
}

body {
  background: #f4f5f7;
  margin: 0;
  color: #1f2933;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===============================
   PLANNER CONTAINER
=============================== */

#planner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

h1, h2, h3 {
  margin: 0 0 10px;
  line-height: 1.25;
}

h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; }

.subtitle {
  font-size: 13px;
  color: #4b5563;
  margin: 6px 0 18px;
}

/* ===============================
   PANELS & CARDS
=============================== */

.panel,
.card,
.tier,
details.s1details {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.panel {
  padding: 18px 20px;
  margin-bottom: 22px;
}

.card {
  padding: 14px 16px;
  margin-bottom: 14px;
}

.tier {
  padding: 14px 16px;
  margin: 14px 0;
}

.tier.A { border-left: 6px solid #2e7d32; }
.tier.B { border-left: 6px solid #f9a825; }
.tier.C { border-left: 6px solid #c62828; }

/* Athlete Level Targets */
.athlete-level-targets {
  background: #f0f9ff;
  border: 2px solid #0ea5e9;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.athlete-level-targets h3 {
  margin: 0 0 12px;
  color: #0c4a6e;
  font-size: 16px;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  font-size: 14px;
}

.target-grid div {
  background: white;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #bae6fd;
}

.target-grid strong {
  color: #0369a1;
}

/* ===============================
   COLLAPSIBLE DETAILS
=============================== */

details.s1details {
  margin-bottom: 22px;
  overflow: hidden;
}

details.s1details > summary {
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 750;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

details.s1details > summary:hover {
  background: #f9fafb;
}

.summaryHint {
  font-size: 12px;
  color: #6b7280;
  font-weight: 400;
}

.s1content {
  padding: 0 18px 18px;
}

/* ===============================
   TABLES
=============================== */

.tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th, td {
  border: 1px solid #e5e7eb;
  padding: 7px 8px;
  text-align: center;
}

th {
  background: #f3f4f6;
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

tbody tr.manual-week {
  background: #fffbeb;
}

tbody tr.auto-week {
  background: transparent;
}

/* Form (TSB) critical states */
.form-warning {
  background: #fef3c7 !important;
  font-weight: 700;
}

.form-critical {
  background: #fecaca !important;
  color: #991b1b !important;
  font-weight: 700;
}

/* SLF Badge Styles */
.slf-manual {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
}

.slf-early {
  color: #6b7280;
}

.slf-moderate {
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
}

.slf-strong {
  background: #fecaca;
  color: #991b1b;
  font-weight: 700;
}

.slf-none {
  color: #d1d5db;
}

/* Warning Cell & Button */
.warnings-cell {
  text-align: center;
}

.warning-btn {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.warning-btn:hover {
  background: #fbbf24;
  transform: scale(1.05);
}

.warning-count {
  background: #dc2626;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

tr.has-warnings {
  border-left: 3px solid #f59e0b;
}

/* ===============================
   MODAL OVERLAY & CONTAINER
=============================== */

.tss-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  z-index: 2147483646;
}

.tss-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 2147483647;
  overflow-y: auto;
}

body.tss-modal-open {
  overflow: hidden;
}

.tss-panel {
  max-width: 940px;
  margin: 24px auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.tss-header,
.tss-footer {
  padding: 16px 20px;
  font-weight: 800;
  border-bottom: 1px solid #e5e7eb;
}

.tss-footer {
  border-top: 1px solid #e5e7eb;
  border-bottom: none;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.tss-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
}

/* ===============================
   FORM ELEMENTS
=============================== */

label {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  display: block;
}

select,
input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  font-family: inherit;
}

select:focus,
input:focus {
  outline: none;
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1);
}

.inputs,
.inputs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 1100px) {
  .inputs,
  .inputs-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .inputs,
  .inputs-grid {
    grid-template-columns: 1fr;
  }
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.row3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* ===============================
   PILL BAR (RADIO BUTTONS)
=============================== */

.pillbar {
  display: flex;
  gap: 10px;
}

.pill {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill input {
  display: none;
}

.pill.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.pill:hover:not(.active) {
  background: #f3f4f6;
}

/* ===============================
   ALERTS
=============================== */

.alert {
  border-radius: 12px;
  padding: 12px;
  margin-top: 14px;
}

.alert-info {
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.alert-success {
  background: #ecfff1;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert-danger {
  background: #fff0f0;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* ===============================
   BUTTONS
=============================== */

.tss-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #111827;
  background: #111827;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.tss-btn:hover {
  background: #000;
  border-color: #000;
  transform: translateY(-1px);
}

.tss-btn:active {
  transform: translateY(0);
}

.tss-btn:disabled {
  background: #e5e7eb;
  border-color: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.tss-btn.secondary {
  background: #fff;
  color: #111827;
}

.tss-btn.secondary:hover {
  background: #f3f4f6;
}

/* ===============================
   TSS RANGE DISPLAY
=============================== */

.tss-range {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

/* ===============================
   SYNC ANIMATION
=============================== */

@keyframes syncPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.sync-ok {
  background: #d1fae5 !important;
  color: #065f46 !important;
  animation: syncPulse 0.6s ease-out;
}

/* ===============================
   UTILITY CLASSES
=============================== */

.small {
  font-size: 12px;
}

.muted {
  color: #6b7280;
}

/* ===============================
   RESPONSIVE DESIGN
=============================== */

@media (max-width: 1000px) {
  #planner {
    padding: 18px 14px 30px;
  }
  
  .tables {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .row,
  .row3 {
    grid-template-columns: 1fr;
  }
  
  .inputs {
    grid-template-columns: 1fr;
  }
  
  .tss-panel {
    margin: 12px;
    max-height: calc(100vh - 24px);
  }
  
  .tss-body {
    max-height: calc(100vh - 150px);
  }
  
  .pillbar {
    flex-direction: column;
  }
  
  .pill {
    padding: 12px;
  }
}

/* ===============================
   TABLE INPUT STYLING
=============================== */

table select,
table input {
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 4px;
}

table .tssInp {
  width: 80px;
  text-align: center;
}

table .blockSel {
  width: auto;
  min-width: 100px;
}
