/*
 * app.css -- compact overrides on top of Sneat core.css, plus the few layout
 * rules Sneat keeps in demo.css. No SCSS build needed: the sidebar reads CSS
 * variables, and the rest is plain cascade.
 */

:root, [data-bs-theme] {
  /* Tighter sidebar */
  --bs-menu-width: 14.5rem;
  --bs-menu-collapsed-width: 4.5rem;
  --bs-menu-item-spacer: 0.0625rem;
  --bs-menu-vertical-link-padding-y: 0.3rem;
  --bs-menu-vertical-link-padding-x: 0.8rem;
  --bs-menu-vertical-menu-link-padding-y: 0.25rem;
  --bs-menu-vertical-menu-level-spacer: 0.5rem;
}

/* Base type one notch smaller than Sneat's 15px default */
html { font-size: 14px; }
body { font-size: 0.9286rem; line-height: 1.4; }
h1, .h1 { font-size: 1.85rem; } h2, .h2 { font-size: 1.55rem; } h3, .h3 { font-size: 1.3rem; }
h4, .h4 { font-size: 1.15rem; } h5, .h5 { font-size: 1rem; }   h6, .h6 { font-size: 0.9286rem; }

/* Compact controls */
.btn { padding: 0.36rem 0.9rem; font-size: 0.9286rem; }
.btn-sm { padding: 0.22rem 0.6rem; font-size: 0.8125rem; }
.btn-icon { width: calc(1.5em + 0.72rem + 2px); height: calc(1.5em + 0.72rem + 2px); }
.btn-icon.btn-sm { width: calc(1.5em + 0.44rem + 2px); height: calc(1.5em + 0.44rem + 2px); }
.btn:hover { transform: none; }
.form-control { padding: 0.4rem 0.75rem; font-size: 0.9286rem; }
.form-control-sm { padding: 0.25rem 0.6rem; font-size: 0.8125rem; }
/* Longhands only: the shorthand would reset the right gutter core.css reserves for the caret */
.form-select { padding-top: 0.4rem; padding-bottom: 0.4rem; padding-left: 0.75rem; font-size: 0.9286rem; }
.form-select-sm { padding-top: 0.25rem; padding-bottom: 0.25rem; padding-left: 0.6rem; font-size: 0.8125rem; }
.form-label { margin-bottom: 0.25rem; font-size: 0.8571rem; }
.input-group-text { padding: 0.4rem 0.75rem; }
.card .card-header { padding: 0.9rem 1.25rem; }
.card .card-body { padding: 1.25rem; }
.card-title { margin-bottom: 0.5rem; }
.table > :not(caption) > * > * { padding: 0.5rem 0.9rem; }
.table-sm > :not(caption) > * > * { padding: 0.3rem 0.6rem; }

/* Data tables inside cards (.table-wrap / .app-table) */
.app-table { margin-bottom: 0; }
.app-table > :not(caption) > * > * { padding: 0.7rem 0.9rem; vertical-align: middle; }
.app-table > :not(caption) > * > :first-child { padding-left: 1.25rem; }
.app-table > :not(caption) > * > :last-child { padding-right: 1.25rem; }
.app-table > thead > tr > th {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--bs-secondary-color); background: color-mix(in srgb, var(--bs-body-color) 5%, transparent);
  border-bottom: 1px solid var(--bs-border-color);
  white-space: nowrap;
}
.app-table > tbody > tr:last-child > td { border-bottom: 0; }
.app-table > tbody > tr:hover > td { background: color-mix(in srgb, var(--bs-body-color) 3%, transparent); }
.app-table .table-serial { width: 3.25rem; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; text-align: right; }
.app-table .table-actions { width: 1%; text-align: right; }
.app-table .avatar.avatar-sm { width: 1.85rem; height: 1.85rem; }
.app-table .avatar.avatar-sm .avatar-initial { font-size: 0.7rem; }
.table-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--bs-border-color);
}
.table-filters .form-select-sm { width: auto; min-width: 9rem; padding-right: 1.9rem; }
.table-filters-search { flex: 0 1 18rem; width: auto; }
.table-filters-search .input-group-text { padding-right: 0.25rem; color: var(--bs-secondary-color); }
.table-filters-search .input-group-text .bx { font-size: 1rem; }
.table-filters-search .form-control { padding-left: 0.4rem; }
/* Row count + rows-per-page sit at the right end of the filter row */
.table-filters-end { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-left: auto; }
.table-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.25rem;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--bs-border-color);
}
.table-count { font-size: 0.8571rem; color: var(--bs-secondary-color); }
.table-count strong { color: var(--bs-body-color); font-weight: 600; }
.table-page-size { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.8571rem; color: var(--bs-secondary-color); white-space: nowrap; }
.table-page-size .form-select-sm { min-width: 4.5rem; }
.table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 1.25rem; border-top: 1px solid var(--bs-border-color); }
.card > .table-wrap:first-child .table-toolbar, .card > .table-toolbar:first-child, .card > .table-filters:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.dropdown-item { padding: 0.4rem 1rem; }
.alert { padding: 0.65rem 1rem; }
/* Impersonation / support-access notice at the top of every page */
.support-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.support-banner > .bx { font-size: 1.35rem; }
.support-banner form { margin: 0; }
.modal-header { padding: 1rem 1.25rem; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 0.75rem 1.25rem; }
.badge { font-size: 0.75em; }
.breadcrumb { margin-bottom: 0.75rem; font-size: 0.8571rem; }

/* Menu chrome */
/* core.css positions the collapse pin for its own 16.25rem menu; follow ours */
.menu .app-brand .layout-menu-toggle { inset-inline-start: calc(var(--bs-menu-width) - 1.05rem); }
/* Icons inside buttons size from the button, not from .icon-base */
.btn .bx { font-size: 1.15em; vertical-align: -0.2em; }
.btn-icon .bx { font-size: 1.2rem; flex: none; inline-size: 1em; block-size: 1em; }
.btn-icon.btn-sm .bx { font-size: 1rem; }
.menu-vertical .menu-header { margin: 0.75rem 0 0.25rem; }
.menu-vertical .menu-header .menu-header-text { font-size: 0.75rem; }
.menu-vertical .menu-icon { font-size: 1.15rem; }
.menu .app-brand { height: 56px; margin-top: 8px; }
.app-brand-logo svg { width: 22px; height: 30px; }
.app-brand-text { font-size: 1.3rem; letter-spacing: -0.3px; }

/* Page gutter */
.container-p-y:not([class^="pb-"]):not([class*=" pb-"]) { padding-bottom: 1.25rem !important; }
.container-p-y:not([class^="pt-"]):not([class*=" pt-"]) { padding-top: 1.25rem !important; }

/* Keep the scrollbar track reserved so fixed elements never shift when a modal
   hides the page scrollbar; and restate the navbar inset for modal-open, because
   core.css hardcodes its own 16.25rem menu width there rather than the variable. */
html { scrollbar-gutter: stable; }
@media (min-width: 1200px) {
  .layout-menu-fixed.layout-navbar-fixed:not(.layout-menu-collapsed) .modal-open .layout-content-navbar:not(.layout-without-menu) .layout-navbar {
    inset-inline-start: var(--bs-menu-width);
  }
}

/* From Sneat demo.css: fixed navbar needs the page pushed down */
.layout-navbar-fixed .layout-wrapper:not(.layout-horizontal):not(.layout-without-menu) .layout-page { padding-top: 68px !important; }
.layout-navbar-fixed .layout-wrapper:not(.layout-without-menu) .layout-page { padding-top: 60px !important; }
.content-wrapper .navbar { z-index: auto; }
.layout-navbar { height: 3.6rem; }

/* Page header row: title left, actions right */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 1rem; }
.page-header h4 { margin: 0; }

/* Toasts */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: 0.5rem; }
#toast-container .toast { min-width: 18rem; }

/* htmx request state */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request .btn[type="submit"] { pointer-events: none; opacity: 0.7; }

/* Tables without DataTables: sortable headers and row actions */
th a.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort-link .bx { font-size: 0.9em; vertical-align: -0.1em; }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-left: 0.15rem; }
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--bs-secondary-color); }
.empty-state .bx { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* Public site */
.site-nav .nav-link { padding: 0.5rem 0.8rem; }
.site-nav .navbar-nav { flex-direction: row; align-items: center; }
.hero { padding: 4rem 0; }
.site-footer { padding: 1rem 0 0.5rem; font-size: 0.8571rem; background: var(--bs-body-bg); }
.site-footer .footer-heading { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bs-secondary-color); margin-bottom: 0.75rem; }
.site-footer .footer-links li { margin-bottom: 0.4rem; }
.site-footer .footer-links a { color: var(--bs-body-color); text-decoration: none; }
.site-footer .footer-links a:hover { color: var(--bs-primary); }
.site-footer .footer-bottom { color: var(--bs-secondary-color); }
.footer-brand { display: inline-flex; align-items: center; line-height: 0; }
.footer-brand img { height: auto; max-width: 100%; }
/* The wordmark is navy; give it a light plate in dark mode instead of inverting the brand colours. */
html[data-bs-theme="dark"] .footer-brand { background: #fff; border-radius: 4px; padding: 0.3rem 0.5rem; }

/* Campaign report: hourly opens/clicks without a chart library */
.timeline-chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; }
.timeline-slot { flex: 1 1 0; display: flex; align-items: flex-end; gap: 1px; height: 100%; min-width: 0; }
.timeline-bar { flex: 1 1 0; min-height: 1px; border-radius: 2px 2px 0 0; }
.timeline-opens { background: var(--bs-primary); }
.timeline-clicks { background: var(--bs-success); }
.timeline-key { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 2px; vertical-align: -1px; }

/* Campaign composer (static/js/campaign-editor.js) */
.campaign-editor-wrap { position: relative; }
/* Reserved before Quill initialises, so the page does not jump on load. */
#campaign-editor { min-height: 320px; }
#campaign-editor .ql-editor { min-height: 320px; }
#editor-source-wrapper textarea { font-family: var(--bs-font-monospace); font-size: 0.8125rem; }
/* "Tight lines". The editor has to show what the inbox will: without this the
   toolbar button applies the format and nothing visibly happens. Keep it the
   same rule rendering._EDITOR_CLASS_STYLES inlines for ql-compact-tight. */
#campaign-editor .ql-editor .ql-compact-tight { margin: 0; }
/* The inserted button, as the editor shows it. rendering.expand_buttons turns
   this marker into the table an inbox gets, so this styling is editor-only. */
#campaign-editor .email-cta {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  margin: 0.5rem 0;
  border-radius: 6px;
  background: var(--bs-primary);
  color: #fff;
  font-weight: 600;
  cursor: default;
  user-select: none;
}

/* Search-select picker (apps.core.widgets.SearchSelectMultiple, app.js) */
.search-select { position: relative; }
/* .form-control gives the border, radius and colours; the layout is ours. */
.search-select-control { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; height: auto; min-height: calc(1.53em + 0.876rem + 2px); cursor: text; }
.search-select-control:focus-within { border-color: var(--bs-primary); box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.16); }
.search-select-input { flex: 1 1 7rem; min-width: 7rem; border: 0; padding: 0; background: transparent; color: inherit; outline: 0; }
.search-select-chip { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; font-weight: 500; }
.search-select-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-select-chip .btn-close { --bs-btn-close-opacity: 0.6; width: 0.6em; height: 0.6em; padding: 0; }
.search-select-results { position: absolute; z-index: 5; left: 0; right: 0; margin-top: 0.25rem; max-height: 16rem; overflow-y: auto; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); box-shadow: var(--bs-box-shadow-sm); }
.search-select-option { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; padding: 0.4rem 0.75rem; border: 0; background: transparent; color: var(--bs-body-color); text-align: left; }
.search-select-option:hover, .search-select-option:focus, .search-select-option.is-active { background: var(--bs-secondary-bg); outline: 0; }
.search-select-note { margin: 0; padding: 0.5rem 0.75rem; font-size: 0.8125rem; color: var(--bs-secondary-color); }

/* Dashboard: daily activity, meters and share bars, without a chart library.
   Heights and widths are percentages computed in each app's analytics module;
   the only thing inline on an element is that one number. (Never write a path
   with a star inside a CSS comment: the slash-star pair ends it early and the
   rule that follows is eaten by the parser.) */
.day-chart { display: flex; align-items: flex-end; gap: 3px; height: 180px; }
.day-slot { flex: 1 1 0; display: flex; align-items: flex-end; gap: 1px; height: 100%; min-width: 0; }
.day-bar { flex: 1 1 0; min-height: 1px; border-radius: 2px 2px 0 0; }
.series-sends { background: rgba(var(--bs-primary-rgb), 0.35); }
.series-opens { background: var(--bs-primary); }
.series-clicks { background: var(--bs-success); }
.chart-key { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 2px; vertical-align: -1px; }
.meter { height: 6px; border-radius: 3px; background: var(--bs-secondary-bg); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; background: var(--bs-primary); }
.meter-fill.is-good { background: var(--bs-success); }
.meter-fill.is-bad { background: var(--bs-danger); }
.meter-fill.is-muted { background: var(--bs-secondary); }
.stat-delta { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.stat-delta .bx { vertical-align: -2px; }

/* Segment rule builder. One grid row per rule: field, operator, value, remove.
   It collapses to two columns on a phone rather than scrolling sideways, and
   the value column carries its own suffix ("days") beside the input. */
.rule-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.rule-value { display: flex; align-items: center; gap: 0.375rem; min-width: 0; }
.rule-value > :first-child { flex: 1 1 auto; min-width: 0; }
.rule-suffix { flex: 0 0 auto; font-size: 0.8125rem; color: var(--bs-secondary-color); }
.rule-suffix:empty { display: none; }
.rule-set-rows:empty + template + [data-rule-add] { margin-top: 0; }
@media (max-width: 767.98px) {
  .rule-row { grid-template-columns: minmax(0, 1fr) auto; }
  .rule-row [data-rule-field] { grid-column: 1 / -1; }
}
