/* Papírtár – stíluslap. Mobil-first, világos/sötét téma. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #1e2430;
  --muted: #667085;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #e8f0fe;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 56px;
  --maxw: 880px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #171d2b;
    --surface-2: #1e2536;
    --border: #2a3346;
    --text: #e6eaf2;
    --muted: #9aa4b8;
    --primary: #4f8cff;
    --primary-ink: #0b1220;
    --primary-soft: #1b2740;
    --ok: #4ade80;
    --ok-bg: #10331f;
    --warn: #fbbf24;
    --warn-bg: #3a2c0a;
    --danger: #f87171;
    --danger-bg: #3a1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Fejléc ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-mark { font-size: 22px; }
.top-nav { display: flex; gap: 4px; }
.top-nav .nav-link {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.top-nav .nav-link.active { background: var(--primary-soft); color: var(--primary); }

/* ---------- Fő tartalom ---------- */
.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 100px;
}
.page { display: block; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; margin: 0; }
.page-head-actions { display: flex; gap: 8px; }
.section-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 24px 0 10px;
}

/* ---------- Gombok ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-sm { padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- Statisztika kártyák ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.stat-card.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.stat-icon { font-size: 26px; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------- Kártyalista / sorok ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  transition: background 0.12s ease;
}
.row:hover { background: var(--surface-2); }
.row-thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.row-thumb-fallback { font-size: 24px; }
.row-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title {
  font-weight: 650;
  font-size: 16px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.chip-icon { font-size: 13px; }
.row-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.row-chevron { color: var(--muted); font-size: 22px; padding-right: 4px; }

/* ---------- Pill / címke ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill.soft { background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.tag { font-size: 13px; color: var(--primary); background: var(--primary-soft); padding: 3px 9px; border-radius: 999px; }

/* ---------- Szűrők ---------- */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.filter-row { margin-bottom: 12px; }
.filter-search {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.filter-more { margin-top: 12px; }
.filter-more summary { cursor: pointer; color: var(--primary); font-size: 14px; font-weight: 600; padding: 4px 0; }
.filter-actions { margin-top: 12px; }

/* ---------- Mezők ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
textarea.field-input { resize: vertical; }
select.field-input { appearance: none; -webkit-appearance: none; }

.results-meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

/* ---------- Űrlap ---------- */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.form-section .section-title { margin-top: 0; }
.doc-form .field { margin-bottom: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 72px;
}
.hidden-file { display: none; }

/* ---------- Fotók ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.photo-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface-2);
}
.photo-add:hover { border-color: var(--primary); color: var(--primary); }
.photo-add-icon { font-size: 24px; }
.photo-add-text { font-size: 12px; text-align: center; }
.photo-input { display: none; }

/* ---------- Részletek ---------- */
.detail-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.detail-type-icon { font-size: 34px; }
.detail-title { font-size: 22px; margin: 0 0 8px; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.gallery-item {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--surface-2);
  aspect-ratio: 4 / 3;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-nophoto { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

/* Fájl (nem-kép) csatolmányok listája a részletnézetben */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.file-card:hover { background: var(--surface-2); }
.file-icon { font-size: 24px; }
.file-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-open { color: var(--primary); font-size: 14px; font-weight: 600; white-space: nowrap; }

/* Fájl csempe az űrlap csatolmány-rácsában */
.photo-thumb.file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: var(--surface-2);
  text-align: center;
}
.file-thumb-icon { font-size: 28px; }
.file-thumb-name {
  font-size: 11px;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Szekció-fejléc gombbal (pl. vezérlőpult „mind a naptárba”) */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-head .section-title { margin-bottom: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.detail-value { font-size: 16px; font-weight: 600; margin-top: 2px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.detail-notes {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.detail-notes p { margin: 6px 0 0; white-space: pre-wrap; }

/* ---------- Üres állapot ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-title { font-size: 18px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 14px; margin-bottom: 18px; max-width: 420px; margin-left: auto; margin-right: auto; }

/* ---------- Info / veszélyzóna kártyák ---------- */
.info-card, .card.danger-zone, .card { }
.page .card { padding: 18px; margin-bottom: 16px; }
.page .card h2 { margin: 0 0 8px; font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.app-footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }

/* ---------- Alsó navigáció (mobil) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: none;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--muted);
  font-size: 11px;
}
.bottom-nav .nav-link.active { color: var(--primary); }
.bn-icon { font-size: 20px; }
.nav-add .bn-icon {
  background: var(--primary);
  color: var(--primary-ink);
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

/* ---------- Modális ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 20, 32, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.modal-head { padding: 18px 18px 0; font-size: 18px; font-weight: 700; }
.modal-body { padding: 12px 18px; color: var(--muted); }
.modal-body p { margin: 0; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 18px; }

/* ---------- Világítódoboz ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 34px;
  cursor: pointer;
}

/* ---------- Reszponzív ---------- */
@media (max-width: 640px) {
  .top-nav { display: none; }
  .bottom-nav { display: flex; }
  .app-main { padding-bottom: 90px; }
  .page-head h1 { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { bottom: 80px; }
}
