/* ─── 1) Design tokens ───────────────────────────────────────────────────── */
:root {
  --bg: #f9f9f9;
  --text: #333;
  --muted: #666;
  --primary: #007bff;
  --primary-hover: #005fa3;
  --border: #ddd;
  --radius: 4px;
  --card-bg: #fff;
  --spacing: 1rem;
  --gap: 0.5rem;
  --input-height: 40px;

  /* max width for content + ad gutters */
  --site-max-width: 1100px;
}

/* ─── 2) Site wrapper ─────────────────────────────────────────────────────── */
.site-container {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
  width: 100%;
}

/* ─── 3) Global reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── 4) Base typography & layout ────────────────────────────────────────── */
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: calc(var(--spacing) * 2);
  text-align: center;
}

h1 {
  margin-bottom: calc(var(--spacing) / 4);
}

.description {
  max-width: 600px;
  margin: 0 auto calc(var(--spacing) * 1.5);
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.4;
}

/* ─── 5) Inputs & buttons ───────────────────────────────────────────────── */
input,
button {
  font-size: 1rem;
  border-radius: var(--radius);
}

input {
  padding: var(--gap);
  border: 1px solid var(--border);
}

button {
  padding: var(--gap) calc(var(--gap) * 2);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background .2s;
}
button:hover {
  background: var(--primary-hover);
}

/* ─── 6) Two-column container ────────────────────────────────────────────── */
.main-content {
  display: flex;
  gap: var(--gap);
  margin-top: var(--spacing);
}
.left-column  { flex: 2 1 0; }
.right-column { flex: 1 1 0; }

/* ─── 7) Panel cards (Top Sites, Favorites, Outages) ───────────────────── */
.section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacing);
  margin-bottom: var(--spacing);
  text-align: left;
  width: 100%;           /* fill its flex column */
}
.section h2 {
  margin-bottom: calc(var(--spacing) / 2);
  font-size: 1rem;
  text-align: center;
}

/* ─── 8) Status-check form ───────────────────────────────────────────────── */
.status-check-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--gap);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: var(--radius);
  padding: calc(var(--gap)/2);
  background: var(--card-bg);
  margin-bottom: var(--spacing);
  width: 100%;           /* fill its flex column */
  position: relative;    /* for dropdown */
  overflow: visible;
}

.status-check-panel input {
  width: 100%;
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: var(--radius);
  padding: var(--gap);
  height: var(--input-height);
  outline: none;
}

.status-check-panel button {
  padding: 0 var(--spacing);
  height: var(--input-height);
  white-space: nowrap;
}

/* ─── 9) Autocomplete dropdown ──────────────────────────────────────────── */
#suggestionBox {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}
#suggestionBox div {
  padding: var(--gap);
  cursor: pointer;
}
#suggestionBox div:hover,
#suggestionBox .selected {
  background: #f0f0f0;
}

/* ─── 10) Status display ─────────────────────────────────────────────────── */
.status {
  font-weight: 600;
  min-height: 3.5em;
  margin-bottom: var(--spacing);
  width: 100%;
}
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.dot.green { background: green; }
.dot.red   { background: red; }
.status-text.green { color: green; }
.status-text.red   { color: red; }

/* ─── 11) Top Sites table ───────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  width: 50%;
}
.popular-panel .site-name a {
  font-size: .95rem;   /* slightly smaller */
  font-weight: 600;    /* keep it bold */
}
.site-status {
  font-size: .8rem;
  color: var(--muted);
}

/* ─── 12) Favorites & Outages list ──────────────────────────────────────── */
#favoritesList {
  list-style: none;
}
#favoritesList li {
  display: grid;
  grid-template:
    "name remove"
    "status status"
    / 1fr auto;
  gap: calc(var(--gap)/2) var(--gap);
  align-items: center;
  margin-bottom: var(--spacing);
}
.favorites-panel .instruction {
  font-size: .95rem;                      /* match .description */
  color: var(--muted);
  text-align: center;
  margin-bottom: calc(var(--spacing)*1.5);
}
#favoritesList .site-name {
  grid-area: name;
  display: flex;
  align-items: center;
  font-weight: 600;
}
#favoritesList .site-name .dot {
  margin-right: 4px;
}
#favoritesList .site-status {
  grid-area: status;
}
button.remove-fav {
  grid-area: remove;
  justify-self: end;      /* flush-right */
  background: none;
  border: none;
  padding: 0;
  font-size: .9rem;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}
button.remove-fav:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* ─── 13) Favorite-star icon ───────────────────────────────────────────── */
.favorite-star {
  font-size: 1.2rem;
  margin-right: var(--gap);
  color: var(--muted);
  cursor: pointer;
  transition: color .2s;
}
.favorite-star:hover,
.favorite-star.starred {
  color: gold;
}

/* ─── 14) Footer ────────────────────────────────────────────────────────── */
footer {
  margin-top: calc(var(--spacing) * 2);
  font-size: .9rem;
  color: var(--muted);
}
footer a {
  margin-right: 10px;
}

/* ─── 15) Responsive stacking ───────────────────────────────────────────── */
@media (max-width: 767px) {
  .main-content {
    flex-direction: column;
    gap: var(--spacing);
  }
  .left-column,
  .right-column {
    display: contents;  /* unwrap panels */
  }
  .favorites-panel { order: 1; }
  .popular-panel   { order: 2; }
  .outages-panel   { order: 3; }
}

/* ─── 16) Mobile form stack ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .status-check-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: var(--gap);
  }
  .status-check-panel input,
  .status-check-panel button {
    width: 100%;
  }
  .status-check-panel button {
    margin: 0;
  }
}
