/*
  The OLXR CRM dark theme.

  Built after measuring three interfaces that do this well - Linear,
  Vercel and Attio - rather than from an idea of what dark looks like. The
  numbers those three agree on are not the ones you would guess, and they
  are what the first attempt got wrong:

                        this, before      Linear        Vercel
    page                rgb(43,48,53)     rgb(8,9,10)   rgb(0,0,0)
    raised surface      same as page      rgb(15,16,17) rgb(10,10,10)
    border              solid grey        white 8%      white 14%
    corner radius       mixed             8px           6px
    body text           #dee2e6           #f7f8f8       #ededed

  Three things follow from that table and between them they are most of
  the difference.

  The page has to be properly dark. Bootstrap's dark body is a mid grey,
  and against a mid grey nothing can recede - every card, table and input
  has to be lighter still, so the whole screen drifts upwards into a
  uniform slab. Starting near black gives somewhere for things to sit.

  Separation is a hairline, not a fill. A card here is the page colour
  plus one step, with a one-pixel border at seven per cent white. The
  border does the work; the fill is almost nothing. Filling panels to make
  them visible is what makes an interface look heavy.

  And text has levels. Four of them, from the thing you are reading to the
  timestamp you are not. A dark interface with one text colour reads as
  shouting.

  The accent is OLXR's own orange, #F47521, taken from the logo and used
  on about one element per screen. Linear's blue and Vercel's blue are
  theirs; the structure here is the borrowed part, the colour is not.
*/

/* -------------------------------------------------------------- Inter */

/*
  Self-hosted, one variable file, 48KB.

  Not Google Fonts: this is a CRM full of other people's personal data,
  and a stylesheet from a third party on every page view is a request to
  somebody else's server telling them when it was opened and from where.
  The file is small enough that the argument for a CDN never arrives.

  swap, so text paints in the fallback immediately rather than leaving the
  screen blank while 48KB arrives.
*/
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-variable-latin.woff2') format('woff2');
}

/* --------------------------------------------------------- the tokens */

[data-bs-theme='dark'] {
  /*
    Four surfaces, close together on purpose. The whole range from page to
    dropdown is about nine per cent of lightness; the separation comes
    from the borders below, not from these.
  */
  --olxr-bg: #0b0c0e;
  --olxr-surface: #131417;
  --olxr-raised: #1a1c20;
  --olxr-hover: #212429;

  --olxr-line: rgba(255, 255, 255, 0.07);
  --olxr-line-strong: rgba(255, 255, 255, 0.12);

  /* Four levels, each with a job: read it, read it after, glance, ignore. */
  --olxr-text: #f2f3f5;
  --olxr-text-2: #c3c8d0;
  --olxr-text-3: #878d98;
  --olxr-text-4: #5f646d;

  /* The logo's two colours. The red is already the right danger colour. */
  --olxr-accent: #f47521;
  --olxr-accent-hover: #ff8a3d;
  --olxr-accent-dim: rgba(244, 117, 33, 0.14);
  --olxr-danger: #e4555c;
  --olxr-danger-dim: rgba(214, 43, 51, 0.16);
  --olxr-success: #4ec98a;
  --olxr-success-dim: rgba(78, 201, 138, 0.14);
  --olxr-warning: #e0a63c;
  --olxr-warning-dim: rgba(224, 166, 60, 0.14);

  --olxr-radius: 8px;
  --olxr-radius-sm: 6px;

  /* ------------------------------------------- handing these to Bootstrap */

  --bs-body-bg: var(--olxr-bg);
  --bs-body-color: var(--olxr-text-2);
  --bs-emphasis-color: var(--olxr-text);
  --bs-secondary-color: var(--olxr-text-3);
  --bs-tertiary-color: var(--olxr-text-4);
  --bs-secondary-bg: var(--olxr-surface);
  --bs-tertiary-bg: var(--olxr-raised);
  --bs-border-color: var(--olxr-line);
  --bs-border-color-translucent: var(--olxr-line);
  --bs-border-radius: var(--olxr-radius);
  --bs-border-radius-sm: var(--olxr-radius-sm);
  --bs-border-radius-lg: 10px;

  --bs-primary: var(--olxr-accent);
  --bs-primary-rgb: 244, 117, 33;
  --bs-link-color: var(--olxr-accent);
  --bs-link-hover-color: var(--olxr-accent-hover);
  --bs-link-color-rgb: 244, 117, 33;
  --bs-link-hover-color-rgb: 255, 138, 61;

  --bs-code-color: var(--olxr-accent);
  --bs-highlight-bg: var(--olxr-accent-dim);

  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Inter in the light theme too, so the two do not look like two products. */
:root {
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------------------------------------------------------- typography */

body {
  /*
    Grayscale smoothing on dark. Subpixel rendering assumes dark text on
    light and over-thickens light text on dark, which is most of why light
    type on a dark page can look muddy.
  */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.006em;
}

/*
  Headings tighten as they grow. Inter is drawn with generous spacing for
  small sizes, so a 2rem heading set at its default tracking looks loose
  and amateurish; every reference measured runs between -0.02em and
  -0.022em at display sizes.
*/
h1, .h1 { letter-spacing: -0.022em; font-weight: 620; }
h2, .h2 { letter-spacing: -0.019em; font-weight: 600; }
h3, .h3 { letter-spacing: -0.016em; font-weight: 600; }
h4, .h4, h5, .h5, h6, .h6 { letter-spacing: -0.012em; font-weight: 600; }

[data-bs-theme='dark'] h1, [data-bs-theme='dark'] h2,
[data-bs-theme='dark'] h3, [data-bs-theme='dark'] h4,
[data-bs-theme='dark'] h5, [data-bs-theme='dark'] h6 {
  color: var(--olxr-text);
}

/*
  Lining, fixed-width digits wherever numbers are stacked. Without this a
  column of money or dates is ragged, because Inter's default figures are
  proportional - the "1" is narrower than the "8" - and the eye reads the
  ragged edge as carelessness before it reads the numbers.
*/
.table, .badge, time, .text-nowrap {
  font-variant-numeric: tabular-nums;
}

/*
  bg-body-tertiary, which is on the <body> of every layout.

  Bootstrap's background utilities read --bs-tertiary-bg-RGB, a separate
  variable from the --bs-tertiary-bg set above, so setting one and not the
  other left the page at Bootstrap's own grey while the cards took the new
  colour - and the cards came out darker than the page they sit on, which
  is the one arrangement guaranteed to look wrong.

  Two rules rather than redefining the rgb variable, because the class is
  doing two different jobs in this application: on the body it means "the
  page", and on a card header it means "a shade up from the card".
*/
[data-bs-theme='dark'] .bg-body-tertiary {
  background-color: var(--olxr-raised) !important;
}

[data-bs-theme='dark'] body.bg-body-tertiary {
  background-color: var(--olxr-bg) !important;
}

/* ------------------------------------------------------------ chrome */

/*
  The bar is the page with a line under it.

  It was a black block sitting on a grey page, which is the arrangement
  that makes an application look like a website with a header. Taking the
  fill away and leaving one hairline puts the content first and is what
  every interface measured for this does.
*/
[data-bs-theme='dark'] .navbar {
  background-color: var(--olxr-bg) !important;
  border-bottom: 1px solid var(--olxr-line);
}

[data-bs-theme='dark'] .navbar .nav-link {
  color: var(--olxr-text-3);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: var(--olxr-radius-sm);
  transition: color 0.12s ease, background-color 0.12s ease;
}

[data-bs-theme='dark'] .navbar .nav-link:hover {
  color: var(--olxr-text);
  background-color: var(--olxr-hover);
}

[data-bs-theme='dark'] .navbar .nav-link.active {
  color: var(--olxr-text);
}

footer, .footer {
  border-top: 1px solid var(--olxr-line);
}

/* ------------------------------------------------------------- cards */

[data-bs-theme='dark'] .card {
  --bs-card-bg: var(--olxr-surface);
  --bs-card-border-color: var(--olxr-line);
  --bs-card-border-radius: var(--olxr-radius);
  --bs-card-cap-bg: transparent;
  --bs-card-color: var(--olxr-text-2);
}

[data-bs-theme='dark'] .card-header {
  border-bottom-color: var(--olxr-line);
  color: var(--olxr-text);
  font-weight: 600;
}

[data-bs-theme='dark'] .list-group {
  --bs-list-group-bg: transparent;
  --bs-list-group-border-color: var(--olxr-line);
  --bs-list-group-color: var(--olxr-text-2);
  --bs-list-group-action-hover-bg: var(--olxr-hover);
  --bs-list-group-action-hover-color: var(--olxr-text);
}

/* ------------------------------------------------------------ tables */

/*
  No fill on the header row, which is the single biggest change here.

  A filled header is a band of colour above the data competing with it. A
  header is a label: small, uppercase, tracked out, in the muted text
  colour, separated by the same hairline as everything else. The rows then
  carry no vertical rules at all - the alignment does that job, and lines
  between columns are a habit from printed tables.
*/
[data-bs-theme='dark'] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--olxr-text-2);
  --bs-table-border-color: var(--olxr-line);
  --bs-table-hover-bg: var(--olxr-hover);
  --bs-table-hover-color: var(--olxr-text);
  border-color: var(--olxr-line);
}

[data-bs-theme='dark'] .table > thead,
[data-bs-theme='dark'] .table > thead > tr > th,
[data-bs-theme='dark'] .table-light,
[data-bs-theme='dark'] .table-light > :not(caption) > * > * {
  background-color: transparent !important;
  color: var(--olxr-text-3) !important;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom-color: var(--olxr-line) !important;
}

[data-bs-theme='dark'] .table > tbody > tr > td {
  border-top-color: var(--olxr-line);
  border-bottom-color: var(--olxr-line);
}

/* ----------------------------------------------------------- buttons */

.btn {
  --bs-btn-border-radius: var(--olxr-radius-sm);
  font-weight: 500;
  letter-spacing: -0.006em;
}

/*
  The accent button. One per screen, usually - the thing you came to do.
  Dark text on orange rather than white, because #F47521 is a light colour
  and white on it fails every contrast test there is.
*/
[data-bs-theme='dark'] .btn-primary,
[data-bs-theme='dark'] .btn-warning {
  --bs-btn-color: #1a1205;
  --bs-btn-bg: var(--olxr-accent);
  --bs-btn-border-color: var(--olxr-accent);
  --bs-btn-hover-color: #1a1205;
  --bs-btn-hover-bg: var(--olxr-accent-hover);
  --bs-btn-hover-border-color: var(--olxr-accent-hover);
  --bs-btn-active-color: #1a1205;
  --bs-btn-active-bg: var(--olxr-accent-hover);
  --bs-btn-active-border-color: var(--olxr-accent-hover);
  --bs-btn-disabled-color: #1a1205;
  --bs-btn-disabled-bg: var(--olxr-accent);
  --bs-btn-disabled-border-color: var(--olxr-accent);
}

/*
  The everyday button: a raised surface with a hairline, not an outline.
  Bootstrap's outline buttons are a border and nothing else, which on a
  dark page reads as disabled rather than as secondary.
*/
[data-bs-theme='dark'] .btn-outline-secondary,
[data-bs-theme='dark'] .btn-secondary,
[data-bs-theme='dark'] .btn-outline-dark,
[data-bs-theme='dark'] .btn-dark,
/*
  light and outline-light land here too. In a light theme they are the
  quiet button; read literally in the dark they are a white box, and the
  sign-out button in the navigation was exactly that - the brightest thing
  on the screen, for the action you want least often.
*/
[data-bs-theme='dark'] .btn-outline-light,
[data-bs-theme='dark'] .btn-light {
  --bs-btn-color: var(--olxr-text-2);
  --bs-btn-bg: var(--olxr-raised);
  --bs-btn-border-color: var(--olxr-line-strong);
  --bs-btn-hover-color: var(--olxr-text);
  --bs-btn-hover-bg: var(--olxr-hover);
  --bs-btn-hover-border-color: var(--olxr-line-strong);
  --bs-btn-active-color: var(--olxr-text);
  --bs-btn-active-bg: var(--olxr-hover);
  --bs-btn-active-border-color: var(--olxr-line-strong);
  --bs-btn-disabled-color: var(--olxr-text-4);
  --bs-btn-disabled-bg: var(--olxr-surface);
  --bs-btn-disabled-border-color: var(--olxr-line);
}

[data-bs-theme='dark'] .btn-outline-danger,
[data-bs-theme='dark'] .btn-danger {
  --bs-btn-color: var(--olxr-danger);
  --bs-btn-bg: var(--olxr-danger-dim);
  --bs-btn-border-color: rgba(228, 85, 92, 0.3);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #c6383f;
  --bs-btn-hover-border-color: #c6383f;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #c6383f;
  --bs-btn-active-border-color: #c6383f;
}

[data-bs-theme='dark'] .btn-link {
  --bs-btn-color: var(--olxr-text-3);
  --bs-btn-hover-color: var(--olxr-text);
  text-decoration: none;
}

/* ------------------------------------------------------------ badges */

/*
  Tinted, not filled.

  A solid green block saying "Client" is a traffic light. The same word in
  green on a dim green wash with a faint border reads as a label, which is
  what it is - and a row of them does not turn a table into bunting. This
  is the clearest single marker of a considered interface against a
  default one.
*/
.badge {
  --bs-badge-border-radius: 5px;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  padding: 0.25em 0.55em;
  border: 1px solid transparent;
}

[data-bs-theme='dark'] .badge.text-bg-success,
[data-bs-theme='dark'] .badge.text-bg-success-subtle {
  background-color: var(--olxr-success-dim) !important;
  color: var(--olxr-success) !important;
  border-color: rgba(78, 201, 138, 0.22);
}

[data-bs-theme='dark'] .badge.text-bg-danger {
  background-color: var(--olxr-danger-dim) !important;
  color: var(--olxr-danger) !important;
  border-color: rgba(228, 85, 92, 0.24);
}

[data-bs-theme='dark'] .badge.text-bg-warning {
  background-color: var(--olxr-warning-dim) !important;
  color: var(--olxr-warning) !important;
  border-color: rgba(224, 166, 60, 0.24);
}

[data-bs-theme='dark'] .badge.text-bg-primary {
  background-color: var(--olxr-accent-dim) !important;
  color: var(--olxr-accent) !important;
  border-color: rgba(244, 117, 33, 0.26);
}

[data-bs-theme='dark'] .badge.text-bg-light,
[data-bs-theme='dark'] .badge.text-bg-secondary,
[data-bs-theme='dark'] .badge.text-bg-dark {
  background-color: var(--olxr-raised) !important;
  color: var(--olxr-text-3) !important;
  border-color: var(--olxr-line-strong);
}

/* -------------------------------------------------------------- forms */

[data-bs-theme='dark'] .form-control,
[data-bs-theme='dark'] .form-select {
  background-color: var(--olxr-raised);
  border-color: var(--olxr-line-strong);
  border-radius: var(--olxr-radius-sm);
  color: var(--olxr-text);
}

[data-bs-theme='dark'] .form-control::placeholder {
  color: var(--olxr-text-4);
}

/*
  The focus ring is the accent, and it is a ring rather than a glow.

  Bootstrap's default is a wide translucent blue halo, which on a dark
  page is a smudge. A one-pixel accent border with a thin ring outside it
  says where the keyboard is without lighting up the room.
*/
[data-bs-theme='dark'] .form-control:focus,
[data-bs-theme='dark'] .form-select:focus,
[data-bs-theme='dark'] .btn:focus-visible,
[data-bs-theme='dark'] .form-check-input:focus {
  background-color: var(--olxr-raised);
  border-color: var(--olxr-accent);
  box-shadow: 0 0 0 3px rgba(244, 117, 33, 0.16);
  outline: none;
}

[data-bs-theme='dark'] .form-check-input:checked {
  background-color: var(--olxr-accent);
  border-color: var(--olxr-accent);
}

[data-bs-theme='dark'] .form-text {
  color: var(--olxr-text-4);
}

[data-bs-theme='dark'] .input-group-text {
  background-color: var(--olxr-surface);
  border-color: var(--olxr-line-strong);
  color: var(--olxr-text-3);
}

/* ---------------------------------------------------------- dropdowns */

[data-bs-theme='dark'] .dropdown-menu {
  --bs-dropdown-bg: var(--olxr-raised);
  --bs-dropdown-border-color: var(--olxr-line-strong);
  --bs-dropdown-border-radius: var(--olxr-radius);
  --bs-dropdown-link-color: var(--olxr-text-2);
  --bs-dropdown-link-hover-bg: var(--olxr-hover);
  --bs-dropdown-link-hover-color: var(--olxr-text);
  --bs-dropdown-link-active-bg: var(--olxr-accent-dim);
  --bs-dropdown-link-active-color: var(--olxr-accent);
  /*
    One shadow in the whole theme, and only here. A dropdown is the one
    thing genuinely floating above the page; everything else is in it.
  */
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------ alerts */

/*
  Alerts as quiet notes rather than coloured slabs: a dim wash, a hairline
  in the same hue, and the text doing the talking.
*/
[data-bs-theme='dark'] .alert {
  --bs-alert-border-radius: var(--olxr-radius);
  border-width: 1px;
}

[data-bs-theme='dark'] .alert-warning {
  --bs-alert-bg: var(--olxr-warning-dim);
  --bs-alert-border-color: rgba(224, 166, 60, 0.22);
  --bs-alert-color: #f0c070;
}

[data-bs-theme='dark'] .alert-danger {
  --bs-alert-bg: var(--olxr-danger-dim);
  --bs-alert-border-color: rgba(228, 85, 92, 0.24);
  --bs-alert-color: #f0868c;
}

[data-bs-theme='dark'] .alert-success {
  --bs-alert-bg: var(--olxr-success-dim);
  --bs-alert-border-color: rgba(78, 201, 138, 0.22);
  --bs-alert-color: #7fdcac;
}

[data-bs-theme='dark'] .alert-secondary {
  --bs-alert-bg: var(--olxr-surface);
  --bs-alert-border-color: var(--olxr-line);
  --bs-alert-color: var(--olxr-text-2);
}

/* The attention row in a list, in the same language as the alerts. */
[data-bs-theme='dark'] .list-group-item-warning,
[data-bs-theme='dark'] .table-warning > td,
[data-bs-theme='dark'] .table-warning > th {
  background-color: var(--olxr-warning-dim) !important;
  color: #f0c070 !important;
}

/* ------------------------------------------------------------- bits */

[data-bs-theme='dark'] code {
  background-color: var(--olxr-raised);
  border: 1px solid var(--olxr-line);
  border-radius: 4px;
  padding: 0.08em 0.34em;
  font-size: 0.84em;
}

[data-bs-theme='dark'] hr,
[data-bs-theme='dark'] .dropdown-divider {
  border-color: var(--olxr-line);
  opacity: 1;
}

[data-bs-theme='dark'] .border,
[data-bs-theme='dark'] .border-top,
[data-bs-theme='dark'] .border-bottom,
[data-bs-theme='dark'] .border-start,
[data-bs-theme='dark'] .border-end {
  border-color: var(--olxr-line) !important;
}

[data-bs-theme='dark'] .text-body-secondary { color: var(--olxr-text-3) !important; }
[data-bs-theme='dark'] .text-body-tertiary { color: var(--olxr-text-4) !important; }
[data-bs-theme='dark'] .text-danger { color: var(--olxr-danger) !important; }
[data-bs-theme='dark'] .text-success { color: var(--olxr-success) !important; }
[data-bs-theme='dark'] .text-warning { color: var(--olxr-warning) !important; }

/* Links inside prose get the accent; links that are nav or buttons do not. */
[data-bs-theme='dark'] a:not(.btn):not(.nav-link):not(.navbar-brand):not(.dropdown-item) {
  text-decoration-color: rgba(244, 117, 33, 0.35);
  text-underline-offset: 0.18em;
}

/*
  A link in a list is a row, not a link.

  Twelve contacts in a table gave twelve orange names, and at that point
  the accent has quietly become the body text colour - it marks nothing,
  because everything is marked. Every interface measured for this treats
  the accent as roughly one element per screen.

  So a name in a table or a list group is set in the primary text colour,
  with no underline, and turns accent on hover. The row is obviously
  clickable from its position and its cursor; it does not also need to
  shout. Prose links elsewhere keep the accent, because there the colour
  is the only thing saying a link is there at all.
*/
[data-bs-theme='dark'] .table a:not(.btn):not(.badge),
[data-bs-theme='dark'] .list-group a:not(.btn):not(.badge) {
  color: var(--olxr-text);
  font-weight: 500;
  text-decoration: none;
}

[data-bs-theme='dark'] .table a:not(.btn):not(.badge):hover,
[data-bs-theme='dark'] .list-group a:not(.btn):not(.badge):hover {
  color: var(--olxr-accent);
}

/*
  Rows respond to the cursor. Without it a dense table is a wall, and
  reading across one is harder than it should be.
*/
[data-bs-theme='dark'] .table-hover > tbody > tr:hover > *,
[data-bs-theme='dark'] .table > tbody > tr:hover > * {
  background-color: var(--olxr-hover);
}

/*
  The section captions - "WHAT IS COMING", "REACH THEM". Uppercase at this
  size needs tracking out, or it reads as a word with the letters jammed
  together rather than as a label.
*/
.card-label,
h2.h6.text-uppercase {
  letter-spacing: 0.06em !important;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--olxr-text-3);
}
