/* =====================================================================
   main.css


   To use: 
		add this line to each page's <head>, then delete the page's <style> block.
		<link rel="stylesheet" href="../css/main.css">
   
   ===================================================================== */


/* ---------------------------------------------------------------------
   1. Colors and shared values
   --------------------------------------------------------------------- */
:root {
  --teal: #005758;          /* banner, buttons, focus */
  --teal-dark: #00474a;     /* button hover */
  --bar: #333333;           /* nav and footer */
  --page: #f4f4f4;          /* page background */
  --field: #f9f9f9;         /* read-only value boxes */
  --field-border: #cccccc;  /* value box border */
  --link: #0077cc;          /* section heading links, an Error Description that opens a resolution, links in the resolution popup */
  --success: #4caf50;       /* "Copied" popup, OK status text, edge of a value box marked ok */
  --warn: #8a5a00;          /* warning status text */
  --error: #b00020;         /* error status text, edge of a value box marked error */
  --muted: #666666;         /* hints and neutral status text */
  --icon: #8a8a8a;          /* copy and clear icons */
  --label-width: 100px;     /* field label column */
  --footer-space: 6em;      /* room under the content so the pinned footer never covers it */
  --shade: rgba(0, 0, 0, 0.4); /* page shading behind the resolution popup */
}


/* ---------------------------------------------------------------------
   2. Base
   --------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--page);
}


/* ---------------------------------------------------------------------
   3. Page frame: banner, nav bar, content, footer
   Element selectors, so they also style Tenant Lookup's
   .banner, .menu and .footer elements. Its .page wrapper needs no rule.
   --------------------------------------------------------------------- */
header {
  background-color: var(--teal);
  color: #ffffff;
  padding: 1em;
  text-align: center;
}

nav {
  margin: 0;
  padding: 1em;
  background-color: var(--bar);
}

nav a {
  color: #ffffff;
  margin: 0 1em;
  text-decoration: none;
}

main {
  padding: 2em 2em calc(2em + var(--footer-space));
}

footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  padding: 2em 1em;         /* same height whether or not the text sits in a <p> */
  background-color: var(--bar);
  color: #ffffff;
  text-align: center;
}

footer p {
  margin: 0;
}


/* ---------------------------------------------------------------------
   4. Two-column layout (Corporate info)
   --------------------------------------------------------------------- */
.container {
  display: flex;
}

.column {
  flex: 1;
  padding: 10px;
}


/* ---------------------------------------------------------------------
   5. Section heading row: title on the left, link on the right
     --------------------------------------------------------------------- */
.header-container,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 20px;
}

.section-title,
.section-head h2 {
  margin: 0;
}

.header-container a,
.section-head a,
.right-link {
  color: var(--link);
  font-size: 1rem;
  text-decoration: none;
}


/* ---------------------------------------------------------------------
   6. Field rows: label | value | button
   --------------------------------------------------------------------- */
.param-container,
.row {
  display: grid;
  grid-template-columns: var(--label-width) minmax(0, 1000px) auto;
  justify-content: start;
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  margin-bottom: 20px;
}

.label,
.row label {
  font-weight: bold;
}

/* A row the page shows only when it has a value (Tenant Lookup's Error Code and Error Description) */
.param-container[hidden],
.row[hidden] {
  display: none;
}

/* A row with a mouse-over description shows the help pointer on its label */
.param-container[title] .label,
.row[title] label {
  cursor: help;
}

/* Value box: looks like a text box, not editable */
.value-box,
.field {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--field-border);
  border-radius: 4px;
  background-color: var(--field);
  color: inherit;
  font: inherit;
  overflow-wrap: anywhere;  /* long codes wrap instead of widening the page */
}

/* An empty value box keeps the height of a one-line box (PAC Data leaves a missing value blank) */
.value-box:empty {
  min-height: calc(1.15em + 18px);  /* one line of text, plus the box's padding and border */
}

.field.editable {
  background-color: #ffffff;
}

.field[readonly] {
  cursor: text;
}

/* Value box that is a button (Tenant Lookup's Error Description): reads as
   plain text, and as a link when it opens a resolution */
.field.resolution {
  text-align: left;
  white-space: normal;
}

.field.resolution:enabled {
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}

.field.resolution:disabled {
  cursor: text;
}

/* A value marked good (ok) or bad (error), such as Valid POR: a colored edge on the box */
.value-box.ok,
.field.ok {
  border-color: var(--success);
  box-shadow: inset 4px 0 0 var(--success);
}

.value-box.error,
.field.error {
  border-color: var(--error);
  box-shadow: inset 4px 0 0 var(--error);
}

.field:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0, 87, 88, 0.18);
}

/* Hint under a field, and the status message line */
.hint,
.status {
  grid-column: 2 / 4;
}

.hint {
  font-size: 0.875em;
  color: var(--muted);
}

.status {
  min-height: 1.25em;
  color: var(--muted);
}

.status.ok {
  color: var(--success);
}

.status.warn {
  color: var(--warn);
}

.status.error {
  color: var(--error);
}


/* ---------------------------------------------------------------------
   7. Search box with built-in clear button (Tenant Lookup)
   --------------------------------------------------------------------- */
.search-box {
  position: relative;
  width: 100%;
}

.search-box .field {
  padding-right: 34px;
}

.clear {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 4px;
  border: 0;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.clear[hidden] {
  display: none;
}

.clear svg {
  display: block;
  width: 14px;
  height: 14px;
}

.clear svg .ink {
  stroke: var(--icon);
}

.clear:hover svg .ink,
.clear:focus svg .ink {
  stroke: var(--teal);
}

.clear:focus {
  outline: 1px dotted var(--teal);
}


/* ---------------------------------------------------------------------
   8. Buttons
   --------------------------------------------------------------------- */

/* Main action button (Tenant Lookup "Lookup") */
.btn {
  justify-self: start;
  padding: 8px 18px;
  border: 1px solid var(--teal);
  border-radius: 4px;
  background-color: var(--teal);
  color: #ffffff;
  font: inherit;
  font-weight: bold;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover,
.btn:focus {
  background-color: var(--teal-dark);
  border-color: var(--teal-dark);
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Copy buttons */
.copy-button,
.copy {
  justify-self: start;
  border: none;
  background: none;
  cursor: pointer;
}

.copy-button img,
.copy-button svg,
.copy svg {
  width: 20px;
  height: 20px;
}

/* The inline icon has no stroke of its own; this draws its outline */
.copy-button svg .ink,
.copy svg .ink {
  stroke: var(--icon);
}

/* Grayed out while there is nothing to copy */
.copy-button:disabled,
.copy:disabled {
  cursor: default;
  opacity: 0.45;
}


/* ---------------------------------------------------------------------
   9. Divider
   Covers plain <hr> and Tenant Lookup's <hr class="rule">.
   --------------------------------------------------------------------- */
hr {
  border: 2px solid #000000;
  margin: 0.5em 0 20px;
}


/* ---------------------------------------------------------------------
   10. "Copied" popup (Auth Code Viewer, Tenant Lookup)
   Hidden until the script adds "visible"; "error" marks a failed copy.
   --------------------------------------------------------------------- */
#popup {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  border-radius: 5px;
  background-color: var(--success);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

#popup.visible {
  display: block;
}

#popup.error {
  background-color: var(--error);
}


/* ---------------------------------------------------------------------
   11. Resolution popup (Tenant Lookup)
   A <dialog> the script opens with showModal(); the browser keeps it
   hidden until then and shades the page behind it.
   --------------------------------------------------------------------- */
.resolution-dialog {
  width: min(640px, calc(100% - 2em));
  padding: 1.5em;
  border: 1px solid var(--field-border);
  border-radius: 5px;
  background-color: #ffffff;
  color: inherit;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.resolution-dialog::backdrop {
  background-color: var(--shade);
}

.resolution-dialog p {
  margin: 0 0 1em;
}

.resolution-dialog a {
  color: var(--link);
}

.resolution-steps {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

.resolution-steps li {
  margin-bottom: 0.5em;
}

.resolution-actions {
  display: flex;
  justify-content: flex-end;
}
