/*
 * ZDES.lab admin panel: the one and only stylesheet.
 *
 * Served from the same origin (GET /static/admin.css, web/static_files.py),
 * because the Content-Security-Policy is default-src 'self': no inline
 * styles, no style="" attributes, no external fonts or images, no @import.
 * All interface texts live in content/admin.yaml, never in this file
 * (a test keeps Cyrillic out of it).
 *
 * Colour language, on purpose the same on every page:
 *   red     - instance PROD, guard banner, errors and refusals
 *   amber   - instance TEST, warnings
 *   green   - success
 *   blue    - links, the current page, the primary action
 * Rules for the coloured parts are flat (plain hex colours, no variables),
 * so tests/test_web_ui_layout.py can read the colour of each rule.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: #1f2933;
  background: #f4f5f7;
  overflow-wrap: break-word;
}

/* ---- header: instance plate, navigation, logout ---- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.7rem 1rem;
  background: #ffffff;
  border-top: 10px solid #ffb300;
  border-bottom: 1px solid #c5ccd6;
}

body.instance-prod .site-header {
  border-top-color: #c62828;
}

.instance-plate {
  display: inline-block;
  padding: 0.25em 0.9em;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.instance-plate.instance-test {
  background: #ffb300;
  color: #1f1a00;
  border: 2px solid #b26a00;
}

.instance-plate.instance-prod {
  background: #c62828;
  color: #ffffff;
  border: 2px solid #7f0000;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.main-nav a {
  display: inline-block;
  min-height: 44px;
  padding: 0.5em 0.9em;
  border: 2px solid transparent;
  border-radius: 6px;
  color: #0b3d91;
  font-weight: 600;
  text-decoration: none;
}

.main-nav a:hover {
  background: #e8eef9;
  border-color: #b7c7e6;
}

.main-nav a[aria-current="page"] {
  background: #0b3d91;
  border-color: #0b3d91;
  color: #ffffff;
}

.logout-form {
  margin: 0 0 0 auto;
}

/* ---- page body ---- */

.page {
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 1rem;
}

/* Running text stays about 60-70 characters wide; tables and card grids may
   use the full width of the page. */
.page > h1,
.page > h2,
.page > p,
.page > ul,
.page > ol,
.page > form,
.page > pre,
.page > .guard-banner,
.page > .error,
.page > .warning,
.page > .ok {
  max-width: 68ch;
}

h1 {
  margin: 0.4rem 0 0.8rem;
  font-size: 1.6rem;
  line-height: 1.25;
}

h2 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.3rem;
  line-height: 1.3;
}

p,
ul,
ol {
  margin: 0.6rem 0;
}

a {
  color: #0b57d0;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: #062e6f;
}

img {
  max-width: 100%;
  height: auto;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

/* ---- forms ---- */

label {
  display: block;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  margin-top: 0.3rem;
  padding: 0.55em 0.75em;
  font: inherit;
  color: inherit;
  background: #ffffff;
  border: 2px solid #7b8794;
  border-radius: 6px;
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

button {
  min-height: 48px;
  padding: 0.5em 1.4em;
  font: inherit;
  font-weight: 600;
  color: #1f2933;
  background: #e4e7eb;
  border: 2px solid #616e7c;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: #d2d6dc;
}

/* The one action that must not be missed: Publish (and Sign in). */
button.primary {
  padding: 0.65em 2em;
  font-size: 1.1rem;
  color: #ffffff;
  background: #0b57d0;
  border-color: #0842a0;
}

button.primary:hover {
  background: #0842a0;
}

/* A small form next to other content (stuck-publish choices, views in a table). */
.inline-form {
  display: inline-block;
  margin: 0 0.5rem 0.5rem 0;
}

td input[type="text"] {
  display: inline-block;
  width: 8em;
  margin: 0 0.4rem 0 0;
}

/* ---- messages ---- */

.guard-banner {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  color: #7f1d1d;
  background: #fdecea;
  border: 3px solid #c62828;
  border-radius: 6px;
}

.guard-banner p,
.guard-banner ul {
  margin: 0.3rem 0;
}

.error {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #7f1d1d;
  background: #fdecea;
  border: 2px solid #c62828;
  border-radius: 6px;
}

.warning {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #5f4300;
  background: #fff8e1;
  border: 2px solid #f9a825;
  border-radius: 6px;
}

.ok {
  margin: 1rem 0;
  padding: 0.7rem 1rem;
  color: #14421a;
  background: #e8f5e9;
  border: 2px solid #2e7d32;
  border-radius: 6px;
}

/* ---- post preview ---- */

pre {
  margin: 0.5rem 0 1rem;
  padding: 0.75em 1em;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #ffffff;
  border: 1px solid #b8c0cc;
  border-left: 6px solid #0b57d0;
  border-radius: 6px;
}

/* ---- tables: bordered, padded, scroll sideways inside their own box ---- */

.table-wrap {
  max-width: 100%;
  margin: 1rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #c5ccd6;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 0.55em 0.75em;
  text-align: left;
  vertical-align: top;
  border: 1px solid #b8c0cc;
}

th {
  font-weight: 700;
  background: #e9edf3;
}

tbody tr:nth-child(even) td {
  background: #f8f9fb;
}

/* ---- deck: cards ---- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.card {
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid #b8c0cc;
  border-radius: 8px;
}

.page > .card {
  max-width: 16rem;
}

.card p {
  margin: 0.4rem 0;
}

.card img {
  display: block;
}

/* ---- phones ---- */

/* Plate and Logout share the first row, the navigation takes the second. */
@media (max-width: 40rem) {
  body {
    font-size: 17px;
  }

  .site-header {
    gap: 0.4rem 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  .main-nav {
    order: 3;
    flex-basis: 100%;
    gap: 0.1rem 0.25rem;
  }

  .main-nav a {
    padding: 0.5em 0.45em;
  }

  .page {
    padding: 0.75rem;
  }
}
