/* FILE: /opt/octopus-agile-dev/static/style.css */
:root{
  --bg: #070A12;

  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.04);

  --border: rgba(255,255,255,0.12);
  --border2: rgba(255,255,255,0.18);

  --text: #ffffff;
  --muted: rgba(255,255,255,0.74);
  --muted2: rgba(255,255,255,0.58);

  --shadow: 0 10px 30px rgba(0,0,0,0.40);

  --yellow: #FFD43B;

  /* bright solid colours */
  --green: #00C853;   /* vivid green */
  --green2:#00B248;   /* slightly deeper green */
  --amber: #FFEB3B;   /* standard bright yellow */
  --red:   #FF1744;   /* vivid red */

  --greenGlow: rgba(34,197,94,0.45);
  --amberGlow: rgba(245,158,11,0.45);
  --redGlow: rgba(239,68,68,0.45);
}

*{ box-sizing:border-box; }

html, body{
  margin:0;
  padding:0;
  background:
    radial-gradient(1200px 500px at 20% 0%, rgba(255,212,59,0.16), transparent 55%),
    radial-gradient(900px 500px at 90% 20%, rgba(79,70,229,0.22), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

a{ color: var(--yellow); text-decoration:none; }
a:hover{ text-decoration:underline; }

.top-bar{
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  font-size: 13px;
  color: var(--muted);
}

.top-bar strong{ color: var(--text); }
.top-left{ white-space:nowrap; }

.top-right{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.dot{ opacity:0.65; }

.top-bar a{
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,212,59,0.18);
  border: 1px solid rgba(255,212,59,0.45);
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.hero{ padding: 34px 16px 16px; }

.hero-inner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 18px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel2);
  box-shadow: var(--shadow);
}

.badge{
  display:inline-block;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,212,59,0.55);
  background: rgba(255,212,59,0.12);
  color: var(--yellow);
  font-weight: 900;
}

.hero-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap: 18px;
  margin-top: 12px;
}

.hero-head h1{
  margin: 0;
  font-size: 36px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.hero-desc{
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
  max-width: 62ch;
}

@media (max-width: 820px){
  .hero-head{
    flex-direction: column;
    align-items:flex-start;
    gap: 10px;
  }
  .hero-head h1{ font-size: 32px; }
  .hero-desc{ max-width: 100%; }
}

.region-pills{
  display:flex;
  flex-wrap:wrap;
  gap: 10px;
  padding: 14px 0 6px;
}

.pill{
  cursor:pointer;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  transition: transform .08s ease, background .2s ease, border .2s ease, box-shadow .2s ease;
  box-shadow: 0 8px 18px rgba(0,0,0,0.30);
}

.pill:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.28);
}

.pill.active{
  border-color: rgba(255,212,59,0.70);
  background: rgba(255,212,59,0.18);
  box-shadow: 0 0 0 3px rgba(255,212,59,0.18), 0 10px 22px rgba(0,0,0,0.35);
}

.controls-bar{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
}

.control-group{
  display:flex;
  align-items:center;
  gap: 10px;
}

.control-group label{
  font-size: 12px;
  color: var(--muted2);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#sortSelect{
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  outline: none;
}

#sortSelect:focus{
  border-color: rgba(255,212,59,0.55);
  box-shadow: 0 0 0 3px rgba(255,212,59,0.14);
}

.controls-right{
  display:flex;
  align-items:center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content:flex-end;
}

.control-toggle{
  display:flex;
  align-items:center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

.control-toggle input{
  width: 18px;
  height: 18px;
  accent-color: var(--yellow);
}

.container{
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px 36px;
}

.rates-block{ margin-top: 22px; }

.rates-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.rates-head h2{
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.subnote{
  font-size: 12px;
  color: var(--muted2);
}

.summary-row{
  display:flex;
  align-items:center;
  gap: 10px;
  margin: 8px 0 10px;
}

@media (max-width: 720px){
  .summary-row{
    flex-direction: column;
    align-items: stretch;
  }
}

.avg-banner{
  flex: 1 1 auto;
  padding: 10px 14px;
  border-radius: 10px;
  display:flex;
  align-items:center;
  gap: 12px;
  line-height: 1.2;
  border: 1px solid rgba(255,212,59,0.45);
  background: rgba(255,212,59,0.10);
  box-shadow: 0 10px 22px rgba(0,0,0,0.35);
  white-space: nowrap;
}

.avg-banner strong{ font-weight: 950; }

.avg-banner .avg-label{
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.95;
}

.avg-banner.subtle{
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
}

.rates{
  display:grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 1024px){
  .rates{ grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 640px){
  .hero-inner{ padding: 16px; }
  .rates{ grid-template-columns: repeat(3, 1fr); }
}

/* cards */
.rate-card{
  border: 2px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 8px 10px 8px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.34);
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.rate-card::after{
  content:"";
  position:absolute;
  inset:-30% -30% auto -30%;
  height: 80%;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.10), transparent 55%);
  pointer-events:none;
}

.rate-card .time{
  font-size: 11px;
  color: rgba(255,255,255,0.88);
  margin-bottom: 4px;
  font-weight: 800;
}

.rate-card .price{
  font-size: 18px;
  font-weight: 950;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.0;
}

.rate-card.past{
  opacity: 0.22;
  filter: grayscale(0.9);
}

/* SOLID bright colours (no gradients) */
.rate-card.very-cheap{
  border-color: rgba(255,255,255,0.18);
  background: var(--green);
  box-shadow: 0 10px 22px rgba(0,0,0,0.34), 0 0 0 3px rgba(0,200,83,0.18);
}

.rate-card.cheap{
  border-color: rgba(255,255,255,0.18);
  background: var(--green2);
  box-shadow: 0 10px 22px rgba(0,0,0,0.34), 0 0 0 3px rgba(0,178,72,0.18);
}

.rate-card.mid{
  border-color: rgba(255,255,255,0.18);
  background: var(--amber);
  box-shadow: 0 10px 22px rgba(0,0,0,0.34), 0 0 0 3px rgba(255,235,59,0.18);
}

/* Yellow needs dark text for readability */
.rate-card.mid .time{ color: rgba(0,0,0,0.75); }
.rate-card.mid .price{
  color: #000;
  text-shadow: none;
}

.rate-card.expensive{
  border-color: rgba(255,255,255,0.18);
  background: var(--red);
  box-shadow: 0 10px 22px rgba(0,0,0,0.34), 0 0 0 3px rgba(255,23,68,0.18);
}

/* make text readable on bright solids */
.rate-card.very-cheap .time,
.rate-card.cheap .time,
.rate-card.mid .time,
.rate-card.expensive .time{
  color: rgba(255,255,255,0.92);
}

.rate-card.very-cheap .price,
.rate-card.cheap .price,
.rate-card.mid .price,
.rate-card.expensive .price{
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* CHEAPEST SLOT - much stronger */
.rate-card.cheapest-slot{
  outline: 4px solid rgba(255,255,255,0.98);
  outline-offset: 3px;
  transform: translateZ(0);
  animation: cheapestPulse 0.9s ease-in-out infinite;
}

.rate-card.cheapest-slot::before{
  content: "★";
  position: absolute;
  top: 7px;
  right: 9px;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.55);
  opacity: 0.98;
}

@keyframes cheapestPulse{
  0%, 100%{
    box-shadow:
      0 0 0 0 rgba(255,255,255,0.0),
      0 12px 26px rgba(0,0,0,0.40);
    filter: brightness(1.0);
  }
  50%{
    box-shadow:
      0 0 0 10px rgba(255,255,255,0.22),
      0 12px 26px rgba(0,0,0,0.40);
    filter: brightness(1.12);
  }
}

/* simplified view */
body.compact .rates{
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 1024px){
  body.compact .rates{ grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 640px){
  body.compact .rates{ grid-template-columns: repeat(4, 1fr); }
}

body.compact .rate-card{
  padding: 6px 8px 6px;
  border-radius: 12px;
}

body.compact .rate-card .time{
  font-size: 10px;
  margin-bottom: 3px;
}

body.compact .rate-card .price{
  font-size: 16px;
}

.loading{
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(255,255,255,0.03);
}

footer{
  max-width: 1100px;
  margin: 22px auto 30px;
  padding: 0 16px;
  color: var(--muted2);
  font-size: 12px;
  text-align: center;
}

html, body{
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* prevents right-side drift */
}

.hero, .container, footer{
  width: 100%;
  max-width: 100%;
}

.hero-inner{
  width: 100%;
  max-width: 1100px;  /* keep desktop behaviour */
  margin-left: auto;
  margin-right: auto;
}

/* Safari/iOS: avoid flex items forcing overflow */
.top-bar, .hero-inner, .controls-bar, .region-pills{
  min-width: 0;
}

@media (max-width: 520px){

  /* slightly tighter padding so it fits cleanly */
  .hero{ padding: 20px 12px 12px; }
  .hero-inner{ padding: 14px 14px 12px; border-radius: 16px; }

  /* stack the hero heading + description neatly */
  .hero-head{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* region buttons: ensure they wrap and never force a horizontal scroll */
  .region-pills{
    gap: 8px;
  }
  .pill{
    max-width: 100%;
  }

  /* controls: force a clean stacked layout */
  .controls-bar{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .control-group{
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  #sortSelect{
    width: 100%;
  }

  .control-toggle{
    width: 100%;
    justify-content: flex-start;
  }

  /* top bar: allow wrapping without pushing content off-screen */
  .top-bar{
    flex-wrap: wrap;
    gap: 8px;
  }
  .top-left{
    flex: 1 1 100%;
    white-space: normal;
  }
  .top-right{
    flex: 1 1 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 520px){

  /* Make the summary row behave cleanly */
  .summary-row{
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* Average banner: compact, centred, no overflow */
  .avg-banner{
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    white-space: normal;
  }

  .avg-banner .avg-label{
    font-size: 11px;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
  }

  .avg-banner strong{
    font-size: 18px;
    white-space: nowrap;
  }

  /* Rate grid: tighter spacing on mobile */
  .rates{
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Rate cards: ultra-compact */
  .rate-card{
    padding: 8px 8px 6px;
    border-radius: 14px;
  }

  .rate-card .time{
    font-size: 11px;
    margin-bottom: 2px;
  }

  .rate-card .price{
    font-size: 18px;
  }

  .rate-card .unit{
    display: none;
  }

  /* Cheapest highlight stays strong but not oversized */
  .rate-card.cheapest{
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 14px rgba(255,255,255,0.6);
  }
}