/* ── Notfallpass — style.css ── */

/* ── Colour variables ── */
:root {
  --color_gray-light: #efefef;
  --color_black:      #1a1814;
  --color_red:        #b71e1e;
  --color_gray-dark:  #6e6c67;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    letter-spacing: 0.03em;
}

/* ── Typography ── */

/* label: monospace, small — for field titles and section headers */
label {
  font-family: ui-monospace, 'Courier New', monospace;
  font-size: 0.8em;
  font-weight: 400;
  color: var(--color_gray-dark);
  display: block;
  margin-bottom: 0.25em;
}

/* p: serif body text — for field values, text blocks, descriptions */
p {
  font-size: 0.95em;
  font-weight: 400;
  line-height: 1.65;
  color: var(--color_black);
}

/* name: large serif — for the patient name in the viewer header */
.name {
  font-size: 2em;
  font-weight: 400;
  line-height: 1.15;
  color: var(--color_black);
}

/* ── Base ── */
body {
  background: var(--color_gray-light);
  color: var(--color_black);
  min-height: 100vh;
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── States ── */
#state-landing,
#state-loading,
#state-error {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2em;
  gap: 0.75em;
}

#state-viewer,
#state-editor {
  display: none;
}

#state-viewer.visible,
#state-editor.visible {
  display: block;
}

/* ── Landing ── */
.landing-cross {
  font-size: 2.5em;
  color: var(--color_red);
  line-height: 1;
}

.landing-title {
  font-size: 1.8em;
  font-weight: 400;
  color: var(--color_black);
}

.landing-subtitle {
  font-size: 0.85em;
  color: var(--color_gray-dark);
  font-style: italic;
}

/* ── Loading ── */
.loading-ring {
  width: 30px;
  height: 30px;
  border: 2px solid #ddd8d0;
  border-top-color: var(--color_red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-bar {
  width: 160px;
  height: 1px;
  background: #ddd8d0;
}

.loading-bar-fill {
  height: 100%;
  background: var(--color_red);
  width: 0%;
  transition: width 0.3s;
}

.loading-label {
  font-family: ui-monospace, monospace;
  font-size: 0.7em;
  color: var(--color_gray-dark);
}

/* ── Error ── */
.error-icon {
  font-size: 1.5em;
  color: var(--color_red);
}

.error-title {
  font-size: 1.1em;
}

.error-message {
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  color: var(--color_red);
  border: 1px solid var(--color_red);
  border-radius: 2px;
  padding: 0.75em 1em;
  max-width: 440px;
  line-height: 1.7;
  white-space: pre-wrap;
  text-align: left;
}

/* ── Viewer ── */
#content {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5em 4em;
}

.viewer-header {
  padding: 2em 0 1.5em;
  margin-bottom: 0;
}

.viewer-cross {
  font-size: 2em;
  color: var(--color_red);
  margin-bottom: 0.4em;
}

.viewer-meta {
  font-family: ui-monospace, monospace;
  font-size: 0.7em;
  color: var(--color_gray-dark);
  margin-top: 0.3em;
}

/* ── Section ── */
section {
  padding-top: 1.5em;
  border-top: 1px solid #ddd8d0;
  margin-top: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.section-title {
  font-family: ui-monospace, monospace;
  font-size: 0.8em;
  color: var(--color_gray-dark);
}

/* ── Items (field grid) ── */
.items-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
}

.items-grid .item {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
}

.item .field-value {
  font-size: 1.2em;
  color: var(--color_black);
}

.item .field-value.accent {
  color: var(--color_red);
  font-weight: bold;
}

.item .field-value.empty {
  color: var(--color_gray-dark);
  font-style: italic;
  font-size: 0.85em;
}

/* ── Text block ── */
.text-block {
  font-size: 0.92em;
  line-height: 1.7;
  color: var(--color_black);
  white-space: pre-wrap;
  border-left: 2px solid #ddd8d0;
  padding-left: 0.9em;
}

.text-block.empty {
  color: var(--color_gray-dark);
  font-style: italic;
  border-color: transparent;
  padding-left: 0;
}

/* ── Contacts ── */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.contact-card {
  display: flex;
  flex-direction: row;
  gap: 1em;
  padding: 0.55em 0;
  border-bottom: 1px solid #ddd8d0;
}

.contact-card:last-child {
  border-bottom: none;
}

.contact-role {
  font-family: ui-monospace, monospace;
  font-size: 0.62em;
  color: var(--color_gray-dark);
  width: 80px;
  flex-shrink: 0;
  padding-top: 0.15em;
}

.contact-name {
  font-size: 0.92em;
  color: var(--color_black);
}

.contact-detail {
  font-family: ui-monospace, monospace;
  font-size: 0.72em;
  color: var(--color_gray-dark);
  margin-top: 0.1em;
}

/* ── PDF list (viewer) ── */
.pdf-list {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

.pdf-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65em;
  padding: 0.6em 0.85em;
  border: 1px solid #ddd8d0;
  border-radius: 2px;
  background: white;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--color_black);
  transition: border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.pdf-item:hover,
.pdf-item:active {
  border-color: var(--color_red);
}

.pdf-item-name {
  flex: 1;
  font-size: 0.88em;
}

.pdf-item-size {
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: var(--color_gray-dark);
}

.pdf-item-arrow {
  font-size: 0.75em;
  color: var(--color_red);
  font-weight: bold;
}

/* ── Editor header ── */
.editor-header {
  background: var(--color_black);
  color: var(--color_gray-light);
  padding: 0.75em 1.5em;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1em;
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
}

.editor-badge {
  margin-left: auto;
  color: var(--color_gray-dark);
  font-size: 0.6em;
}

/* ── Editor form ── */
.editor-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 2em;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.form-section-title {
  font-family: ui-monospace, monospace;
  font-size: 0.62em;
  color: var(--color_gray-dark);
  padding-bottom: 0.4em;
  border-bottom: 1px solid #ddd8d0;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75em;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  flex: 1 1 200px;
}

.form-group.full {
  flex: 1 1 100%;
}

input[type="text"],
input[type="date"],
input[type="tel"],
input[type="email"],
input[type="password"],
textarea,
select {
  background: white;
  border: 1px solid #ddd8d0;
  border-radius: 2px;
  padding: 0.5em 0.65em;
  font-size: 0.88em;
  color: var(--color_black);
  width: 100%;
  outline: none;
  transition: border-color 0.1s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color_red);
}

input::placeholder,
textarea::placeholder {
  color: #ccc8c0;
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
}

/* ── Contact editor rows ── */
.contact-editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

.contact-editor-row {
  display: flex;
  flex-direction: row;
  gap: 0.4em;
  align-items: center;
  padding: 0.5em 0.65em;
  border: 1px solid #ddd8d0;
  border-radius: 2px;
  background: white;
}

.contact-editor-row input {
  flex: 1;
  border: none;
  padding: 0;
  font-size: 0.85em;
  background: transparent;
}

.contact-editor-row input:focus {
  outline: none;
  border: none;
}

.contact-editor-row input + input {
  border-left: 1px solid #ddd8d0;
  padding-left: 0.5em;
}

/* ── PDF upload ── */
.pdf-editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

.pdf-editor-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.75em;
  border: 1px solid #ddd8d0;
  border-radius: 2px;
  background: white;
  font-size: 0.82em;
}

.pdf-editor-row-name {
  flex: 1;
}

.pdf-editor-row-size {
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: var(--color_gray-dark);
}

.pdf-total {
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: var(--color_gray-dark);
}

.pdf-upload-zone {
  border: 1px dashed #ddd8d0;
  border-radius: 2px;
  padding: 1.1em;
  text-align: center;
  cursor: pointer;
  background: white;
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  color: var(--color_gray-dark);
  transition: border-color 0.1s, color 0.1s;
}

.pdf-upload-zone:hover,
.pdf-upload-zone.dragover {
  border-color: var(--color_red);
  color: var(--color_black);
}

/* ── Password fields ── */
.pw-field {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.pw-field input {
  padding-right: 2.2em;
}

.pw-toggle {
  position: absolute;
  right: 0.5em;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color_gray-dark);
  font-size: 0.72em;
  padding: 0;
  line-height: 1;
}

.pw-hint {
  font-family: ui-monospace, monospace;
  font-size: 0.62em;
  color: var(--color_gray-dark);
  line-height: 1.5;
  margin-top: 0.2em;
}

/* ── URL output box ── */
.url-output-box {
  background: var(--color_black);
  border-radius: 2px;
  padding: 1em 1.1em;
  margin-top: 0.75em;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.url-row {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

.url-row-label {
  font-family: ui-monospace, monospace;
  font-size: 0.58em;
  color: #555;
}

.url-row-value {
  font-family: ui-monospace, monospace;
  font-size: 0.7em;
  color: #bbb;
  word-break: break-all;
  line-height: 1.55;
}

.url-row-value .fragment {
  color: #e8a87c;
}

.url-copy-button {
  font-family: ui-monospace, monospace;
  font-size: 0.62em;
  background: none;
  border: 1px solid #333;
  border-radius: 2px;
  color: #666;
  padding: 0.15em 0.5em;
  cursor: pointer;
  margin-top: 0.2em;
  align-self: flex-start;
  transition: color 0.1s, border-color 0.1s;
}

.url-copy-button:hover {
  color: #bbb;
  border-color: #555;
}

/* ── Download hint ── */
.download-hint {
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: var(--color_gray-dark);
  line-height: 1.6;
  border: 1px solid #ddd8d0;
  border-radius: 2px;
  padding: 0.65em 0.85em;
  background: white;
}

.download-hint strong {
  color: var(--color_black);
}

/* ── Buttons ── */
.button-primary {
  background: var(--color_red);
  color: white;
  border: none;
  border-radius: 2px;
  padding: 0.6em 1.25em;
  font-family: ui-monospace, monospace;
  font-size: 0.75em;
  cursor: pointer;
  transition: opacity 0.1s;
}

.button-primary:hover { opacity: 0.85; }
.button-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.button-secondary {
  background: none;
  color: var(--color_black);
  border: 1px solid #ddd8d0;
  border-radius: 2px;
  padding: 0.6em 1em;
  font-family: ui-monospace, monospace;
  font-size: 0.75em;
  cursor: pointer;
  transition: border-color 0.1s;
}

.button-secondary:hover { border-color: var(--color_black); }

.button-add {
  background: none;
  border: 1px dashed #ddd8d0;
  border-radius: 2px;
  padding: 0.45em 0.9em;
  font-family: ui-monospace, monospace;
  font-size: 0.72em;
  color: var(--color_gray-dark);
  cursor: pointer;
  width: 100%;
  transition: border-color 0.1s, color 0.1s;
}

.button-add:hover {
  border-color: var(--color_red);
  color: var(--color_red);
}

.button-emove {
  background: none;
  border: none;
  color: var(--color_gray-dark);
  cursor: pointer;
  font-size: 0.75em;
  padding: 0 0.25em;
  flex-shrink: 0;
  transition: color 0.1s;
}

.button-emove:hover { color: var(--color_red); }

/* ── Action bar ── */
.action-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6em;
  padding: 1em 1.5em;
  border-top: 1px solid #ddd8d0;
  background: var(--color_gray-light);
  position: sticky;
  bottom: 0;
}

.save-status {
  font-family: ui-monospace, monospace;
  font-size: 0.68em;
  color: var(--color_gray-dark);
  margin-left: auto;
}

.save-status.ok  { color: #2d6a4f; }
.save-status.err { color: var(--color_red); }
