/*
 * Spring-owned shared design tokens + base styling for the Thymeleaf backoffice shell (login +
 * layout/backoffice). The player UI now lives entirely in the Next.js clients under web/; this sheet
 * only needs to make the server-rendered backoffice legible and on-brand. backoffice.css layers admin
 * chrome on top of these tokens.
 *
 * Theming: design tokens live in `:root`; each brand overrides a small set via a `theme-<key>` class
 * placed on <body> (see layout/auth.html, layout/backoffice.html + GlobalModelAttributes). Add a new
 * brand by adding one `.theme-<key>` block, not by forking the sheet. There is no dark theme — only
 * brand accents — so `color-scheme` stays `light` (see the matching meta in the layout heads).
 */

:root {
  color-scheme: light;
  --brand-accent: #1d4ed8;
  --brand-accent-strong: #1e40af;
  --brand-accent-contrast: #ffffff;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --positive: #047857;
  --negative: #b91c1c;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --container: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Brand themes -------------------------------------------------------------- */
.theme-hadbet {
  --brand-accent: #266dd3;
  --brand-accent-strong: #344055;
  --brand-highlight: #44ffd1;
  --brand-highlight-contrast: #344055;
  --error-text: #db504a;
}
.theme-topracer {
  --brand-accent: #03413e;
  --brand-accent-strong: #022e2c;
  --brand-highlight: #ffeb3b;
  --brand-highlight-contrast: #03413e;
}

/* Base ---------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a {
  color: var(--brand-accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1 {
  font-size: 1.6rem;
  margin: 0 0 1rem;
}
h2 {
  font-size: 1.2rem;
}
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header -------------------------------------------------------------------- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.logo:hover {
  text-decoration: none;
}
.account {
  display: flex;
  align-items: center;
}
.login-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.account-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.myaccount {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
}
.balance-label {
  color: var(--text-muted);
}
.balance-amount {
  font-weight: 600;
}
.logout-form {
  margin: 0;
}
.logout-form button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.logout-form button:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Content + footer ---------------------------------------------------------- */
.content {
  padding: 2rem 0 3rem;
  min-height: calc(100vh - 64px - 56px);
}
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer .container {
  display: flex;
  align-items: center;
  min-height: 56px;
}

/* Buttons ------------------------------------------------------------------- */
.btn,
button[type="submit"],
.statement-filter button,
.account-form .actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--brand-accent);
  color: var(--brand-accent-contrast);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover,
button[type="submit"]:hover,
.statement-filter button:hover,
.account-form .actions button:hover {
  background: var(--brand-accent-strong);
  text-decoration: none;
}

/* Alerts -------------------------------------------------------------------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.alert ul {
  margin: 0;
  padding-left: 1.1rem;
}
.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}
.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Cards / sections ---------------------------------------------------------- */
.hero,
.login-box,
.account-dashboard,
.account-form,
.account-statement {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.hero {
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-accent-strong));
  color: var(--brand-accent-contrast);
  border: none;
}
.hero h1 {
  margin-bottom: 0.5rem;
}

/* Login --------------------------------------------------------------------- */
.login-box {
  max-width: 420px;
  margin: 2rem auto;
}
.login-extra {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* Forms --------------------------------------------------------------------- */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent) 20%, transparent);
}
input:disabled {
  background: var(--bg);
  color: var(--text-muted);
}
textarea {
  min-height: 80px;
  resize: vertical;
}
.actions {
  margin-top: 1.25rem;
}
.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Account navigation -------------------------------------------------------- */
.account-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.account-nav a {
  padding: 0.6rem 0.9rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.account-nav a:hover {
  color: var(--text);
  text-decoration: none;
}
.account-nav a.active {
  color: var(--brand-accent);
  border-bottom-color: var(--brand-accent);
}

/* Dashboard tiles ----------------------------------------------------------- */
.content-title {
  margin: 1.5rem 0 0.75rem;
}
.account-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.btn-account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
}
.btn-account:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  text-decoration: none;
}

/* Statement / transactions -------------------------------------------------- */
.statement-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.statement-filter label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.statement-filter input {
  width: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table-hover tbody tr:hover {
  background: var(--bg);
}
.amount-positive {
  color: var(--positive);
}
.amount-negative {
  color: var(--negative);
}
.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .header .container {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
  .login-extra {
    flex-direction: column;
    gap: 0.5rem;
  }
}
