/* tyn-volunter -- shared UI framework (F7-1).
   Two layout modes, chosen in base.html by whether `user` is set:
   - .auth-page  : dark card-centered layout for login/forgot/reset password
   - .app-shell  : light sidebar + content layout for everything else
*/

:root {
  --auth-bg: #0f172a;
  --auth-card-bg: #1e293b;
  --auth-border: #334155;
  --auth-title: #f1f5f9;
  --auth-subtitle: #94a3b8;
  --auth-label: #7dd3c0;
  --auth-input-bg: #0f172a;
  --auth-input-border: #334155;
  --auth-input-text: #e2e8f0;

  --shell-bg: #f8fafc;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-active-bg: #ccfbf1;
  --sidebar-active-text: #0f766e;

  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --table-header-bg: #f1f5f9;

  --accent: #0d9488;
  --accent-hover: #0f766e;
  --error: #dc2626;
  --error-bg: #fef2f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "PingFang TC",
    "Microsoft JhengHei",
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--text-primary);
}

h1 {
  font-size: 1.375rem;
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

/* ---------- auth pages (login / forgot / reset password) ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  background: var(--auth-bg);
  padding: 2rem 1rem;
}

.auth-header {
  text-align: center;
  color: var(--auth-title);
}

.auth-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.auth-header p {
  margin: 0;
  color: var(--auth-subtitle);
  font-size: 0.9rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--auth-card-bg);
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  padding: 2rem;
  color: var(--auth-title);
}

.auth-card h1 {
  color: var(--auth-title);
}

.auth-card label {
  color: var(--auth-label);
}

.auth-card input {
  background: var(--auth-input-bg);
  border: 1px solid var(--auth-input-border);
  color: var(--auth-input-text);
}

.auth-card p.error {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.4);
  color: #fca5a5;
}

.auth-card a {
  color: var(--auth-label);
}

/* ---------- app shell (everything else) ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--shell-bg);
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 0.5rem 1.25rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.sidebar-nav a:hover {
  background: #f1f5f9;
}

.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.sidebar-user {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.85rem;
}

.sidebar-user-email {
  color: var(--text-primary);
  word-break: break-all;
}

.sidebar-user-role {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem;
  overflow-x: auto;
}

/* ---------- shared form / table / button baseline ---------- */

form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 480px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  font-weight: 400;
}

input,
select {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
}

button,
.link-button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  align-self: flex-start;
}

button:hover,
.link-button:hover {
  background: var(--accent-hover);
}

.link-button {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 400;
  text-decoration: underline;
}

.link-button:hover {
  background: none;
  color: var(--accent-hover);
}

p.error {
  background: var(--error-bg);
  border: 1px solid #fecaca;
  color: var(--error);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  max-width: 480px;
}

table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  background: var(--table-header-bg);
  color: var(--text-secondary);
  font-weight: 600;
}

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  max-width: 480px;
}

dt {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

dd {
  margin: 0;
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-user {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-left: auto;
  }

  .content {
    padding: 1.25rem;
  }
}
