/* Dayflow Server. Tokens follow the app: Utilities/DayflowTheme.swift and
   Views/UI/Settings/SettingsComponents.swift. */

@font-face {
  font-family: "Figtree";
  src: url("/assets/fonts/Figtree-VariableFont_wght.ttf") format("truetype");
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/InstrumentSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/InstrumentSerif-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --window-bg: radial-gradient(
    ellipse 120% 110% at 64% 100%,
    #ffe6cf 17%,
    #ffe6e0 33%,
    #d6e8ff 100%
  );
  --panel-fill: rgba(251, 251, 251, 0.55);
  --panel-border: #fafafa;
  --panel-glow: rgba(255, 255, 255, 0.25);
  --panel-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

  --text: rgba(0, 0, 0, 0.9);
  --text-strong: #333333;
  --text-secondary: rgba(0, 0, 0, 0.55);
  --text-meta: rgba(0, 0, 0, 0.4);
  --divider: rgba(0, 0, 0, 0.08);
  --subtle-fill: rgba(0, 0, 0, 0.05);
  --ink: rgb(64, 43, 0);

  --accent: #f3854b;
  --accent-text: #e8763d;

  --primary-fill: #ff9f6f;
  --primary-border: #f4c8b1;
  --primary-glow: rgba(255, 220, 203, 0.9);
  --primary-text: #ffffff;

  --secondary-fill: #fcf9f7;
  --secondary-border: #d0d0d0;
  --secondary-text: #727272;

  --input-fill: rgba(255, 255, 255, 0.9);
  --input-border: #e1e1e1;
  --card-fill: rgba(255, 255, 255, 0.75);
  --card-border: #f2eeec;
  --code-fill: rgba(255, 255, 255, 0.7);

  --good: rgb(64, 158, 82);
  --warn: rgb(219, 153, 26);
  --bad: rgb(194, 48, 48);

  --font-ui: "Figtree", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-display: "Instrument Serif", "New York", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --window-bg: linear-gradient(
      -15deg,
      rgb(48, 60, 91) 21%,
      rgb(49, 51, 72) 53%,
      rgb(59, 41, 75) 105%
    );
    --panel-fill: linear-gradient(140deg, rgba(39, 41, 58, 0.8), rgba(32, 39, 51, 0.8));
    --panel-border: #414141;
    --panel-glow: rgba(255, 255, 255, 0.2);
    --panel-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);

    --text: rgba(255, 255, 255, 0.92);
    --text-strong: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-meta: rgba(255, 255, 255, 0.45);
    --divider: rgba(255, 255, 255, 0.1);
    --subtle-fill: rgba(255, 255, 255, 0.08);
    --ink: rgb(255, 163, 120);

    --accent-text: #f77952;

    --primary-fill: #d1653e;
    --primary-border: #ea9265;
    --primary-glow: rgba(255, 135, 77, 0.9);

    --secondary-fill: rgba(104, 109, 138, 0.4);
    --secondary-border: #777777;
    --secondary-text: #dddddd;

    --input-fill: rgba(255, 255, 255, 0.1);
    --input-border: #666666;
    --card-fill: rgba(255, 255, 255, 0.12);
    --card-border: #717171;
    --code-fill: rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--window-bg) fixed;
  -webkit-font-smoothing: antialiased;
}

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

/* MARK: Glass panel */

.panel {
  background: var(--panel-fill);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow:
    inset 0 0 4px var(--panel-glow),
    var(--panel-shadow);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

/* MARK: Dashboard layout (SettingsView.swift: 160 pt sidebar, 600 pt content) */

.window {
  max-width: 920px;
  margin: 32px auto;
  padding: 32px 36px 48px;
  display: grid;
  grid-template-columns: 160px minmax(0, 600px);
  gap: 32px;
  min-height: calc(100vh - 64px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.brand img {
  width: 26px;
  height: 26px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.05;
  color: var(--text-strong);
}

.tab {
  display: block;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
}

.tab:hover {
  color: var(--text);
}

.tab.selected {
  background: var(--subtle-fill);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  font-size: 12px;
  color: var(--text-meta);
}

.sidebar-footer form {
  margin-top: 6px;
}

.content {
  min-width: 0;
}

.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 4px;
  color: var(--text-strong);
}

.page-subtitle {
  margin: 0 0 32px;
  color: var(--text-secondary);
}

/* MARK: Sections and rows (SettingsComponents.swift) */

.section + .section {
  margin-top: 44px;
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 0 8px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}

.row:last-child {
  border-bottom: none;
}

.row-label {
  font-size: 14px;
  font-weight: 600;
}

.row-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
  overflow-wrap: anywhere;
}

.row-value {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  max-width: 60%;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* MARK: Status (6 pt dot + 13 pt semibold label) */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.good {
  color: var(--good);
}
.status.warn {
  color: var(--warn);
}
.status.bad {
  color: var(--bad);
}
.status.muted {
  color: var(--text-meta);
}

/* MARK: Stat tiles (summary cards) */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}

.stats + .section {
  margin-top: 36px;
}

.stat {
  background: var(--card-fill);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  color: var(--accent-text);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* MARK: Buttons (primary, secondary, link) */

button,
.button {
  font-family: inherit;
  cursor: pointer;
}

.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--primary-border);
  background: var(--primary-fill);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: inset 0 0 4px var(--primary-glow);
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
}

.button-primary:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.button-primary:active {
  transform: translateY(0);
}

.button-secondary {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--secondary-border);
  background: var(--secondary-fill);
  color: var(--secondary-text);
  font-size: 12px;
  font-weight: 600;
}

.button-secondary:hover {
  color: var(--text);
}

.button-secondary.destructive {
  color: var(--bad);
}

.button-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.button-link::after {
  content: " →";
}

form.inline {
  display: inline;
  margin: 0;
}

/* MARK: Inputs */

.field {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-fill);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}

.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 133, 75, 0.18);
}

.field.code {
  font-size: 26px;
  letter-spacing: 10px;
  text-align: center;
  font-weight: 600;
}

/* MARK: Table */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}

.table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-meta);
  padding: 8px 6px;
  border-bottom: 1px solid var(--divider);
}

.table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}

.table .nowrap {
  white-space: nowrap;
}

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

.table tr:last-child td {
  border-bottom: none;
}

.error-text {
  color: var(--bad);
  font-size: 11px;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.empty {
  padding: 28px 0;
  color: var(--text-meta);
  text-align: center;
  font-size: 13px;
}

/* MARK: Code blocks with copy */

.code-block {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 4px;
  padding: 8px 8px 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--divider);
  background: var(--code-fill);
}

.code-block pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 5px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre;
}

.code-block .copy {
  flex-shrink: 0;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 14px 0 14px 34px;
  border-bottom: 1px solid var(--divider);
}

.steps > li:last-child {
  border-bottom: none;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-fill);
  border: 1px solid var(--primary-border);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.flash {
  margin: 0 0 24px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--card-fill);
  border: 1px solid var(--card-border);
}

.flash.bad {
  color: var(--bad);
}

/* MARK: Sign-in */

.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.signin-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 32px;
  text-align: center;
}

.signin-card img.logo {
  width: 44px;
  height: 44px;
}

.signin-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.05;
  margin: 14px 0 6px;
  color: var(--text-strong);
}

.signin-title em {
  color: var(--accent-text);
}

.signin-subtitle {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

.signin-card form {
  display: grid;
  gap: 12px;
}

.signin-card .button-primary {
  padding: 12px 18px;
  font-size: 15px;
  border-radius: 10px;
}

.signin-footer {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-meta);
}

@media (max-width: 760px) {
  .window {
    grid-template-columns: 1fr;
    margin: 0;
    border-radius: 0;
    padding: 24px 20px;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .brand {
    width: 100%;
    margin-bottom: 8px;
  }
  .sidebar-footer {
    display: none;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
