/* Hand-written stylesheet for the PlayGuard SPA. Self-hosted only: no
 * external fonts, no CDN imports (CSP style-src 'self'). Sized for phones
 * (~380px) first; a single media query switches the card list to a grid on
 * desktop. */

* {
  box-sizing: border-box;
}

body {
  font: 16px/1.5 -apple-system, system-ui, "Segoe UI", sans-serif;
  margin: 0 auto;
  max-width: 1100px;
  padding: 12px;
  background: #f4f4f6;
  color: #1a1a24;
}

/* -- login ------------------------------------------------------------- */

main.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

form.login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
}

/* -- app shell ----------------------------------------------------------- */

main.app {
  display: block;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

header.top h1 {
  font-size: 1.3rem;
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
}

nav.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid #ddd;
}

nav.tabs button {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #556;
  padding: 10px 8px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
}

nav.tabs button.active {
  color: #2c6e49;
  border-bottom-color: #2c6e49;
}

/* -- cards ------------------------------------------------------------------ */

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin: 0 0 12px;
  width: 100%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.card h1 {
  font-size: 1.4rem;
  margin: 0 0 16px;
}

.card h2 {
  font-size: 1.1rem;
  margin: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

section.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

section.grid .card {
  margin: 0;
}

/* Desktop: cards side by side, wider gutters. */
@media (min-width: 900px) {
  body {
    padding: 24px;
  }

  section.grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
}

/* -- controls ------------------------------------------------------------------ */

input,
button,
select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #ccd;
  border-radius: 6px;
  background: #fff;
}

button {
  background: #2c6e49;
  color: #fff;
  border: 0;
  cursor: pointer;
}

button:disabled {
  background: #9bb8a8;
  cursor: default;
}

button.ghost {
  background: none;
  color: #2c6e49;
  border: 1px solid #ccd;
  padding: 6px 10px;
}

button.ghost:disabled {
  background: none;
  color: #99a;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
}

label.picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #556;
  font-size: 0.9rem;
}

/* Wide enough to keep the week label readable; wraps onto its own row on
 * phones instead of getting crushed next to the device picker. */
.week-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 240px;
  min-width: 0;
}

.week-picker select {
  flex: 1;
  min-width: 0;
}

button.arrow {
  padding: 6px 12px;
  font-weight: 700;
}

/* -- text states ------------------------------------------------------------------ */

.error {
  color: #c0392b;
  margin: 0 0 8px;
}

.muted {
  color: #667;
}

.small {
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.big {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 4px 0;
}

.big.yes {
  color: #2c6e49;
}

.big.no {
  color: #778;
}

.status-body p {
  margin: 4px 0;
}

/* -- badges, alerts, overrides ---------------------------------------------------- */

.badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge.playing {
  background: #dcf3e4;
  color: #1d5c3a;
}

.badge.idle {
  background: #e8e8ee;
  color: #555;
}

.badge.offline {
  background: #fdecea;
  color: #b03a2e;
}

.alert {
  background: #fdecea;
  border-left: 4px solid #c0392b;
  color: #7c261d;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
}

.override {
  background: #fef5e7;
  border-left: 4px solid #e67e22;
  color: #7e4a10;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 600;
}

/* -- progress bars -------------------------------------------------------------------- */

.meter {
  margin: 10px 0;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.progress {
  background: #e8e8ee;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-fill {
  background: #2c6e49;
  height: 100%;
  border-radius: 999px;
}

.progress-fill.full {
  background: #c0392b;
}

/* -- week chart ---------------------------------------------------------------------------- */

svg.chart {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 4px auto;
}

svg.chart .axis {
  stroke: #ccd;
  stroke-width: 1;
}

svg.chart .bar {
  fill: #2c6e49;
}

svg.chart g.today .bar {
  fill: #e67e22;
}

svg.chart text {
  font-family: inherit;
  font-size: 12px;
  fill: #556;
}

svg.chart .value {
  font-size: 11px;
}

svg.chart g.today .day {
  font-weight: 700;
  fill: #1a1a24;
}

svg.chart g.future .day {
  fill: #aab;
}

.week-total {
  margin: 4px 0 0;
  font-weight: 600;
}

/* -- admin controls ------------------------------------------------------------------------ */

section.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

section.stack .card {
  margin: 0;
}

.note {
  background: #eaf1fb;
  border-left: 4px solid #3a6ea5;
  color: #1f3a5c;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 12px;
  font-size: 0.9rem;
}

form.control-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0 4px;
}

form.control-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #556;
  font-size: 0.9rem;
}

form.control-form input[type="number"] {
  width: 110px;
}

.success {
  color: #1d5c3a;
  margin: 4px 0;
}

textarea.config {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid #ccd;
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
  margin: 8px 0;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dirty {
  color: #7e4a10;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.pending {
  background: #fef5e7;
  color: #7e4a10;
}

.badge.applied {
  background: #dcf3e4;
  color: #1d5c3a;
}

.badge.rejected {
  background: #fdecea;
  color: #b03a2e;
}

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

table.history-table th,
table.history-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #e4e4ea;
  white-space: nowrap;
}

table.history-table th {
  color: #667;
  font-weight: 600;
}

table.history-table td.detail {
  white-space: normal;
  min-width: 140px;
  color: #556;
}

/* -- statistics --------------------------------------------------------------------------------- */

dl.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

dl.stats div {
  background: #f4f4f6;
  border-radius: 6px;
  padding: 8px 10px;
}

dl.stats dt {
  font-size: 0.8rem;
  color: #667;
}

dl.stats dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

dl.stats div.bad {
  background: #fdecea;
}

dl.stats div.bad dd {
  color: #b03a2e;
}

.table-wrap {
  overflow-x: auto;
}

table.stats-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  white-space: nowrap;
}

table.stats-table th,
table.stats-table td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid #e4e4ea;
}

table.stats-table th:first-child,
table.stats-table td:first-child {
  text-align: left;
}

table.stats-table th {
  color: #667;
  font-weight: 600;
}

tr.bad td {
  background: #fdecea;
  color: #7c261d;
}
