/* mikkel-q kalibrerings-UI — minimal, funksjonell, ingen build-step. */

:root {
  --green: #2c8a3a;
  --green-dark: #1f6b2b;
  --yellow: #e6b800;
  --red: #d33;
  --gray-bg: #f4f4f4;
  --gray-border: #ddd;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #fafafa;
  color: #222;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1em;
  padding: 1em;
  min-height: 100vh;
}

.stream-container {
  position: relative;
  background: #000;
  align-self: start;
  border-radius: 4px;
  overflow: hidden;
}

.stream-container img {
  display: block;
  width: 100%;
  height: auto;
}

.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.sidebar {
  background: var(--gray-bg);
  padding: 1em 1.25em;
  border-radius: 4px;
  overflow-y: auto;
  max-height: calc(100vh - 2em);
}

.sidebar h1 {
  margin: 0 0 0.25em 0;
  font-size: 1.4em;
}

.sidebar h2 {
  margin: 1.5em 0 0.5em 0;
  font-size: 1.05em;
  border-bottom: 1px solid var(--gray-border);
  padding-bottom: 0.25em;
}

.meta {
  font-size: 0.85em;
  color: #666;
  margin: 0 0 1em 0;
  font-family: monospace;
}

.toolbar {
  display: flex;
  gap: 0.4em;
  flex-wrap: wrap;
}

.toolbar button {
  padding: 0.5em 0.9em;
  border: 1px solid var(--gray-border);
  background: white;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9em;
}

.toolbar button.active {
  background: var(--green);
  color: white;
  border-color: var(--green-dark);
}

.toolbar button:hover:not(.active) {
  background: #eef;
}

.hint {
  font-size: 0.85em;
  color: #555;
  margin: 0.5em 0 0 0;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item-list li {
  padding: 0.5em 0;
  border-bottom: 1px solid var(--gray-border);
  font-size: 0.9em;
}

.item-list li .delete {
  float: right;
  cursor: pointer;
  color: var(--red);
  font-weight: bold;
  padding: 0 0.5em;
}

.item-list li .delete:hover {
  color: #a00;
}

.state {
  font-family: monospace;
  font-size: 0.95em;
  background: white;
  padding: 0.6em;
  border-radius: 3px;
  border: 1px solid var(--gray-border);
}

.state-numbers {
  font-weight: bold;
  color: var(--green);
}

.save-btn {
  width: 100%;
  padding: 0.75em;
  font-size: 1.05em;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.save-btn:hover { background: var(--green-dark); }

#save-status {
  margin: 0.5em 0 0 0;
  font-size: 0.9em;
  min-height: 1.2em;
}

.help-panel {
  font-size: 0.88em;
  margin: 0.5em 0 1em;
  background: var(--gray-bg);
  border: 1px solid var(--gray-border);
  border-radius: 4px;
  padding: 0.4em 0.8em;
}
.help-panel summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.4em 0;
  user-select: none;
}
.help-panel h4 {
  margin: 0.8em 0 0.2em;
  font-size: 0.95em;
}
.help-panel p, .help-panel ul {
  margin: 0.2em 0;
  color: #444;
  line-height: 1.4;
}
.help-panel ul {
  padding-left: 1.2em;
}
.help-panel code {
  background: white;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.95em;
}

/* Linje-edit modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  padding: 1.5em;
  border-radius: 8px;
  min-width: 340px;
  max-width: 92vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-content h3 {
  margin: 0 0 1em;
}
.modal-content label {
  display: block;
  margin: 0.8em 0;
  font-size: 0.95em;
  font-weight: 500;
}
.modal-content input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.4em 0.6em;
  margin-top: 0.3em;
  font-size: 1em;
  border: 1px solid var(--gray-border);
  border-radius: 3px;
}
.modal-content input[type="color"] {
  display: inline-block;
  width: 60px;
  height: 36px;
  vertical-align: middle;
  margin-left: 0.5em;
  border: 1px solid var(--gray-border);
  border-radius: 3px;
  cursor: pointer;
}
.direction-set {
  margin: 1em 0;
  border: 1px solid var(--gray-border);
  border-radius: 4px;
  padding: 0.4em 0.8em 0.8em;
}
.direction-set legend {
  font-weight: 600;
  font-size: 0.9em;
  padding: 0 0.4em;
}
.direction-set label {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-weight: normal;
  margin: 0.4em 0;
}
.direction-set input[type="radio"] {
  margin: 0;
}
.point-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #444;
  color: white;
  font-weight: 600;
  font-size: 0.82em;
  line-height: 1;
}
.point-pill.a { background: #2196f3; }
.point-pill.b { background: #ff5722; }

.modal-warnings {
  list-style: none;
  padding: 0;
  margin: 0.8em 0 0;
  font-size: 0.85em;
  color: #b87600;
}
.modal-warnings li {
  margin: 0.3em 0;
  padding-left: 1.4em;
  position: relative;
}
.modal-warnings li::before {
  content: "⚠";
  position: absolute;
  left: 0;
  top: 0;
}

.modal-buttons {
  display: flex;
  gap: 0.5em;
  justify-content: flex-end;
  margin-top: 1.2em;
}
.modal-buttons button {
  padding: 0.5em 1.1em;
  font-size: 0.95em;
  cursor: pointer;
  border: 1px solid var(--gray-border);
  background: white;
  border-radius: 3px;
}
.modal-buttons .primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.modal-buttons .primary:hover { background: var(--green-dark); }

/* Sidebar element-list */
.line-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
  border: 1px solid rgba(0,0,0,0.2);
}
.line-name-btn {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: underline dotted;
}
.line-name-btn:hover {
  text-decoration: underline;
}
.element-warning {
  color: #b87600;
  font-size: 0.95em;
  margin-left: 0.4em;
  cursor: help;
}

.camera-controls {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  margin: 0.5em 0 1em 0;
}

.camera-controls label {
  font-size: 0.9em;
  font-weight: 500;
  color: #555;
}

.camera-controls label.inline {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.camera-controls select {
  padding: 0.4em 0.6em;
  font-size: 0.95em;
  border: 1px solid var(--gray-border);
  border-radius: 3px;
  background: white;
}

.footer {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--gray-border);
  font-size: 0.8em;
  color: #888;
  line-height: 1.4;
}

.footer code {
  background: white;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.9em;
}

/* ---- Auth-status (Mikkelvakt-innlogga brukar) ---------------------------- */

.auth-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4em 0.6em;
  margin-bottom: 0.8em;
  background: #eef4f9;
  border: 1px solid #c8d8e8;
  border-radius: 4px;
  font-size: 0.85em;
}

.auth-email {
  font-family: monospace;
  color: #2a5a8a;
  word-break: break-all;
  padding-right: 0.5em;
}

.auth-logout-btn {
  padding: 0.3em 0.7em;
  background: #fff;
  border: 1px solid #c8d8e8;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.85em;
  white-space: nowrap;
}

.auth-logout-btn:hover {
  background: #f0f5fa;
}

/* ---- Felt-validering ----------------------------------------------------- */

#validation-section {
  margin-top: 1em;
  padding-top: 0.5em;
  border-top: 2px solid #d4a017;
}

.validation-toggle {
  width: 100%;
  padding: 0.8em;
  font-size: 1.1em;
  background: #d4a017;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.validation-toggle:hover {
  background: #b88a10;
}

.validation-panel.hidden,
#save-section.hidden,
#validation-start.hidden {
  display: none;
}

.session-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 0;
  font-size: 0.9em;
  color: #666;
}

.session-meta code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
}

.session-meta button.secondary {
  padding: 0.3em 0.8em;
  background: #eee;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
}

.validation-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5em;
  padding: 0.8em;
  background: #f8f5e8;
  border-radius: 4px;
  margin: 0.5em 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.validation-stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.85em;
}

.validation-stats .label {
  color: #888;
  font-size: 0.85em;
  text-transform: uppercase;
}

.validation-stats span:not(.label) {
  font-size: 1.3em;
  font-weight: 600;
  color: #333;
  font-variant-numeric: tabular-nums;
}

.hint-inline {
  font-size: 0.75em;
  color: #888;
  font-weight: normal;
}

.validation-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em;
  margin: 0.5em 0;
}

.gt-btn {
  min-height: 60px;
  padding: 0.5em 0.8em;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  font-size: 1em;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.gt-btn:active {
  transform: scale(0.98);
}

.gt-in {
  background: #e8f5e8;
}

.gt-in:hover {
  background: #d8eed8;
}

.gt-out {
  background: #fef0e0;
}

.gt-out:hover {
  background: #fce0c8;
}

.gt-direction {
  font-weight: 700;
  font-size: 1.1em;
}

.gt-in .gt-direction {
  color: #2a7a2a;
}

.gt-out .gt-direction {
  color: #c0701c;
}

.gt-line {
  font-size: 0.85em;
  color: #555;
  margin-top: 2px;
}

.undo-btn {
  width: 100%;
  padding: 0.6em;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
}

.undo-btn:hover {
  background: #e4e4e4;
}

.validation-flash {
  min-height: 1.4em;
  margin: 0.4em 0;
  font-size: 0.9em;
  font-weight: 500;
}

.validation-flash.kind-ok {
  color: #2a7a2a;
}

.validation-flash.kind-warn {
  color: #c08010;
}

.validation-flash.kind-error {
  color: #c02020;
}

.validation-result {
  padding: 0.8em;
  background: #f0f5fa;
  border-radius: 4px;
  font-size: 1em;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}

.validation-result strong {
  font-size: 1.2em;
  color: #2a5a8a;
}

.download-btn {
  display: inline-block;
  margin-top: 0.5em;
  padding: 0.6em 1em;
  background: #2a5a8a;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.95em;
}

.download-btn:hover {
  background: #1e4670;
}

/* Mobile-tuning: smalare sidebar på telefon */
@media (max-width: 600px) {
  .validation-stats {
    grid-template-columns: 1fr 1fr 1fr;
    font-size: 0.9em;
  }
  .validation-stats span:not(.label) {
    font-size: 1.1em;
  }
  .gt-btn {
    min-height: 70px;  /* større touch-target på mobile */
  }
}
