/*
 * InnClocky — components.
 *
 * Tables rather than cards for anything with more than three rows, 1px borders
 * rather than shadows, and exactly one coloured button in the whole
 * application: start/stop.
 */

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-family: inherit;
  font-size: var(--text-dense);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: #000000;
  text-decoration: none;
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn--secondary:hover {
  background: var(--surface-alt);
  border-color: var(--ink-soft);
}

.btn--danger {
  background: var(--surface);
  border-color: var(--alert);
  color: var(--alert);
}

.btn--danger:hover {
  background: var(--alert);
  color: var(--surface);
}

.btn--small {
  padding: var(--s1) var(--s2);
  font-size: 12px;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* A link that behaves like a link but sits in a row of buttons. */
.link-action {
  font-size: var(--text-dense);
  font-weight: 600;
}

/* --- Forms ---------------------------------------------------------------- */

.form {
  max-width: 520px;
}

.form--wide {
  max-width: 100%;
}

.field {
  margin-bottom: var(--s4);
}

.field > label {
  display: block;
  margin-bottom: var(--s1);
  font-size: var(--text-dense);
  font-weight: 600;
}

.field__hint {
  margin: var(--s1) 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.field__error {
  margin: var(--s1) 0 0;
  font-size: 12px;
  color: var(--alert);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--text-body);
  line-height: 1.4;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ink-soft);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--alert);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  font-size: var(--text-dense);
}

.checkbox input {
  margin: 2px 0 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: var(--border);
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s5);
  padding: var(--s4);
  border: var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.filters .field {
  margin-bottom: 0;
}

/* --- Tables --------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-dense);
}

table.data th,
table.data td {
  padding: var(--s2) var(--s3);
  text-align: left;
  vertical-align: top;
  border-bottom: var(--border);
}

table.data thead th {
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
}

table.data tbody tr:nth-child(even) {
  background: var(--surface-alt);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.data td.actions {
  text-align: right;
  white-space: nowrap;
}

table.data tfoot td {
  padding: var(--s2) var(--s3);
  font-weight: 700;
  border-top: 2px solid var(--ink);
  font-variant-numeric: tabular-nums;
}

/* --- Status pills --------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 1px var(--s2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  color: var(--ink-soft);
}

.pill--ok {
  border-color: var(--green);
  color: var(--green);
}

.pill--alert {
  border-color: var(--alert);
  color: var(--alert);
}

.pill--info {
  border-color: var(--blue);
  color: var(--blue);
}

/* --- Progress ------------------------------------------------------------- */

.progress {
  display: block;
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress__bar {
  display: block;
  height: 100%;
  background: var(--green);
}

.progress--over .progress__bar {
  background: var(--alert);
}

/* --- Flash and inline messages -------------------------------------------- */

.flash {
  margin-bottom: var(--s5);
  padding: var(--s3) var(--s4);
  border: var(--border);
  border-left: 3px solid var(--ink);
  border-radius: var(--radius);
  font-size: var(--text-dense);
}

.flash--notice {
  border-left-color: var(--green);
}

.flash--alert {
  border-left-color: var(--alert);
}

.errors {
  margin-bottom: var(--s5);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--alert);
  border-radius: var(--radius);
  font-size: var(--text-dense);
  color: var(--alert);
}

.errors ul {
  margin: var(--s1) 0 0;
  padding-left: var(--s5);
}

/* --- Empty states --------------------------------------------------------- */

.empty {
  padding: var(--s8) var(--s5);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  color: var(--ink-soft);
  font-size: var(--text-dense);
}

.empty strong {
  display: block;
  margin-bottom: var(--s1);
  color: var(--ink);
  font-size: var(--text-body);
}

/* --- Definition rows (summaries) ------------------------------------------ */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s4);
  margin: 0 0 var(--s5);
  padding: var(--s4);
  border: var(--border);
  border-radius: var(--radius);
}

.facts div {
  min-width: 0;
}

.facts dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.facts dd {
  margin: var(--s1) 0 0;
  font-size: var(--text-heading);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- Pagination ----------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s4);
  font-size: var(--text-dense);
}

.pagination__spacer {
  flex: 1 1 auto;
}

/* --- Code-ish values in the audit log ------------------------------------- */

.diff {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff del {
  color: var(--alert);
  text-decoration: line-through;
}

.diff ins {
  color: var(--green);
  text-decoration: none;
}

/* --- Timer panel ---------------------------------------------------------- */

.timer-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s5);
  margin-bottom: var(--s8);
  padding: var(--s5);
  border: var(--border);
  border-radius: var(--radius);
}

.timer-panel__form {
  display: contents;
}

.timer-panel__fields {
  display: flex;
  gap: var(--s3);
  flex: 1 1 420px;
  min-width: 0;
}

.timer-panel__fields .field {
  margin-bottom: 0;
}

.timer-panel__project {
  flex: 0 0 220px;
  min-width: 0;
}

.timer-panel__description {
  flex: 1 1 auto;
  min-width: 0;
}

.timer-panel__action {
  display: flex;
  align-items: center;
  gap: var(--s5);
}

/* The one piece of state people check a hundred times a day. */
.timer-counter {
  display: block;
  font-size: var(--text-counter);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.timer-counter--running {
  color: var(--green);
}

.timer-counter__label {
  display: block;
  margin-bottom: var(--s1);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.btn--timer {
  min-width: 130px;
  padding: var(--s3) var(--s6);
  font-size: var(--text-body);
}

/* The only coloured button in the application. */
.btn--running {
  background: var(--green);
  border-color: var(--green);
}

.btn--running:hover {
  background: #55700a;
  border-color: #55700a;
}

@media (max-width: 620px) {
  .timer-panel__fields {
    flex-direction: column;
    flex-basis: 100%;
  }

  .timer-panel__project {
    flex: 1 1 auto;
  }

  .timer-panel__action {
    flex: 1 1 100%;
    justify-content: space-between;
  }
}

/* --- Day groups ----------------------------------------------------------- */

.day {
  margin-bottom: var(--s6);
}

.day__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s2);
  padding-bottom: var(--s2);
  border-bottom: 2px solid var(--ink);
}

.day__title {
  font-size: var(--text-body);
  font-weight: 700;
}

.day__total {
  font-size: var(--text-body);
  font-weight: 700;
}

/* --- Editing in place ----------------------------------------------------- */

/* Reads as text until you go near it, so a dense table stays a table. */
.inline-form {
  margin: 0;
}

.cell-edit {
  min-width: 160px;
  padding: var(--s1) var(--s2) !important;
}

.inline-form select,
.inline-form input[type="text"] {
  padding: var(--s1) var(--s2);
  border-color: transparent;
  background: transparent;
  font-size: var(--text-dense);
}

.inline-form select:hover,
.inline-form input[type="text"]:hover,
.inline-form select:focus,
.inline-form input[type="text"]:focus {
  border-color: var(--line);
  background: var(--surface);
}

.inline-form--panel select,
.inline-form--panel input[type="text"] {
  padding: var(--s2) var(--s3);
  border-color: var(--line);
  background: var(--surface);
  font-size: var(--text-body);
}

.entry--running td {
  background: var(--surface-alt);
}

.entry--running .num {
  color: var(--green);
  font-weight: 700;
}
