/*
 * Application styles.
 * Layout: chukker tournament editing — teams + roster + schedule.
 */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #151515;
  --muted: #6a665f;
  --line: #ddd8cf;
  --accent: #176f62;
  --accent-strong: #0d4d45;
  --danger: #b91c1c;
  --play: #05a84f;
  --out: #e11d12;
  --radius: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------------- Header / shell ---------------- */

.app-header {
  align-items: center;
  background: #0e0e0e;
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 14px 28px;
}
.app-header a { color: #fff; }
.app-header nav { display: flex; gap: 18px; }
.brand { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }

.app-shell {
  margin: 0 auto;
  max-width: 1280px;
  padding: 28px 24px 56px;
}

.page-title {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-title h1 { font-size: 30px; line-height: 1.1; margin: 4px 0 0; }

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
  text-transform: uppercase;
}

.small { font-size: 12px; }
.muted { color: var(--muted); }

/* ---------------- Buttons & inputs ---------------- */

.button-row,
.inline-form,
.team-edit {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-weight: 600;
  min-height: 36px;
  padding: 7px 13px;
  text-decoration: none;
  transition: border-color 0.1s, background 0.1s;
}
.button:hover { border-color: #b9b3a8; text-decoration: none; }
.button-small { min-height: 28px; padding: 4px 9px; font-size: 13px; }
.button-large { min-height: 44px; padding: 11px 24px; font-size: 16px; }

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.button-icon {
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
}

.link-button,
.text-danger {
  background: none;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  min-height: 36px;
  padding: 7px 10px;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(23, 111, 98, 0.15);
}
textarea { resize: vertical; }

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.compact-field {
  display: grid;
  gap: 4px;
}
.compact-field.grow { flex: 1; }

.compact-check {
  align-items: center;
  display: flex;
  gap: 6px;
}
.compact-check input { min-height: auto; width: auto; }

.input-num {
  min-height: 32px;
  padding: 4px 8px;
  text-align: right;
  width: 64px;
}

/* ---------------- Flashes & panels ---------------- */

.flash {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 600;
  margin: 0 0 18px;
  padding: 11px 14px;
}
.flash-notice { background: #eef7f1; border-color: #b7d8c7; }
.flash-alert  { background: #fff5f5; border-color: #e7aaa5; color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
  padding: 18px 20px;
}
.panel-empty { color: var(--muted); }
.panel-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.panel-header h2 { font-size: 18px; margin: 0; }
.panel-header p { margin: 4px 0 0; }

/* ---------------- Forms (event new/edit) ---------------- */

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.field { display: grid; gap: 6px; }
.field-wide,
.form-errors,
.form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }

.form-errors {
  background: #fff5f5;
  border: 1px solid #e7aaa5;
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 12px;
}

/* ---------------- Tables (generic) ---------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.panel > .table-wrap { border: 0; border-radius: 0; padding: 0; }

table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
th { font-size: 13px; font-weight: 700; }
.actions { text-align: right; }

/* ---------------- Teams chip grid ---------------- */

.team-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.team-chip {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 4px 6px 4px 8px;
}
.team-chip input { min-height: 28px; padding: 3px 8px; font-size: 13px; }
.team-chip .button { margin-left: 2px; }
.team-chip-new { background: #fff; border-style: dashed; }

.team-chip-swatch {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  height: 18px;
  width: 18px;
  flex-shrink: 0;
}
.team-chip-name { width: 110px; font-weight: 600; }
.team-chip-color { width: 80px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.team-chip-delete { display: inline-block; margin-left: 2px; }
.team-chip-delete button { font-size: 13px; }

/* ---------------- Roster ---------------- */

.roster-add {
  align-items: flex-end;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
}
.roster-add .compact-field { min-width: 160px; }

.roster-form { display: contents; }

.roster-table {
  width: 100%;
}
.roster-table thead th {
  background: var(--surface-soft);
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.roster-table td { vertical-align: middle; }

.roster-table .col-player { min-width: 160px; }
.roster-table .col-player .roster-player-link { font-weight: 600; }
.roster-table .col-player .small { display: block; margin-top: 2px; }

.roster-table .col-hcp,
.roster-table .col-num { width: 80px; }
.roster-table .col-team { min-width: 130px; }

.team-select {
  min-height: 32px;
  padding: 3px 8px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.team-select-auto {
  background: #fff;
  color: var(--muted);
  font-weight: 500;
  font-style: italic;
}

.inline-delete { display: inline; }
.inline-delete button { padding: 4px 8px; }

.roster-form-footer {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 14px;
}

/* ---------------- Schedule ---------------- */

.schedule-scroll { overflow-x: auto; }

.schedule-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  min-width: 100%;
}
.schedule-table th,
.schedule-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
}
.schedule-table thead th {
  background: var(--surface-soft);
  position: sticky;
  top: 0;
  z-index: 3;
}

.schedule-table th.sticky-col,
.schedule-table td.sticky-col {
  background: var(--surface);
  position: sticky;
  z-index: 2;
}
.schedule-table .player-col { left: 0; min-width: 160px; font-weight: 600; }
.schedule-table .hcp-col    { left: 160px; min-width: 56px; text-align: center; }
.schedule-table .total-col  { left: 216px; min-width: 48px; text-align: center; font-weight: 700; }

.schedule-table thead th.sticky-col { z-index: 4; }

.schedule-table th.cell-summary,
.schedule-table td.cell-status {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
}

.cell-out, .cell-unavailable {
  color: var(--muted);
  background: var(--surface-soft);
}
.cell-play { font-weight: 800; }

.schedule-team-summary th {
  background: var(--surface-soft);
  font-size: 12px;
}
.schedule-team-summary .player-col { font-weight: 700; }

.schedule-fix-badge {
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 6px;
  padding: 1px 6px;
  text-transform: uppercase;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 720px) {
  .app-header,
  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .app-shell { padding: 20px 14px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .roster-form-footer { flex-direction: column; align-items: stretch; }
  .roster-form-footer .button-large { width: 100%; justify-content: center; }
}
