/* TimeTracking shared component styles, layered on top of Pico CSS.
   Theme-specific colours and layout live in classic.css and modern.css. */
:root {
  --tt-accent: #2f7d6d;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
.muted { color: var(--pico-muted-color); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.narrow { max-width: 42rem; margin-inline: auto; }

.dev-banner {
  background: #b3261e; color: #fff; text-align: center; font-weight: 600;
  padding: .3rem; font-size: .85rem; letter-spacing: .05em;
}

.flash { padding: .75rem 1rem; border-radius: var(--pico-border-radius); }
.flash-ok { background: #e3f4ee; color: #135243; }
.flash-err, .form-error { background: #fdecea; color: #8a1c13; padding: .75rem 1rem; border-radius: var(--pico-border-radius); }
/* Dark colours: explicit choice via the toggle, or the OS setting when no choice is saved. */
[data-theme=dark] .flash-ok { background: #173a31; color: #c7f0e2; }
[data-theme=dark] .flash-err, [data-theme=dark] .form-error { background: #4a1a16; color: #ffd9d4; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .flash-ok { background: #173a31; color: #c7f0e2; }
  :root:not([data-theme=light]) .flash-err, :root:not([data-theme=light]) .form-error { background: #4a1a16; color: #ffd9d4; }
}

.theme-toggle {
  background: none; border: 1px solid var(--pico-muted-border-color); border-radius: 50%;
  width: 2.25rem; height: 2.25rem; padding: 0; margin: 0; line-height: 1; font-size: 1.05rem;
  cursor: pointer; color: inherit;
}
.theme-toggle:hover { border-color: var(--pico-primary); }

.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; padding: 0; margin: 0; width: auto;
  color: var(--pico-primary); cursor: pointer; font-size: inherit;
}
.link-button:hover { text-decoration: underline; }
.danger-link { color: #b3261e; }
button.danger { background: #b3261e; border-color: #b3261e; }
.small-link { font-size: .875rem; }
.button-row { display: flex; gap: 1rem; align-items: center; }
.button-row > * { width: auto; margin-bottom: 0; }

.badge {
  display: inline-block; font-size: .7rem; padding: .1rem .45rem; border-radius: 1rem;
  background: var(--pico-muted-border-color); color: var(--pico-muted-color);
  vertical-align: middle; margin-left: .25rem;
}
.badge-admin { background: var(--tt-accent); color: #fff; }
.badge-employee { background: var(--pico-primary-focus, #e8e7fd); color: var(--pico-color); }
.badge-warn { background: #fdecc8; color: #7a4b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .badge-warn { background: #4a3510; color: #ffdd9e; } }
[data-theme=dark] .badge-warn { background: #4a3510; color: #ffdd9e; }

/* Login */
.login-card { max-width: 26rem; margin: 3rem auto; text-align: center; }
.login-card form { text-align: left; }
.google-button { display: inline-flex; align-items: center; gap: .6rem; width: 100%; justify-content: center;
  background: #fff; color: #1f1f1f; border: 1px solid #747775; }
.google-button:hover { background: #f5f5f5; color: #1f1f1f; }

/* Home */
.home-grid { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) { .home-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.week-header { display: flex; align-items: center; gap: 1rem; }
.week-header h2 { margin: 0; flex: 0 1 auto; }
.week-header a[aria-label] { font-size: 1.5rem; text-decoration: none; }
.week-total { margin: .5rem 0 1rem; font-size: 1.1rem; }
.day { border-top: 1px solid var(--pico-muted-border-color); padding: .5rem 0; }
.day-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-weight: 600; font-size: .9rem; }
.day-title { margin: 0; font-size: inherit; font-weight: inherit; color: inherit; }
.day-meta { display: inline-flex; align-items: center; gap: .75rem; }
.add-link { font-weight: 500; }
.day-future .day-title { opacity: .7; }
.day-empty .day-header { font-weight: 400; color: var(--pico-muted-color); }
.entry { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0 .4rem .75rem; }
.entry-main { flex: 1; min-width: 0; }
.entry-note { margin: .15rem 0 0; color: var(--pico-muted-color); font-size: .9rem; white-space: pre-line; overflow-wrap: anywhere; }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.entry-actions { display: inline-flex; gap: .6rem; }
.entry-time { font-weight: 600; font-variant-numeric: tabular-nums; }

.danger-zone summary { color: #b3261e; }

/* Admin */
.admin-grid { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) { .admin-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }

.project { border-bottom: 1px solid var(--pico-muted-border-color); padding: .5rem 0; }
.project-row { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; }
.project-row.child { padding-left: 1.25rem; }
.row-actions { display: flex; gap: 1rem; white-space: nowrap; }

/* Reports */
.filters { margin-bottom: 2rem; }
.presets { display: flex; flex-wrap: wrap; gap: 1rem; }
.checklist { max-height: 14rem; overflow-y: auto; border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius); padding: .5rem 1rem; }
.checklist label { font-size: .9rem; }
.checklist label.child { padding-left: 1.25rem; }
.report-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.report-head a[role=button] { width: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; }
.stat { text-align: center; margin: 0; padding: 1rem; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--pico-muted-color); font-size: .85rem; }
.charts { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); margin-top: 1rem; }
.charts article { margin: 0; }
.bar-row { display: grid; grid-template-columns: 8rem 1fr 3.5rem; gap: .5rem; align-items: center; margin-bottom: .35rem; font-size: .85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.preset[aria-current] { font-weight: 700; text-decoration: underline; }
details.filters > summary { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; }
.filter-summary { color: var(--pico-muted-color); font-size: .9rem; font-weight: 400; }
.bar { width: 100%; height: .9rem; }
.bar rect { fill: var(--tt-accent); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.split { width: 100%; height: 1.5rem; border-radius: 4px; }
.split-billable, .key-billable { fill: var(--tt-accent); background: var(--tt-accent); }
.split-non, .key-non { fill: #b8c4c2; background: #b8c4c2; }
.legend { font-size: .85rem; margin-top: .5rem; }
.key { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: middle; }
.report-group { margin-top: 1.5rem; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; }
.group-head h3 { margin: 0; }
.note-cell { max-width: 24rem; overflow-wrap: anywhere; font-size: .875rem; }
.entries-detail { margin-top: 2rem; }

/* ---- Settings: theme picker (shared by all themes) ---- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.theme-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; border: 0; padding: 0; margin: 0 0 1rem; }
.theme-option {
  display: flex; flex-direction: column; gap: .6rem; margin: 0; padding: .75rem;
  border: 2px solid var(--pico-muted-border-color); border-radius: 12px; cursor: pointer;
}
.theme-option:hover { border-color: var(--pico-primary-hover, var(--pico-primary)); }
.theme-option:has(input:checked) { border-color: var(--pico-primary); box-shadow: 0 0 0 3px var(--pico-primary-focus, transparent); }
.theme-option input[type=radio] { margin: 0 .35rem 0 0; }
.theme-option-text { display: flex; flex-direction: column; gap: .25rem; }
.theme-preview {
  position: relative; display: block; width: 100%; height: 6rem; overflow: hidden;
  border-radius: 8px; border: 1px solid rgba(0, 0, 0, .1);
}
.theme-preview > span { position: absolute; display: block; }
/* Modern preview: indigo app bar, sidebar, elevated cards, FAB */
.preview-modern { background: #f3f4fa; }
.preview-modern .pv-bar { inset: 0 0 auto 0; height: 1.1rem; background: linear-gradient(90deg, #4338ca, #5b21b6); }
.preview-modern .pv-side { top: 1.1rem; bottom: 0; left: 0; width: 24%; background: #fff; border-right: 1px solid #e0e3ee; }
.preview-modern .pv-card { top: 1.7rem; left: 30%; width: 30%; height: 3rem; border-radius: 6px; background: #fff; box-shadow: 0 2px 6px rgba(23, 25, 45, .15); }
.preview-modern .pv-card2 { top: 1.7rem; left: 64%; width: 30%; height: 2rem; border-radius: 6px; background: #fff; box-shadow: 0 2px 6px rgba(23, 25, 45, .15); }
.preview-modern .pv-fab { right: 6%; bottom: 8%; width: 1.5rem; height: 1.5rem; border-radius: .45rem; background: #4f46e5; box-shadow: 0 3px 8px rgba(67, 56, 202, .45); }
/* Classic preview: white page, thin top nav, teal accents */
.preview-classic { background: #fff; }
.preview-classic .pv-bar { inset: 0 0 auto 0; height: 1.1rem; border-bottom: 1px solid #dfe3e6; background: #fff; }
.preview-classic .pv-bar::before { content: ""; position: absolute; left: 8%; top: .3rem; width: 25%; height: .45rem; border-radius: 3px; background: #2f7d6d; }
.preview-classic .pv-side { display: none; }
.preview-classic .pv-card { top: 1.8rem; left: 8%; width: 38%; height: 3.4rem; border: 1px solid #dfe3e6; border-radius: 6px; background: #fbfcfc; }
.preview-classic .pv-card2 { top: 1.8rem; left: 52%; width: 40%; height: .5rem; border-radius: 3px; background: #dfe3e6; box-shadow: 0 .9rem 0 #dfe3e6, 0 1.8rem 0 #dfe3e6; }
.preview-classic .pv-fab { left: 12%; top: 4.25rem; width: 1.6rem; height: .55rem; border-radius: 3px; background: #2f7d6d; }
.inline-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; }
.inline-row label { flex: 0 1 18rem; margin-bottom: 0; }
.inline-row button { width: auto; margin-bottom: 0; }

/* ---- Log/edit form: two columns so fields aren't cramped (both themes) ---- */
.entry-form .grid { grid-template-columns: 1fr 1fr; }
.entry-form .grid > label[for=duration] { grid-column: 1 / -1; order: -1; }

/* ---- Accessibility ---- */
:focus-visible { outline: 2px solid var(--pico-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Brand logo ---- */
.brand-logo { border-radius: 4px; }
.login-logo { display: block; margin: 0 auto 1rem; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }

/* ---- My time: tools, view toggle, people picker ---- */
.mytime-head { margin-bottom: 1rem; }
.mytime-tools { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; justify-content: space-between; }
.view-toggle { color: var(--pico-color); display: inline-flex; margin: 0; border: 1px solid var(--pico-muted-border-color); border-radius: 999px; overflow: hidden; }
.view-toggle .seg { margin: 0; border: 0; border-radius: 0; padding: .4rem 1rem; width: auto; box-shadow: none !important;
  background: transparent; color: var(--pico-color); font-size: .9rem; }
.view-toggle .seg:not(.seg-on) { color: inherit !important; background: transparent !important; }
.view-toggle .seg-on { background: var(--pico-primary-background); color: var(--pico-primary-inverse, #fff); }
.people-picker { display: inline-flex; gap: .5rem; align-items: center; margin: 0; }
.people-picker select { width: auto; min-width: 12rem; margin: 0; }
.people-picker button { width: auto; margin: 0; }
.viewing-banner { padding: .65rem 1rem; border-radius: var(--pico-border-radius); background: #fff4d6; color: #5a4300; }
[data-theme=dark] .viewing-banner { background: #3d3210; color: #ffe7a3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .viewing-banner { background: #3d3210; color: #ffe7a3; } }

/* ---- Timesheet grid ---- */
.timesheet { font-size: .92rem; min-width: 46rem; }
.timesheet th, .timesheet td { vertical-align: middle; }
.timesheet .ts-project { min-width: 12rem; font-weight: 600; }
.ts-client { display: block; font-weight: 400; }
.ts-cell { text-align: center; padding: .3rem .25rem; }
.ts-cell input { width: 4.6rem; margin: 0; padding: .3rem .35rem; text-align: center; font-variant-numeric: tabular-nums; }
.ts-cell input:disabled { opacity: .45; }
.ts-detail { display: block; font-size: .72rem; margin-top: .15rem; }
.ts-future { opacity: .6; }
.ts-total { font-weight: 600; white-space: nowrap; }
.timesheet .ts-day { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-status { display: block; font-size: .72rem; margin-top: .15rem; min-height: 1em; }
.ts-status.ok { color: #2e7d32; }
.ts-status.err { color: #b3261e; }
.ts-cell input.ts-saving { opacity: .7; }
.ts-cell input[aria-invalid=true] { border-color: #b3261e; }
.timesheet tfoot td, .timesheet tfoot th { font-weight: 600; }
.ts-actions { margin: .75rem 0 1.5rem; flex-wrap: wrap; }
.add-row-form select { min-width: 16rem; }

/* ---- Clients ---- */
.row-edit summary { cursor: pointer; }
.row-edit form { margin: .5rem 0 0; }
.badge-client { background: var(--pico-primary-focus, #e8e7fd); color: var(--pico-color); }

/* ---- Report builder ---- */
.report-builder .grid { align-items: end; }
.report-builder fieldset.inline-choices { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-bottom: 1rem; }
.report-builder fieldset.inline-choices legend { width: 100%; font-weight: 600; margin-bottom: .25rem; }
.report-builder fieldset.inline-choices label { margin: 0; }
.report-builder .builder-section { margin: 0 0 1rem; }
/* Help text inside choice labels stays inline (Pico makes <small> a block). */
.choice-help { font-size: .82rem; font-weight: 400; color: var(--pico-muted-color); }
.report-builder fieldset.inline-choices label { display: inline-flex; align-items: center; gap: .35rem; }
.report-builder .checklists { align-items: start; }
/* The filters section looks like something you can open. */
.report-builder .builder-section > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem;
  padding: .7rem 1rem; border: 1px solid var(--pico-muted-border-color); border-radius: .6rem;
  background: var(--pico-card-sectioning-background-color, transparent); cursor: pointer; list-style: none;
}
.report-builder .builder-section > summary::-webkit-details-marker { display: none; }
.report-builder .builder-section > summary::after { display: none; }
.report-builder .builder-section > summary:hover { border-color: var(--pico-primary); }
.report-builder .builder-section .section-title { font-weight: 600; }
.report-builder .builder-section .toggle-pill { margin-left: auto; font-size: .82rem; font-weight: 600; color: var(--pico-primary);
  padding: .15rem .7rem; border: 1px solid currentColor; border-radius: 999px; white-space: nowrap; }
.report-builder .builder-section .toggle-pill::before { content: "Show ▾"; }
.report-builder .builder-section[open] .toggle-pill::before { content: "Hide ▴"; }
.report-builder .builder-section[open] > summary { margin-bottom: 1rem; }
/* Delete: a real button, outlined in red. */
button.danger-outline { width: auto; background: transparent; color: #b3261e; border: 1px solid #b3261e; box-shadow: none; }
button.danger-outline:hover, button.danger-outline:focus-visible { background: #b3261e; color: #fff; border-color: #b3261e; }
.delete-report { margin: -.75rem 0 1.5rem; }
.report-builder .hint { display: block; margin-top: -.5rem; margin-bottom: .75rem; }
.save-report { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: end; margin: 0 0 1.5rem; }
.save-report label { margin: 0; flex: 1 1 16rem; }
.save-report input[type=text] { margin: 0; }
.save-report button { width: auto; margin: 0; }
.report-sections table { margin-bottom: .5rem; }
.report-sections h3 { margin: 1.25rem 0 .4rem; }
.grand-total { display: flex; justify-content: flex-end; gap: 2.5rem; padding-top: .75rem; border-top: 2px solid var(--pico-muted-border-color); flex-wrap: wrap; }
.grand-total div { display: flex; flex-direction: column; align-items: flex-end; }
.grand-total span { font-size: .8rem; color: var(--pico-muted-color); text-transform: uppercase; letter-spacing: .04em; }
.grand-total strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.saved-list td form { display: inline; margin: 0; }
.new-report-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin-bottom: 1.5rem; }
.new-report-cards article { margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.new-report-cards article p { margin: 0; flex: 1; }
.new-report-cards h3 { display: flex; align-items: center; gap: .5rem; margin: 0; }
.new-report-cards h3 svg { flex: none; width: 1.35rem; height: 1.35rem; fill: var(--tt-accent, currentColor); }
.report-title h2 { margin-bottom: .25rem; }
.report-doc .stats { margin-bottom: 1rem; }
.new-report-cards form { margin: 0; display: flex; gap: .5rem; flex-wrap: wrap; }
.new-report-cards select, .new-report-cards button, .new-report-cards [role=button] { width: auto; margin: 0; }

/* ---- Customer summary ---- */
.summary-actions { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.summary-actions [role=button] { width: auto; margin: 0; }
.summary-doc { max-width: 52rem; }
.summary-letterhead { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding-bottom: 1rem; border-bottom: 1px solid var(--pico-muted-border-color); margin-bottom: 1.25rem; }
.summary-company { display: flex; gap: .9rem; align-items: flex-start; }
.summary-company img { border-radius: 8px; }
.summary-company-name { font-size: 1.15rem; display: block; }
.summary-address { font-size: .9rem; color: var(--pico-muted-color); }
.summary-title { text-align: right; font-size: .92rem; }
.summary-title h2 { margin: 0 0 .25rem; }
.summary-project { margin-bottom: 1.25rem; }
.summary-project h3 { margin-bottom: .4rem; }
.summary-totals { display: flex; justify-content: flex-end; gap: 2.5rem; padding-top: .75rem; border-top: 2px solid var(--pico-muted-border-color); }
.summary-totals div { display: flex; flex-direction: column; align-items: flex-end; }
.summary-totals span { font-size: .8rem; color: var(--pico-muted-color); text-transform: uppercase; letter-spacing: .04em; }
.summary-totals strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.summary-notes { margin-top: 1.5rem; font-size: .88rem; color: var(--pico-muted-color); }
.summary-notes p { margin: 0 0 .25rem; }

/* ---- Printing (e.g. a customer summary): only the document ---- */
@media print {
  header.appbar, body > header, nav.sidebar, .fab, .dev-banner, .no-print, footer.container, .flash, .theme-toggle { display: none !important; }
  .shell { display: block !important; }
  .content, main.container { padding: 0 !important; max-width: none !important; }
  body, .theme-modern article { background: #fff !important; color: #000 !important; box-shadow: none !important; border: 0 !important; }
}

/* ---- Checkboxes, radios and switches: clearly visible when off ---- */
input[type=checkbox]:not(:checked):not([role=switch]), input[type=radio]:not(:checked) {
  border: 2px solid var(--tt-check-border, #7a8394);
  background-color: var(--tt-surface, var(--pico-background-color));
}
input[type=checkbox][role=switch]:not(:checked) {
  --pico-background-color: var(--tt-switch-off, #a3abb8);
  --pico-border-color: var(--tt-switch-off, #a3abb8);
  background-color: var(--tt-switch-off, #a3abb8);
  border-color: var(--tt-switch-off, #a3abb8);
}
input[type=checkbox][role=switch]::before { background-color: #fff; }
input[type=checkbox][role=switch]:checked {
  background-color: var(--pico-primary-background);
  border-color: var(--pico-primary-background);
}
