/*
  Eastvalley Properties theme for the leaseholder portal.

  Pico CSS (loaded before this file in templates/base.html) does the heavy
  lifting: it styles plain HTML elements. This file only
    1. swaps Pico's default colours for the palette used on
       eastvalleyproperties.co.uk, and
    2. adds the handful of layout pieces Pico doesn't provide (the teal header
       bar, the footer, the label/value lists).

  Pico reads its colours from CSS variables named --pico-*, so changing a
  variable here restyles every button, link, table and form at once.
*/

/* --- 1. Palette ----------------------------------------------------------- */

:root {
  /* Colours taken from eastvalleyproperties.co.uk */
  --ev-teal: #4b7881;        /* brand colour: header bar, buttons */
  --ev-teal-dark: #3a5f67;   /* hover state, and links (darker = easier to read) */
  --ev-teal-tint: #edf2f2;   /* very pale teal: table header, row hover */
  --ev-ink: #1f2937;         /* main text */
  --ev-slate: #414f62;       /* secondary text */
  --ev-cream: #faf6f2;       /* page background */
  --ev-border: #d7dfea;      /* light borders */
  --ev-border-strong: #b9c5d5; /* form field borders */
  --ev-white: #ffffff;
}

/*
  The selector below is deliberately the same shape as Pico's own light-theme
  selector so that, loading second, it wins. base.html sets data-theme="light"
  on <html>, which also stops Pico switching to its dark colours on devices
  set to dark mode (we only have a light palette).
*/
:root[data-theme="light"] {
  --pico-background-color: var(--ev-cream);
  --pico-color: var(--ev-ink);
  --pico-muted-color: var(--ev-slate);
  --pico-muted-border-color: var(--ev-border);

  --pico-h1-color: var(--ev-ink);
  --pico-h2-color: var(--ev-ink);
  --pico-h3-color: var(--ev-ink);

  /* "Primary" = links and main buttons. */
  --pico-primary: var(--ev-teal-dark);
  --pico-primary-hover: var(--ev-ink);
  --pico-primary-underline: rgba(75, 120, 129, 0.4);
  --pico-primary-hover-underline: var(--ev-ink);
  --pico-primary-background: var(--ev-teal);
  --pico-primary-border: var(--ev-teal);
  --pico-primary-hover-background: var(--ev-teal-dark);
  --pico-primary-hover-border: var(--ev-teal-dark);
  --pico-primary-inverse: var(--ev-white);
  --pico-primary-focus: rgba(75, 120, 129, 0.35);

  /* Cards (<article>) and form fields. */
  --pico-card-background-color: var(--ev-white);
  --pico-card-border-color: var(--ev-border);
  --pico-card-box-shadow: 0 1px 3px rgba(31, 41, 55, 0.08);
  --pico-form-element-background-color: var(--ev-white);
  --pico-form-element-border-color: var(--ev-border-strong);
  --pico-form-element-active-border-color: var(--ev-teal);
  --pico-form-element-focus-color: var(--ev-teal);

  /* Tables. */
  --pico-table-border-color: var(--ev-border);

  /* <mark>, used for error messages on the login page. */
  --pico-mark-background-color: #fdecea;
  --pico-mark-color: #8a1f17;

  --pico-border-radius: 0.5rem;
}

/* --- 2. Page layout ------------------------------------------------------- */

/* Make the page at least as tall as the window so the footer sits at the
   bottom even when there is little content. */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

/* Teal bar across the top, like the main website. */
.site-header {
  background: var(--ev-teal);
  color: var(--ev-white);
  margin-bottom: 1.5rem;
  padding-block: 0; /* Pico pads <header> top and bottom; the bar looks better slim */
}
.site-header nav { min-height: 3.5rem; }
.site-header .brand {
  color: var(--ev-white);
  font-weight: 700;
  text-decoration: none;
}
.site-header .brand-sub { color: rgba(255, 255, 255, 0.8); }
.site-header .user-email { color: rgba(255, 255, 255, 0.85); font-size: 0.9rem; }
.site-header form { margin: 0; }
/* The log out button: white outline on the teal bar. */
.site-header button {
  margin: 0;
  padding: 0.3rem 0.8rem;
  background: transparent;
  color: var(--ev-white);
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.site-header button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--ev-white);
}

.site-footer {
  border-top: 1px solid var(--ev-border);
  margin-top: 2rem;
  padding-block: 1rem;
  color: var(--ev-slate);
  font-size: 0.875rem;
}

/* On narrow screens, hide the email address so the header fits on one line. */
@media (max-width: 576px) {
  .site-header .user-email,
  .site-header .brand-sub { display: none; }
}

/* --- 3. Components -------------------------------------------------------- */

.muted { color: var(--pico-muted-color); }

/* Narrow centred card: login, password reset and error pages. */
.card-narrow { max-width: 28rem; margin: 2rem auto; }

/* Each <section> inside the main area becomes a white card. */
main > section {
  background: var(--ev-white);
  border: 1px solid var(--ev-border);
  border-radius: var(--pico-border-radius);
  box-shadow: 0 1px 3px rgba(31, 41, 55, 0.08);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
main > section > h2 {
  font-size: 1.15rem;
  color: var(--ev-teal-dark);
  margin-bottom: 1rem;
}
/* Sub-headings inside a card (e.g. the building safety information): smaller than the card's title. */
main > section > h3 {
  font-size: 1rem;
  margin: 1.1rem 0 0.35rem;
}
main > section > :last-child { margin-bottom: 0; }

/* Notices after a form is sent, e.g. "Your reply has been sent". */
.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  background: #e6f2ef;
  border-left: 4px solid var(--ev-teal-dark);
}
.notice-error { background: #fbeaea; border-left-color: #ba2121; }

/* Reports: the updates on one report, oldest first. */
.updates { list-style: none; padding: 0; }
.updates li { border-left: 3px solid var(--ev-border); padding: 0.25rem 0 0.25rem 1rem; margin-bottom: 1rem; }
.updates li.from-you { border-left-color: var(--ev-teal-dark); }
.updates .who { font-weight: 600; color: var(--ev-slate); }
.status-done { color: var(--ev-teal-dark); font-weight: 600; }

/* Label/value lists, e.g. the lease details. */
dl.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
}
dl.details dt { font-weight: 600; color: var(--ev-slate); }
dl.details dd { margin: 0; }
@media (max-width: 576px) {
  /* Stack label above value on phones. */
  dl.details { grid-template-columns: 1fr; gap: 0.1rem; }
  dl.details dd { margin-bottom: 0.6rem; }
}

/* Tables. */
table thead th {
  background: var(--ev-teal-tint);
  color: var(--ev-slate);
  font-weight: 600;
}
/* Wide tables (e.g. the budget) scroll sideways on a phone instead of being
   cut off at the edge of the card. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > table { margin-bottom: 0; }
.table-scroll + .table-scroll, .table-scroll + p { margin-top: 1rem; }
@media (max-width: 576px) {
  /* Tighter cells on phones, so the budget's four columns usually fit
     without scrolling. */
  .table-scroll table { font-size: 0.85rem; }
  .table-scroll th, .table-scroll td { padding: 0.45rem 0.4rem; }
}

/* On phones, a table marked "stack-on-phone" shows each row as a small card:
   one line per column, with the column name (from the cell's data-label) on
   the left. Used for "Your properties", which would otherwise not fit. */
@media (max-width: 576px) {
  table.stack-on-phone thead { display: none; }
  table.stack-on-phone,
  table.stack-on-phone tbody,
  table.stack-on-phone tr,
  table.stack-on-phone td { display: block; width: 100%; }
  table.stack-on-phone tr {
    border: 1px solid var(--ev-border);
    border-radius: var(--pico-border-radius);
    margin-bottom: 0.75rem;
    padding: 0.25rem 0;
  }
  table.stack-on-phone td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border: none;
    padding: 0.35rem 0.75rem;
    text-align: right;
  }
  table.stack-on-phone td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ev-slate);
    text-align: left;
  }
}

/* Rows that static/js/portal.js has made clickable. */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--ev-teal-tint); }

/* Show/hide button under a password field (added by static/js/portal.js). */
button.password-toggle {
  width: auto;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
  margin-top: -0.5rem;
}


/* --- Budget tables (directors' budget page) -------------------------------- */

.budget-table caption { text-align: left; font-weight: 700; padding: 0.5rem 0; }
.budget-table .num { text-align: right; white-space: nowrap; }
.budget-table .over { color: #a12a2a; }           /* over budget */
.budget-table tfoot th, .budget-grand-total th { font-weight: 700; }
.year-picker { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.year-picker label, .year-picker select, .year-picker button { margin: 0; width: auto; }

