/*
  Global styles for SafePostcode
  Define a simple design system using CSS variables. These variables can be
  referenced throughout the site to ensure consistent colours and spacing.
*/

:root {
  /* Colour palette for the light theme inspired by the SafePostcode housing view */
  /* Primary text colour updated to match the dark tone of the new SafePostcode logo */
  --ink: #0b1f4b;        /* Primary text colour (dark navy) */
  /* Secondary text colour tweaked to match the SafePostcode design from the provided template */
  --muted: #5a6b8c;
  /* Page background aligns with the official SafePostcode light theme */
  --bg: #f7f9fd;
  --card: #ffffff;       /* Card background */
  /* Primary brand colour updated to match the SafePostcode logo gradient */
  /* The new logo uses a linear gradient from #2f70ff at the top‑left to #0b1f4b at the bottom‑right. */
  /* We set the accent to the mid tone (#2f70ff) so buttons and highlights harmonise with the logo. */
  --accent: #2f70ff;
  /* Additional state colours (kept unchanged) */
  --good: #0b8f4b;       /* Green for positive states */
  --mid: #b58900;        /* Amber for warning states */
  --bad: #c1172c;        /* Red for negative states */
  --line: #e6ebf7;       /* Lines and borders */

  /* Additional derived colours */
  /* Light tint of primary used for KPI cards, derived from the new accent colour */
  /* Light tint derived from the new accent colour */
  --primary-light: #eaf3fe;

  /* Font sizing scale */
  /* Slightly larger base font for improved legibility on mobile */
  --font-base: 17px;
  --font-large: 1.25rem;
  --font-heading: 2rem;
  --font-subheading: 1.25rem;
}

/* Basic reset */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: var(--font-base);
}

/* Generic form controls */
input[type="text"], select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 1rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  width: 100%;
}
input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 3px rgba(47, 112, 255, 0.15);
}

header {
  /* Use a light tint of the primary colour for the header bar instead of plain white. This
     ties the logo and menu together visually and creates a subtle band across the top of
     the page. The tint is defined in --primary-light and derived from the site accent colour. */
  background: var(--primary-light);
  color: var(--ink);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  /* Ensure the header remains fixed on small screens for easier navigation */
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Menu button styling */
header .menu-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 0.9rem;
  color: var(--accent);
  background: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-name {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
}

/* Logo styling */
.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
}


nav a {
  color: var(--accent);
  margin-right: 12px;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
}
nav a:hover {
  text-decoration: underline;
}

/* Navigation bar styling within the header. Use flex layout and push links towards the centre/right. */
header nav {
  margin-left: auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
/* Highlight the active page in the navigation */
header nav a.active,
header nav a:hover {
  background: var(--primary-light);
  color: var(--ink);
  text-decoration: none;
}


.container {
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  padding: 20px;
  width: 100%;
}

/*
 * Search card wrapper
 * We group the postcode search and city/area selectors into a single rounded card
 * so that the inputs feel part of one cohesive unit. The card uses a subtle
 * shadow and a slightly tinted background to stand off the page. On very small
 * screens the card stretches to fill the container width.
 */
.search-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  margin-bottom: 24px;
  max-width: 450px;
}

/*
 * Details card for collapsible content (e.g. compare two places)
 * Use the <details> element with a custom summary to allow sections of
 * the page to expand/collapse. The summary acts like a header bar and
 * uses a chevron icon that rotates when the section is open. The card
 * inherits the same rounded shape and shadow as other cards.
 */
.details-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  margin-bottom: 24px;
  max-width: 450px;
}

.details-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  padding: 20px;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  position: relative;
}

.details-card summary::after {
  content: '';
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-left: auto;
}

.details-card[open] summary::after {
  transform: rotate(225deg);
}

.details-card .details-content {
  padding: 20px;
}

@media (max-width: 768px) {
  .search-card, .details-card {
    padding: 16px;
    border-radius: 18px;
  }
  .details-card summary {
    padding: 16px;
    font-size: 1rem;
  }
  .details-card .details-content {
    padding: 16px;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  /* Increase card rounding and padding for a softer, modern look */
  border-radius: 24px;
  padding: 24px;
  /* More pronounced shadow for depth */
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  margin-bottom: 20px;
}

/* KPI cards */
.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.kpi {
  background: var(--primary-light, #e9effb);
  border: 1px solid var(--line);
  border-radius: 12px;
  /* Increased internal padding for KPI cards */
  padding: 16px;
}

.kpi h3 {
  margin: 0 0 4px 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.kpi .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}

/* Pills for displaying hints and comparisons */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--primary-light, #e9effb);
  color: var(--accent);
  margin-right: 4px;
  margin-top: 4px;
}

.pill.good {
  background: #ecf9f1;
  color: var(--good);
  border-color: #c9ecd3;
}

.pill.mid {
  background: #fff7e6;
  color: var(--mid);
  border-color: #f5e0b6;
}

.pill.bad {
  background: #fff0f0;
  color: var(--bad);
  border-color: #f1cccc;
}

/* Autocomplete dropdown for postcode suggestions */
.autocomplete-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.9rem;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--primary-light);
}

/* Table styling */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.table th,
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table th {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.table td {
  font-size: 0.92rem;
  color: var(--ink);
}

/* Chart containers: allow horizontal scrolling on small screens */
.chart-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

/* Grid layout for lists of cards */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  margin-top: 12px;
}

/* Responsive and mobile‑friendly adjustments */
@media (max-width: 768px) {
  :root {
    --font-base: 17px;
    --font-heading: 1.8rem;
    --font-subheading: 1.2rem;
  }
  header {
    padding: 14px;
  }
  .container {
    padding: 16px;
  }
  h1 {
    font-size: var(--font-heading);
    line-height: 1.3;
  }
  h2 {
    font-size: var(--font-subheading);
    margin-top: 24px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 16px;
    border-radius: 16px;
  }
  .kpi {
    padding: 12px;
  }
  .kpi .value {
    font-size: 1.4rem;
  }
  .btn {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 1rem;
  }
  #search-section {
    max-width: 100%;
  }
  #search-section select,
  #search-section input {
    font-size: 1rem;
    padding: 12px;
  }
  #search-section .btn-primary {
    padding: 12px;
  }

  /* Ensure compare section elements stack nicely on very small screens */
  #compare-section div[style*="display:flex"] {
    flex-direction: column;
  }
}

/* Button styling */
.btn {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
}

/* Primary button */
.btn-primary {
  /* Use a gradient matching the logo for primary buttons */
  background: linear-gradient(135deg, #2f70ff, #0b1f4b);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-primary:hover {
  /* Darker gradient on hover for clear feedback */
  background: linear-gradient(135deg, #2c64e6, #0a1b44);
}

/* Modern search bar: a rounded container holding input and button */
.search-bar {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}
.search-bar input[type="text"] {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--card);
  box-shadow: none;
}
.search-bar input[type="text"]:focus {
  outline: none;
}
.search-bar button {
  margin: 0;
  border-radius: 0;
  /* Let the gradient span the full height of the bar */
}

/* Modern custom select with arrow icon */
.modern-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2010%206'%3E%3Cpath%20fill='%236e7a91'%20d='M0%200%20L5%206%20L10%200%20Z'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 6px;
  padding-right: 40px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.modern-select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 3px rgba(47, 112, 255, 0.15);
}


/* Secondary/ghost button */
.btn-secondary {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-secondary:hover {
  background: var(--primary-light, #e9effb);
}

/* Line chart canvas */
canvas.line-chart {
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  display: block;
  margin-top: 8px;
}

/* Muted text helper */
/* Muted text helper */
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Added by automated update (stacked search + themed buttons) --- */
.btn-primary{
  background: linear-gradient(135deg, var(--accent), var(--ink));
  color:#fff;
  border: none;
} 
.btn-primary:hover{ filter: brightness(0.95); }
.search-bar.stacked{
  display:flex;
  flex-direction:column;
  gap:8px;
  border-radius:14px;
  border: 1px solid var(--line);
  background: var(--card);
  padding:0; /* input keeps its own padding */
}
.stacked-submit .btn{
  width:100%;
}
#postcode-form input[type="text"]{ width:100%; }

/* augment vars */
:root{
  --brand-1: #0b1f4b;
  --brand-2: #2f70ff;
  --bg: #f7f9ff;
  --ink: #0b1f4b;
  --card: #ffffff;
  --muted: #6b7a99;
  --border: #d7def2;
  --radius: 12px;
  --shadow-1: 0 2px 10px rgba(0,0,0,.07);
  --shadow-2: 0 6px 24px rgba(0,0,0,.08);
}


/* ==== Global Typography & Buttons (standardized) ==== */
:root{
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

html{font-size:16px;}
body{
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,h2,h3,h4{color: var(--ink); line-height:1.25; margin: 0.6em 0 0.35em;}
p{line-height:1.6; color: var(--ink); margin: 0.6em 0;}

a{color:#1b5cff; text-decoration:none;}
a:hover{text-decoration:underline;}

.btn, a.btn, button.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:.5rem;
  padding:0.72rem 1rem; border-radius: var(--radius);
  border:1px solid var(--border); background: var(--card); color: var(--ink);
  font-weight:600; text-decoration:none; cursor:pointer; transition: transform .04s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
  box-shadow: var(--shadow-1);
}
.btn:hover{ box-shadow: var(--shadow-2); }
.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: linear-gradient(180deg, var(--brand-2), var(--brand-1));
  color: #fff; border-color: transparent;
}
.btn-primary:hover{ filter: brightness(1.05); }
.btn-primary:focus-visible{ outline: 3px solid rgba(47,112,255,.35); outline-offset: 2px; }

.btn-secondary{ background: var(--card); color: var(--ink); }
.btn-secondary:hover{ background: #f2f6ff; }

input[type="text"], input[type="search"], select, textarea{
  border:1px solid var(--border); border-radius: var(--radius);
  padding: .68rem .8rem; background:#fff; color: var(--ink);
  transition: box-shadow .18s ease, border-color .18s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(47,112,255,.2);
}

/* Chips & Menu buttons inherit theme */
.sp-chip{ border-radius:999px; }
.sp-float-btn{ transition: filter .18s ease, box-shadow .18s ease; box-shadow: var(--shadow-1); }
.sp-float-btn:hover{ filter: brightness(1.06); box-shadow: var(--shadow-2); }
/* ==== /Global Typography & Buttons ==== */

/* ==== Footer ==== */
/*
 * A simple site‑wide footer used across all pages. It uses the existing
 * SafePostcode colour variables so that the footer integrates seamlessly
 * with the rest of the design. The footer appears at the bottom of
 * every page and contains a brief disclaimer along with links to
 * the Privacy Policy and Terms pages. You can adjust padding or
 * typography here if needed.
 */
.sp-footer {
  background: var(--primary-light);
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding: 16px 0;
  font-size: 0.8rem;
}
.sp-footer .container {
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}
.sp-footer a {
  color: var(--accent);
  text-decoration: none;
}
.sp-footer a:hover {
  text-decoration: underline;
}
