/*
 * ServiRota web — shared component layer.
 * Loaded last on every app page so the web reads like the mobile app:
 * the same fields, chips, pills, cards, list rows and type scale.
 */

:root {
  --accent: #3347e6;
  --accent-hover: #2638c9;
  --ink: #14161c;
  --paper: #f6f5f1;
  --tint: #eceeff;
  --line: #e8e5dd;
  --line-soft: #f0ede6;
  --input-line: #e8e5dd;
  --control-line: #dad6cc;
  --muted: #676b75;
  --secondary-ink: #4b4e57;
  --label-ink: #14161c;
  --card-radius: 20px;
  --control-radius: 14px;
  --shadow-card: 0 1px 2px rgb(20 22 28 / 4%), 0 10px 28px -14px rgb(20 22 28 / 12%);
  --shadow-action: 0 8px 18px -8px rgb(51 71 230 / 70%);
  --ring: 0 0 0 4px rgb(51 71 230 / 14%);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* Page entrance: content eases in instead of popping. */
@media (prefers-reduced-motion: no-preference) {
  .app-main { animation: sr-enter .32s var(--ease) both; }
  .app-main .card, .app-main .service-list > li, dialog[open] { animation: sr-enter .28s var(--ease) both; }
  .app-main .card:nth-of-type(2) { animation-delay: .03s; }
  .app-main .card:nth-of-type(3) { animation-delay: .06s; }
  .app-main .card:nth-of-type(4) { animation-delay: .09s; }
  dialog[open]::backdrop { animation: sr-fade .2s ease both; }
  :is(button, .app-action, .primary-link, .quiet-action, .app-nav a) { transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease; }
  :is(button, .app-action, .primary-link):active:not(:disabled) { transform: scale(.98); }
}
@keyframes sr-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sr-fade { from { opacity: 0; } to { opacity: 1; } }

/* Type */
.app-main h1, .guest h1 { font-weight: 650; letter-spacing: -.035em; line-height: 1.1; }
.app-main h2, .guest h2 { font-size: 1.125rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.app-main h3, .guest h3 { font-weight: 650; letter-spacing: -.01em; }
.eyebrow {
  margin-block: 0 .35rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.record-detail, .services-intro p:not(.eyebrow) { color: var(--muted); }

/* Cards */
.card, .app-main .card {
  border-color: var(--line);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-card);
}

/* Fields: one look for every input, select and textarea in the app. */
:is(.app-main, .guest, dialog, .content-dialog) :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]),
  select, textarea) {
  width: 100%;
  min-height: 48px;
  padding: .7rem .95rem;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background-color: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .9375rem;
  box-shadow: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
:is(.app-main, .guest, dialog, .content-dialog) :is(input, select, textarea)::placeholder { color: var(--muted); }
:is(.app-main, .guest, dialog, .content-dialog) :is(input, select, textarea):hover:not(:disabled) { border-color: var(--control-line); }
:is(.app-main, .guest, dialog, .content-dialog) :is(input, select, textarea):focus { border-color: var(--accent); outline: none; box-shadow: var(--ring); }
:is(.app-main, .guest, dialog, .content-dialog) :is(input, select, textarea):focus-visible { outline: none; }
:is(.app-main, .guest, dialog, .content-dialog) select {
  appearance: none;
  padding-inline-end: 2.5rem;
  background-image: url("/ui/chevron-down.svg");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  background-size: 16px;
  cursor: pointer;
}
:is(.app-main, .guest, dialog) textarea { min-height: 7rem; line-height: 1.5; resize: vertical; }
:is(.app-main, .guest, dialog) input[type="date"], :is(.app-main, .guest, dialog) input[type="datetime-local"] { font-variant-numeric: tabular-nums; }
:is(.app-main, .guest, dialog) input[type="file"] {
  width: 100%;
  min-height: 48px;
  padding: .4rem;
  border: 1px dashed var(--control-line);
  border-radius: var(--control-radius);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
}
:is(.app-main, .guest, dialog) input[type="file"]::file-selector-button {
  margin-inline-end: .75rem;
  min-height: 38px;
  padding: 0 1rem;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
:is(.app-main, .guest, dialog) :is(input[type="checkbox"], input[type="radio"]) {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
  cursor: pointer;
}
:is(.app-main, .guest, dialog) label:not(.choice):not(.module-option) > span:first-child,
:is(.app-main, .guest, dialog) label:not(.choice):not(.module-option) { font-size: .8125rem; font-weight: 600; color: var(--label-ink); }
:is(.app-main, .guest, dialog) label :is(input, select, textarea) { font-weight: 400; }
:is(.app-main, .guest, dialog) .choice { font-size: .9375rem; font-weight: 500; }
:is(.app-main, .guest, dialog) fieldset { border-color: var(--line); border-radius: var(--control-radius); }
:is(.app-main, .guest, dialog) legend { font-size: .8125rem; font-weight: 650; }

/* Buttons */
button { font-weight: 600; }
button:not(.quiet-action):not(.app-action):not(.sidebar-bell):not(.sidebar-branch):not([role="tab"]):not(.sidebar-picker-choice):not(.planning-calendar button) {
  min-height: 46px;
  padding-inline: 1.15rem;
  border-radius: var(--control-radius);
}
:is(.app-main, dialog) button:not(.quiet-action):not(.app-action):not([role="tab"]):not(.app-switcher button):not(.service-status-tabs button):not(.planning-calendar button):not(.customer-list button):not(.intake-issue-suggestions button):not(.sidebar-picker-choice):not(.danger-action):not(:disabled):hover { background-color: var(--accent-hover); }
.app-primary, .app-main form button[type="submit"], dialog form button[type="submit"], .primary-link { box-shadow: var(--shadow-action); }
.primary-link:hover { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.danger-action { background: #b42318; }
.danger-action:hover:not(:disabled) { background: #96190f !important; }

/* Secondary pills: the many inline actions on records ("Düzenle", "Yetkileri gör", …). */
.quiet-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 38px;
  padding: .35rem .95rem;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}
.quiet-action:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: #fff; }
.quiet-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quiet-action[aria-pressed="true"], .quiet-action[aria-current="page"], .quiet-action[aria-current="true"], .quiet-action[aria-selected="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.app-action-secondary { border-color: var(--control-line); }
.app-action-secondary:hover { border-color: var(--accent); background: #fff; color: var(--accent); }
.app-card-action { background: var(--tint); color: var(--accent); }
.app-action { border-radius: var(--control-radius); }

/* Tab-like switchers read as chips, the selected one filled. */
.app-switcher { gap: .5rem; }
.app-switcher :is(button, a) {
  min-height: 40px;
  padding: .35rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: none;
}
.app-switcher :is(button, a):hover { border-color: var(--control-line); background: #fff; color: var(--ink); }
.app-switcher :is([aria-current="page"], [aria-current="true"], [aria-pressed="true"], [aria-selected="true"]) {
  border-color: var(--ink) !important;
  background: var(--ink) !important;
  color: #fff !important;
}
.service-status-tabs button { min-height: 38px; border-color: var(--line); color: var(--ink); font-weight: 500; }

/* Links inside running text */
.app-main :is(p, dd, .form-actions, #help-topics) > a:not(.app-action):not(.primary-link):not(.quiet-action):not(.secondary-link) {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  text-underline-offset: 3px;
}
.app-main :is(p, dd, .form-actions, #help-topics) > a:not(.app-action):not(.primary-link):not(.quiet-action):hover { text-decoration: underline; }
#help-topics :is(h2, h3) a { color: var(--ink); text-decoration: none; }
#help-topics :is(h2, h3) a:hover { color: var(--accent); }
.secondary-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.secondary-link:hover { text-decoration: underline; }

/* Lists of records: white rows with soft dividers inside a rounded group. */
.service-list { gap: .75rem; }
.service-list > li {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(20 22 28 / 3%);
}
.card .service-list > li { box-shadow: none; }
.service-list h3 { font-size: 1rem; font-weight: 650; }
.service-list .form-actions { margin-block-start: .65rem; gap: .5rem; }
.record-tag { background: var(--tint); color: var(--accent); font-weight: 600; }

/* Detail lists */
:is(.app-main, dialog) dl dt { color: var(--muted); font-size: .8125rem; font-weight: 600; }
:is(.app-main, dialog) dl dd { color: var(--ink); }

/* Status, feedback */
:is(.services-error, .account-error, .customer-error):not(:empty) {
  padding: .75rem 1rem;
  border-radius: var(--control-radius);
  background: #fde3e0;
  color: #a12b14;
  font-weight: 500;
}
.status { background: var(--tint); }

/* Dialogs read as sheets */
dialog, .content-dialog, .sidebar-picker {
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 80px -20px rgb(20 22 28 / 35%);
}
dialog::backdrop, .content-dialog::backdrop { background: rgb(20 22 28 / 45%); backdrop-filter: blur(2px); }

/* Details / disclosure groups */
.option-group { background: #fff; border-color: var(--line); }
.option-group summary { list-style: none; display: flex; align-items: center; justify-content: space-between; }
.option-group summary::-webkit-details-marker { display: none; }
.option-group summary::after { content: ""; width: 16px; height: 16px; background: center/contain no-repeat url("/ui/chevron-down.svg"); transition: transform .16s ease; }
.option-group[open] summary::after { transform: rotate(180deg); }

/* Preview and helper panels */
.template-preview, .admin-preview, .lifecycle-preview { background: var(--paper); border: 1px solid var(--line); }
.storage-note { border-inline-start-color: var(--accent); }

/* Sidebar navigation polish */
.app-nav :is(a, button, .app-nav-current), .app-nav summary { border-radius: 12px; }
.app-nav [aria-current="page"] { background: var(--tint); color: var(--accent); }
.sidebar-search, .app-sidebar .sidebar-branch { border-color: var(--line); }

/* Planning month grid */
.planning-calendar button { min-height: 52px; border-radius: 12px; border-color: var(--line); font-weight: 600; }
.planning-calendar button:hover { border-color: var(--accent); }
.planning-calendar button[data-visits] { background: var(--tint); border-color: #d5d9ff; }

/* Records tools (reports, help, transfer) */
.records-tools dl > div { border-color: var(--line); border-radius: 14px; background: #fff; }
.records-tools dd { font-size: 1.375rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.records-tools li { border-block-end: 1px solid var(--line-soft); }
.records-tools li:last-child { border-block-end: 0; }

/* Help topics read as tappable rows */
#help-topics { display: grid; gap: 0; margin-block: .75rem; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
#help-topics > * { margin: 0; padding: .9rem 1.1rem; }
#help-topics > * + * { border-block-start: 1px solid var(--line-soft); }
#help-topics :is(h3, h2) { margin: 0 0 .25rem; font-size: 1rem; }
#help-topics a { display: inline-flex; align-items: center; gap: .35rem; }

@media (max-width: 899px) {
  .app-main h1 { font-size: 1.75rem; }
  .service-list > li { padding: .9rem 1rem; }
}

/* ---------------------------------------------------------------
 * Page headers: one eyebrow, title and lede on every page.
 * ------------------------------------------------------------- */
.app-main .eyebrow, .services-list-page #services-scope, .account-intro .eyebrow, .account-overview-heading .eyebrow {
  margin-block: 0 .35rem;
  color: var(--muted);
  font: 600 .75rem/1.4 var(--font-sans, inherit);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.page-lede {
  max-width: 62ch;
  margin-block: .45rem 1.5rem;
  color: var(--secondary-ink);
  font-size: 1.0625rem;
  line-height: 1.5;
}
.app-main > h1 + .page-lede, .app-main > header h1 + .page-lede { margin-block-start: .5rem; }

/* Search fields that carry an icon keep room for it. */
.services-list-page .service-search input { padding-inline-start: 2.875rem !important; }

/* Secondary submits ("Ara", "Dışa aktar") stay flat; only primary actions glow. */
.app-main .service-search button[type="submit"], .app-main form button.quiet-action[type="submit"],
.app-main .service-search button { box-shadow: none; }

/* Status pills never break across lines. */
.services-badge, .records-tools .status, .record-tag { white-space: nowrap; }

/* Toggle switches keep their switch shape. */
.configuration .config-switch input[type="checkbox"] { width: 2.75rem; height: 1.6rem; }

/* ---------------------------------------------------------------
 * Person and customer rows: initials, name, detail, chevron — as in the app.
 * ------------------------------------------------------------- */
.record-avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tint);
  color: #2336b8;
  font-size: .8125rem;
  font-weight: 650;
  letter-spacing: .02em;
}
.record-text { display: grid; flex: 1; gap: .1rem; min-width: 0; }
.record-text strong { overflow: hidden; color: var(--ink); font-size: .9375rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.record-text small { overflow: hidden; color: var(--muted); font-size: .8125rem; text-overflow: ellipsis; white-space: nowrap; }
.record-head { display: flex; align-items: flex-start; gap: .85rem; }
.record-head .record-text :is(h3, p) { margin: 0; }
.record-head .record-text h3 { margin-block-end: .2rem; }
.record-head .record-text p + p { margin-block-start: .1rem; }
.service-list .record-head + .form-actions { margin-inline-start: calc(40px + .85rem); }

.customer-list { display: grid; gap: 0; margin: .5rem 0 1rem; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.customer-list:empty { display: none; }
.customer-list li + li { border-block-start: 1px solid var(--line-soft); }
.app-main .customer-list button.record-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  width: 100%;
  min-height: 64px;
  padding: .6rem .9rem;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  text-align: start;
  box-shadow: none;
}
.app-main .customer-list button.record-row:hover { background: var(--paper); color: var(--ink); }
.app-main .customer-list button.record-row[aria-current="true"] { background: var(--tint); }
.customer-list .record-row > .app-icon { width: 18px; height: 18px; color: var(--muted); }

.customer-list .record-text strong { white-space: normal; overflow-wrap: anywhere; }
.customer-search .quiet-action[type="submit"] { min-height: 48px; padding-inline: 1.1rem; border-radius: var(--control-radius); font-size: .875rem; }
@media (min-width: 900px) { .customer-layout { grid-template-columns: minmax(18rem, 1fr) minmax(0, 1.8fr); } }

/* ---------------------------------------------------------------
 * Service table (desktop): one line per row, the whole row opens the record.
 * ------------------------------------------------------------- */
@media (min-width: 900px) {
  .services-table col:nth-child(1) { width: 13%; }
  .services-table col:nth-child(3) { width: 17%; }
  .services-table col:nth-child(4) { width: 18%; }
  .services-table col:nth-child(5) { width: 14%; }
  .services-table col:nth-child(6) { width: 17%; }
  .services-list-page .services-table tbody tr { cursor: pointer; }
  .services-list-page .services-table td:last-child { white-space: nowrap; }
  .services-list-page .services-table td:last-child > span { vertical-align: middle; }
  .services-list-page .services-table td:last-child button.quiet-action {
    display: inline-flex;
    width: 34px;
    min-height: 34px;
    height: 34px;
    margin: 0 0 0 .5rem;
    padding: 0;
    vertical-align: middle;
    background: #fff url("/ui/chevron-right.svg") center / 16px no-repeat;
    color: transparent;
    font-size: 0;
  }
  .services-list-page .services-table td:last-child button.quiet-action:hover { border-color: var(--accent); background-color: var(--tint); }
}

/* ---------------------------------------------------------------
 * Workspace home
 * ------------------------------------------------------------- */
.workspace-recent li a { text-decoration: none; }
.workspace-recent li a:hover { color: var(--accent); text-decoration: none; }

/* ---------------------------------------------------------------
 * Phone widths: the same cards and grids as the mobile app.
 * ------------------------------------------------------------- */
@media (max-width: 899px) {
  .page-lede { margin-block-end: 1.1rem; font-size: 1rem; }

  /* Service rows become the app's service cards. */
  .services-list-page .services-table tbody tr {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .35rem 0;
    padding: 1rem;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-card);
  }
  .services-list-page .services-cell-caption { display: none; }
  .services-list-page .services-table td:nth-child(1) { grid-row: 1; grid-column: 1; display: flex; align-items: baseline; gap: .5rem; }
  .services-list-page .services-table td:nth-child(4) { grid-row: 1; grid-column: 2; justify-self: end; padding-inline-start: .75rem; }
  .services-list-page .services-table td:nth-child(2) { grid-row: 2; grid-column: 1 / -1; margin-block-start: .35rem; }
  .services-list-page .services-table td:nth-child(3) { grid-row: 3; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .1rem .5rem; color: var(--secondary-ink); }
  .services-list-page .services-table td:nth-child(5) {
    grid-row: 4; grid-column: 1;
    align-self: center;
    margin-block-start: .5rem; padding-block-start: .7rem !important;
    border-block-start: 1px solid var(--line-soft) !important;
    color: var(--secondary-ink); font-size: .875rem;
  }
  .services-list-page .services-table td:nth-child(6) {
    grid-row: 4; grid-column: 2;
    display: flex; align-items: center; justify-content: flex-end; gap: .6rem;
    margin-block-start: .5rem; padding-block-start: .7rem !important;
    border-block-start: 1px solid var(--line-soft) !important;
    color: var(--muted); font-size: .8125rem;
  }
  .services-list-page .services-table td:nth-child(6) button { min-height: 34px; padding-inline: .8rem; }
  .services-list-page .services-row-title strong { font-size: 1rem; }

  /* Date range stays on one line. */
  .services-list-dates { flex-basis: 100%; }

  /* Search field and its button share a line. */
  .services-list-page .service-search { grid-template-columns: minmax(0, 1fr) auto !important; }
  .services-list-page :is(.service-search > label, .services-list-dates label) { grid-column: auto; }
  .services-list-page .services-table td:nth-child(1) { white-space: nowrap; }
  .services-list-page .services-table td:nth-child(1) .services-cell-secondary { margin: 0; }

  /* Metric tiles: two per row; an odd last tile spans the row. */
  .records-tools dl.records-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Lists of people keep actions under the text, not under the avatar. */
  .service-list .record-head + .form-actions { margin-inline-start: 0; }
}

@media (max-width: 560px) {
  .workspace-counts:has([data-metric="todayVisits"]) > :last-child:nth-child(even),
  .workspace-counts:not(:has([data-metric="todayVisits"])) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* First-run guide on the web home */
.workspace-welcome { display: grid; gap: .75rem; margin-block: .5rem 1rem; }
.workspace-welcome ol { margin: 0; padding-inline-start: 1.25rem; display: grid; gap: .35rem; }
