/*
 * application.css
 */

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

:root {
  --color-bg:        #f5f4f1;
  --color-surface:   #ffffff;
  --color-border:    #e0dbd4;
  --color-text:      #1c1917;
  --color-muted:     #78716c;
  --color-primary:   #2563eb;
  --color-primary-h: #1d4ed8;
  --color-danger:    #dc2626;
  --color-danger-h:  #b91c1c;
  --color-success-bg:#dcfce7;
  --color-success-tx:#14532d;
  --color-alert-bg:  #fee2e2;
  --color-alert-tx:  #7f1d1d;
  --radius:          0.5rem;
  --shadow:          0 1px 3px rgba(0,0,0,.07), 0 2px 6px rgba(0,0,0,.05);
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 0;
  font-size: 1rem;
  line-height: 1.55;
}

/* ── Layout wrapper ── */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.container--wide {
  max-width: 1200px;
}

@media (min-width: 640px) {
  .container {
    padding: 1.5rem 2rem;
  }
}

/* ── Flash messages ── */
.flash-notice,
.flash-alert {
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
}
.flash-notice { background: var(--color-success-bg); color: var(--color-success-tx); }
.flash-alert  { background: var(--color-alert-bg);   color: var(--color-alert-tx); }

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 0.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }

/* ── Nav ── */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  align-items: center;
}
.nav a, .nav form { margin: 0; }

/* ── Buttons ── */
.btn,
input[type="submit"],
button[type="submit"] {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--color-primary);
  color: #fff;
  transition: background 0.12s, box-shadow 0.12s;
  -webkit-appearance: none;
  font-family: inherit;
  line-height: 1.4;
}
.btn:hover,
input[type="submit"]:hover,
button[type="submit"]:hover {
  background: var(--color-primary-h);
  box-shadow: 0 2px 8px rgba(37,99,235,.22);
}
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8125rem; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-h); box-shadow: 0 2px 8px rgba(220,38,38,.22); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-weight: 500;
}
.btn-secondary:hover { background: var(--color-bg); box-shadow: none; }

/* ── Forms ── */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.575rem 0.8rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.11);
}

/* ── Checkbox rows ── */
.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
}
.check-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  border: 1.5px solid var(--color-border);
  border-radius: 0.25rem;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
.check-row label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  margin: 0;
}

/* ── Toggle-reveal sections ── */
.toggle-section {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.toggle-section-header {
  background: var(--color-bg);
  padding: 0 0.875rem;
}
.toggle-section-body {
  padding: 0.875rem;
  border-top: 1.5px solid var(--color-border);
  background: var(--color-surface);
}

/* ── Form actions row ── */
.form-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding-top: 0.5rem;
  flex-wrap: wrap;
}

/* ── Error list ── */
.error-list {
  background: var(--color-alert-bg);
  color: var(--color-alert-tx);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.error-list ul { margin: 0; padding-left: 1.25rem; }
.error-list li { margin-bottom: 0.25rem; }

/* ── Event cards (dashboard) ── */
.event-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.event-card-meta {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin-bottom: 0.15rem;
}
.event-card-types {
  font-weight: 600;
  font-size: 0.9rem;
}
.event-badge {
  display: inline-block;
  padding: 0.175rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #eeece8;
  color: var(--color-text);
  margin-right: 0.2rem;
}

/* ── Show page detail ── */
.detail-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--color-muted); font-weight: 500; }

/* ── Log table ── */
.log-table-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.45;
}

/* Header row */
.log-table thead tr {
  background: var(--color-bg);
}
.log-table th {
  padding: 0.6rem 0.875rem;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  text-align: left;
}

/* Data cells */
.log-table td {
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.log-table tr:last-child td {
  border-bottom: none;
}

/* Alternating rows */
.log-table tbody tr:nth-child(even) td {
  background: #faf9f7;
}

/* Sticky date column */
.log-table th:first-child,
.log-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  font-weight: 600;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}
.log-table thead th:first-child {
  background: var(--color-bg);
  z-index: 2;
}
.log-table tbody tr:nth-child(even) td:first-child {
  background: #faf9f7;
}

/* Count columns — centered */
.log-table th:nth-child(2),
.log-table th:nth-child(5),
.log-table th:nth-child(6),
.log-table td:nth-child(2),
.log-table td:nth-child(5),
.log-table td:nth-child(6) {
  text-align: center;
}

/* Text columns — allow wrapping */
.log-table td:nth-child(4),
.log-table td:nth-child(9) {
  white-space: normal;
  min-width: 10rem;
  max-width: 16rem;
}

.log-muted {
  color: var(--color-muted);
}
