/* Raporty SweetFactory — single stylesheet (step 2.4).
   Clean, responsive layout for the ticket form, history table and detail
   view. No external stylesheets or CDN fonts. */

:root {
  --fg: #1f2933;
  --fg-muted: #52606d;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #cbd2d9;
  --accent: #2563a8;
  --accent-dark: #1d4e82;
  --ok-bg: #e3f4e6;
  --ok-fg: #1b5e20;
  --err-bg: #fbe4e4;
  --err-fg: #a01919;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0 auto;
  max-width: 60rem;
  padding: 1rem 1.25rem 2.5rem;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

/* --- Header / navigation --- */
header {
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
}

header h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

header h1 a {
  color: var(--fg);
  text-decoration: none;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

nav a:hover {
  text-decoration: underline;
}

h2 {
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.75rem;
}

/* --- Flash messages --- */
.flashes {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

.flash {
  border-radius: 6px;
  margin-bottom: 0.5rem;
  padding: 0.6rem 0.9rem;
  font-weight: 500;
}

.flash-success {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.flash-error {
  background: var(--err-bg);
  color: var(--err-fg);
}

/* --- Forms --- */
.ticket-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.field input[type="datetime-local"],
.field textarea {
  width: 100%;
  padding: 0.5rem;
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-checkbox label {
  margin: 0;
}

.field-checkbox input {
  width: 1.1rem;
  height: 1.1rem;
}

.printer-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem 0.25rem;
  margin: 0 0 1.25rem;
  background: #fafbfc;
}

.printer-section legend {
  font-weight: 700;
  padding: 0 0.4rem;
}

/* Belt-and-suspenders: the JS toggles the `hidden` attribute; this rule
   guarantees it wins over the fieldset's own styling. */
.printer-section[hidden] {
  display: none;
}

.hint {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-top: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

/* --- Buttons --- */
button,
.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

.button.secondary,
button.secondary {
  background: #e4e7eb;
  color: var(--fg);
}

.button.secondary:hover,
button.secondary:hover {
  background: #d3d8de;
}

/* --- Status badges (Robocze / Zakończone) --- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-draft {
  background: #e4e7eb;
  color: var(--fg-muted);
}

.badge-done {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

/* --- History table --- */
.table-wrap {
  overflow-x: auto;
}

table.tickets {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table.tickets th,
table.tickets td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.tickets thead th {
  background: #eef2f6;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

table.tickets tbody tr:nth-child(even) {
  background: #fafbfc;
}

table.tickets tbody tr:last-child td {
  border-bottom: none;
}

td.actions {
  white-space: nowrap;
}

td.actions a {
  color: var(--accent);
  margin-right: 0.6rem;
}

.empty {
  color: var(--fg-muted);
  font-style: italic;
}

/* --- Detail view --- */
dl.ticket-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: minmax(12rem, max-content) 1fr;
  gap: 0.4rem 1.25rem;
}

dl.ticket-detail dt {
  font-weight: 600;
  color: var(--fg-muted);
}

dl.ticket-detail dd {
  margin: 0;
}

/* --- Footer --- */
footer {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* --- Narrow screens: stack the detail definition list --- */
@media (max-width: 32rem) {
  dl.ticket-detail {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  dl.ticket-detail dd {
    margin-bottom: 0.6rem;
  }
}
