/* TPL Scoresheet — styles.
   Hand-written replacement for the Tailwind classes the React version used. */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
    background: #e5e7eb;
    -webkit-text-size-adjust: 100%;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app { min-height: 100vh; padding: 16px 8px; }
.container { max-width: 1152px; margin: 0 auto; }

.page-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.app-title { font-size: 18px; font-weight: 700; color: #1f2937; margin: 0; }
.editing-label { font-size: 12px; color: #6b7280; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-plain { border-color: #9ca3af; background: #fff; color: #374151; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.btn-plain:hover:not(:disabled) { background: #f9fafb; }
.btn-danger-hover:hover:not(:disabled) { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

.btn-primary { background: #1d4ed8; color: #fff; font-weight: 600; padding: 8px 20px; box-shadow: 0 2px 4px rgba(0,0,0,.1); }
.btn-primary:hover:not(:disabled) { background: #1e40af; }

.btn-green { background: #15803d; color: #fff; font-weight: 600; }
.btn-green:hover:not(:disabled) { background: #166534; }

.btn-sm { font-size: 13px; padding: 6px 14px; }
.btn-lg { font-size: 16px; font-weight: 700; padding: 12px 36px; border-radius: 12px; box-shadow: 0 4px 8px rgba(0,0,0,.12); }

.link-btn {
    background: none; border: none; padding: 0;
    color: #1d4ed8; font-size: 14px; font-weight: 500;
    text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: #1e3a8a; }
.link-btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-mini {
    font-size: 12px; padding: 4px 12px; border-radius: 4px;
    border: none; cursor: pointer;
}
.btn-load { background: #2563eb; color: #fff; }
.btn-load:hover { background: #1d4ed8; }
.btn-del { background: #fee2e2; color: #b91c1c; }
.btn-del:hover { background: #fecaca; }

/* ── Status banner ───────────────────────────────────────────────────────── */
.status {
    margin-bottom: 12px; padding: 8px 16px;
    border-radius: 8px; font-size: 14px; font-weight: 500;
    border: 1px solid transparent;
}
.status-ok  { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-bad { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    overflow: hidden;
}
.card-head { background: #f3f4f6; border-bottom: 1px solid #d1d5db; padding: 8px 12px; }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; color: #374151; }
.card-body { padding: 8px 12px; }

.report-card { margin-bottom: 16px; }
.report-body { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.select { font-size: 14px; border: 1px solid #d1d5db; border-radius: 4px; padding: 5px 8px; background: #fff; }
.muted { font-size: 12px; color: #9ca3af; }

/* ── Saved scoresheets ───────────────────────────────────────────────────── */
.saved-block { margin-bottom: 16px; }
.saved-panel {
    margin-top: 8px; border: 1px solid #d1d5db; border-radius: 8px;
    overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.05); background: #fff;
}
.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-list li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-bottom: 1px solid #e5e7eb;
}
.saved-list li:last-child { border-bottom: none; }
.saved-list li:hover { background: #f9fafb; }
.saved-name { margin: 0; font-size: 14px; font-weight: 500; color: #1f2937; }
.saved-date { margin: 2px 0 0; font-size: 12px; color: #9ca3af; }
.saved-actions { display: flex; gap: 8px; margin-left: 8px; }
.saved-empty { font-size: 14px; color: #6b7280; padding: 12px; margin: 0; }

/* ── Sheet ───────────────────────────────────────────────────────────────── */
.sheet { background: #fff; border: 2px solid #374151; box-shadow: 0 4px 10px rgba(0,0,0,.1); }

.sheet-head { background: #1e40af; border-bottom: 2px solid #374151; }
.sheet-name-input {
    width: 100%; background: transparent; border: none; outline: none;
    color: #fff; text-align: center; font-weight: 700;
    font-size: 15px; padding: 8px;
}
.sheet-name-input::placeholder { color: #93c5fd; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap, .goal-table-wrap { overflow-x: auto; }
.goal-row-wrap { display: flex; gap: 0; }
.goal-table-wrap { flex: 1; min-width: 0; }

.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.goal-table { min-width: 560px; }
.matches-table, .standings-table { min-width: 520px; }

.grid th, .grid td { border: 1px solid #9ca3af; }
.grid thead th { border: 1px solid #374151; padding: 4px 8px; }

.section-title { background: #fff; text-align: left; font-weight: 700; font-size: 14px; }
.head-row th { background: #f3f4f6; }
.computed-head { background: #dbeafe; }

.grid tbody tr:nth-child(even) { background: #f9fafb; }
.standings-table tbody tr:nth-child(even) { background: transparent; }

.grid td { padding: 2px 4px; }
.sr { text-align: center; font-size: 12px; font-weight: 500; color: #1d4ed8; width: 32px; }
.w-sr { width: 32px; text-align: center; }
.w-goals { width: 64px; }
.w-pts { width: 40px; }
.text-left { text-align: left; }
.nowrap { white-space: nowrap; }
.match-name { font-size: 13px; }

.computed {
    text-align: center; background: #eff6ff;
    font-size: 13px; font-weight: 500; color: #1e40af;
}

.cell-input {
    width: 100%; border: none; outline: none; background: transparent;
    font-size: 13px; font-family: inherit; color: inherit; padding: 2px;
    min-width: 90px;
}
.cell-input.center { text-align: center; min-width: 0; }
.cell-input::placeholder { color: #d1d5db; }

.round-input { display: flex; align-items: center; justify-content: center; gap: 4px; }
.score-box {
    width: 28px; border: none; outline: none; background: transparent;
    text-align: center; font-size: 13px; font-family: inherit; padding: 2px;
}
.score-box::placeholder { color: #d1d5db; }
.dash { font-weight: 700; color: #6b7280; user-select: none; }

/* Team colours */
.team-black  { background: #1f2937; color: #fff; }
.team-yellow { background: #facc15; color: #111827; }
.team-red    { background: #dc2626; color: #fff; }
.team-white  { background: #f3f4f6; color: #111827; }
.team-name   { font-weight: 500; font-size: 13px; padding: 2px 8px; }

/* ── Time-slot panel ─────────────────────────────────────────────────────── */
.slots { flex-shrink: 0; width: 82px; border: 1px solid #374151; font-size: 12px; }
.slots-head {
    border-bottom: 1px solid #374151; background: #f3f4f6;
    text-align: center; font-weight: 700; padding: 4px 2px; line-height: 1.2;
}
.slot {
    border-bottom: 1px solid #9ca3af; text-align: center;
    padding: 4px 2px; min-height: 28px; line-height: 1.2;
}

/* ── Bottom actions ──────────────────────────────────────────────────────── */
.bottom-actions {
    margin-top: 20px; display: flex; flex-wrap: wrap;
    align-items: center; justify-content: center; gap: 12px;
}
.footnote { text-align: center; font-size: 12px; color: #9ca3af; margin: 8px 0 16px; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-card { width: 100%; max-width: 360px; padding: 28px; }
.login-card h1 { margin: 0; font-size: 22px; text-align: center; color: #1e40af; }
.login-sub { margin: 4px 0 20px; text-align: center; font-size: 13px; color: #6b7280; }
.login-card label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: #374151; }
.login-card input {
    width: 100%; padding: 9px 12px; margin-bottom: 14px;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 15px; font-family: inherit;
}
.login-card input:focus { outline: 2px solid #93c5fd; outline-offset: -1px; border-color: #2563eb; }
.login-card button {
    width: 100%; padding: 10px; border: none; border-radius: 8px;
    background: #1d4ed8; color: #fff; font-size: 15px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
.login-card button:hover:not(:disabled) { background: #1e40af; }
.login-card button:disabled { opacity: .6; cursor: not-allowed; }
.login-error {
    background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
    border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 0 0 14px;
}

/* ── Setup page ──────────────────────────────────────────────────────────── */
.setup-card { width: 100%; max-width: 520px; padding: 28px; }
.setup-card h1 { margin: 0 0 16px; font-size: 20px; color: #1e40af; }
.setup-list { margin: 0 0 16px; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.setup-done { font-size: 14px; color: #166534; background: #dcfce7; border: 1px solid #86efac; border-radius: 8px; padding: 10px 12px; margin: 0; }
.setup-fail { font-size: 14px; color: #991b1b; background: #fee2e2; border: 1px solid #fca5a5; border-radius: 8px; padding: 10px 12px; margin: 0; }

@media (min-width: 640px) {
    .app { padding: 16px; }
    .grid { font-size: 14px; }
    .sheet-name-input { font-size: 16px; }
}
