/* ============================================================
   Potenslaegen Journalsystem — Stylesheet
   ============================================================ */

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

:root {
  --blue:       #1a6fa8;
  --blue-dark:  #145a87;
  --blue-light: #e8f2fa;
  --green:      #2e7d32;
  --red:        #c62828;
  --amber:      #e65100;
  --gray-50:    #f8f9fa;
  --gray-100:   #f0f2f5;
  --gray-200:   #e0e4ea;
  --gray-400:   #9aa3b0;
  --gray-600:   #5a6375;
  --gray-900:   #1a1e27;
  --radius:     6px;
  --shadow:     0 1px 4px rgba(0,0,0,.12);
  --shadow-md:  0 3px 10px rgba(0,0,0,.14);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-100);
  min-height: 100vh;
}

/* ---- Navigation ---- */
nav {
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

nav .brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
  margin-right: auto;
  text-decoration: none;
  color: #fff;
}

nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .9rem;
  padding: .25rem .5rem;
  border-radius: var(--radius);
  transition: background .15s;
}
nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
nav a.active { background: rgba(255,255,255,.2); color: #fff; }

#nav-user {
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  margin-left: auto;
}

#btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: .3rem .8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
}
#btn-logout:hover { background: rgba(255,255,255,.25); }

/* ---- Layout ---- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 { font-size: 1.4rem; font-weight: 700; color: var(--blue-dark); margin-bottom: 1.25rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: .75rem; }

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300, #d0d4da); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a31f1f; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; color: var(--gray-600); }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .95rem;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,111,168,.12);
}
.form-group textarea { min-height: 100px; resize: vertical; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { background: var(--gray-50); text-align: left; padding: .65rem .9rem; font-size: .82rem; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--gray-200); }
td { padding: .7rem .9rem; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--blue-light); }

/* ---- Alerts / Messages ---- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error   { background: #fce4e4; color: var(--red); border: 1px solid #f5c6c6; }
.alert-success { background: #e8f5e9; color: var(--green); border: 1px solid #c8e6c9; }
.alert-info    { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #b8d8f0; }
.alert-warning { background: #fff3e0; color: var(--amber); border: 1px solid #ffe0b2; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-green  { background: #e8f5e9; color: var(--green); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-amber  { background: #fff3e0; color: var(--amber); }

/* ---- Journal timeline ---- */
.timeline { list-style: none; position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.9rem;
  top: .45rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--blue);
}
.timeline-item.source-webhook::before { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.timeline-meta {
  font-size: .8rem;
  color: var(--gray-400);
  margin-bottom: .35rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.timeline-content { background: var(--gray-50); border-radius: var(--radius); padding: 1rem; border: 1px solid var(--gray-200); }
.timeline-content.webhook { border-left: 3px solid var(--green); }

/* Webhook data tabel */
.webhook-table { width: 100%; font-size: .85rem; }
.webhook-table td:first-child { color: var(--gray-600); font-weight: 500; width: 40%; vertical-align: top; padding: .3rem .5rem .3rem 0; }
.webhook-table td:last-child { padding: .3rem 0; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 1.25rem; }
.pagination button {
  padding: .35rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: .88rem;
}
.pagination button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Search bar ---- */
.search-bar { display: flex; gap: .75rem; margin-bottom: 1.25rem; }
.search-bar input { flex: 1; }

/* ---- Toolbar ---- */
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar-right { margin-left: auto; display: flex; gap: .5rem; }

/* ---- Patient header ---- */
.patient-header { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .patient-header { grid-template-columns: 1fr; } }
.patient-field label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-400); display: block; margin-bottom: .2rem; }
.patient-field span { font-size: 1rem; color: var(--gray-900); }

/* ---- Login page ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-dark) 0%, #1e88e5 100%);
}
.login-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { text-align: center; font-size: 1.1rem; margin-bottom: .25rem; }
.login-card .subtitle { text-align: center; color: var(--gray-400); font-size: .85rem; margin-bottom: 1.75rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal-box { background: #fff; border-radius: 8px; padding: 1.75rem; max-width: 480px; width: 90%; box-shadow: var(--shadow-md); }
.modal-box h2 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ---- Copy box ---- */
.copy-box {
  display: flex; gap: .5rem; align-items: center;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: .5rem .75rem; font-family: monospace; font-size: .9rem;
  word-break: break-all;
}
.copy-box button { flex-shrink: 0; }

/* ---- Misc ---- */
.text-muted { color: var(--gray-400); }
.text-small { font-size: .85rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }

/* Spinner */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
