/* NZ Study Trip — design tokens: navy/blue professional palette, Lexend + Source Sans 3 */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --color-primary: #1E3A5F;
  --color-primary-hover: #15293f;
  --color-secondary: #2563EB;
  --color-accent: #059669;
  --color-warning: #D97706;
  --color-destructive: #DC2626;
  --color-background: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-foreground: #0F172A;
  --color-muted: #F1F3F5;
  --color-muted-foreground: #64748B;
  --color-border: #E4E7EB;
  --color-ring: #1E3A5F;

  --font-heading: 'Lexend', system-ui, sans-serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 8px 20px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);

  --transition-fast: 160ms ease;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-foreground);
  background: var(--color-background);
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--space-3);
  color: var(--color-foreground);
}

h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

p { margin: 0 0 var(--space-3); }

a {
  color: var(--color-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: inherit;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

img { max-width: 100%; display: block; }

/* ---------- Layout ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-7);
}

.page-narrow {
  max-width: 420px;
  margin: var(--space-7) auto;
  padding: 0 var(--space-4);
}

@media (max-width: 768px) {
  .page { padding: var(--space-5) var(--space-3) var(--space-6); }
}

/* ---------- Top nav ---------- */

.top-nav {
  background: var(--color-primary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  color: #fff;
}
.brand:hover { color: #fff; text-decoration: none; opacity: 0.9; }

.top-nav-links { display: flex; gap: var(--space-4); }
.top-nav-links a {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  font-size: 14px;
}
.top-nav-links a:hover { color: #fff; }

.nav-spacer { flex: 1; }

.nav-user {
  color: #fff;
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}
.nav-user:hover { color: #fff; text-decoration: underline; }

.inline-form { display: inline; }

@media (max-width: 640px) {
  .top-nav-links { display: none; }
}

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}

.btn-primary { background: var(--color-secondary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary { background: #fff; color: var(--color-foreground); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-muted); }

.top-nav .btn-secondary { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.35); }
.top-nav .btn-secondary:hover { background: rgba(255,255,255,0.22); }

.btn-ghost { background: transparent; color: var(--color-muted-foreground); border-color: transparent; }
.btn-ghost:hover { background: var(--color-muted); color: var(--color-foreground); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger { background: #fff; color: var(--color-destructive); border-color: #fecaca; min-height: 36px; padding: 0 var(--space-3); }
.btn-danger:hover { background: #fef2f2; }

.btn-group { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--color-muted);
  color: var(--color-muted-foreground);
  white-space: nowrap;
}
.badge-done { background: #dcfce7; color: #065f46; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-empty { background: #f1f5f9; color: #475569; }

/* ---------- Filter bar ---------- */

.filter-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-card);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.filter-row-secondary {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

@media (max-width: 1024px) {
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-row-secondary { grid-template-columns: 1fr 1fr; }
  .field-grow { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .filter-grid { grid-template-columns: 1fr; }
  .filter-row-secondary { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted-foreground);
}

.field input,
.field select,
.field textarea {
  font-weight: 400;
  font-size: 15px;
  color: var(--color-foreground);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 40px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field textarea { min-height: unset; resize: vertical; font-family: inherit; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-range { display: flex; align-items: center; gap: var(--space-2); }
.field-range input { width: 100%; }
.field-range-sep { color: var(--color-muted-foreground); }

.search-row {
  position: relative;
  margin-top: var(--space-4);
  display: flex;
  align-items: center;
}
.filter-row-secondary .search-row { margin-top: 0; align-self: end; }

.field-full {
  margin-top: var(--space-4);
}
.field-full input, .field-full select { width: 100%; }

.search-icon { position: absolute; left: var(--space-3); color: var(--color-muted-foreground); pointer-events: none; }
.search-input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-6) 0 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: #fff;
}
.search-input:focus { outline: none; border-color: var(--color-secondary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.search-clear {
  position: absolute;
  right: var(--space-2);
  color: var(--color-muted-foreground);
  padding: var(--space-1);
  border-radius: 999px;
  line-height: 1;
}
.search-clear:hover { color: var(--color-foreground); background: var(--color-muted); text-decoration: none; }

.filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-foreground);
  cursor: pointer;
}
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--color-accent); cursor: pointer; }
.checkbox-field-small { font-size: 13px; font-weight: 400; color: var(--color-muted-foreground); white-space: nowrap; }

.filter-footer-actions { display: flex; align-items: center; gap: var(--space-3); }
.filter-count { font-size: 13px; color: var(--color-muted-foreground); }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}
.tab {
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-muted-foreground);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--color-foreground); text-decoration: none; }
.tab.is-active { color: var(--color-secondary); border-bottom-color: var(--color-secondary); }

.results-count { color: var(--color-muted-foreground); font-size: 14px; margin-bottom: var(--space-3); }

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-muted-foreground);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}
@media (max-width: 1024px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .card-grid { grid-template-columns: 1fr; } }

.card {
  position: relative;
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  color: var(--color-foreground);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}
.card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}
.card-link-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.card-header h3 { margin: 0; font-size: 16px; flex: 1; }

.card-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 4px);
  padding: 4px;
}

.card-meta {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--color-muted-foreground);
  margin-bottom: var(--space-2);
}

.card-view-link {
  position: relative;
  z-index: 2;
  display: inline-block;
  margin-top: var(--space-2);
  font-size: 13px;
  font-weight: 600;
}

.card-row-levels {
  margin-bottom: var(--space-2);
}
.card-levels {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-foreground);
  background: var(--color-surface-muted, #f1f5f9);
  border-radius: var(--radius-sm, 4px);
  padding: 2px 8px;
}

.card-facts {
  list-style: none;
  margin: 0 0 var(--space-2);
  padding: 0;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-facts li { line-height: 1.3; }

.card-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: var(--space-2);
}

.card-website {
  position: relative;
  z-index: 2;
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
}

.card-map-link {
  position: relative;
  z-index: 2;
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted-foreground);
}
.card-map-link:hover {
  color: var(--color-foreground);
}

/* ---------- Detail page ---------- */

.back-link { display: inline-block; margin-bottom: var(--space-4); font-size: 14px; font-weight: 600; }

.detail-header { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.detail-header h1 { margin: 0; }
.detail-logo {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 4px);
  padding: 6px;
}

.detail-general {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}
.detail-general dt { font-weight: 600; color: var(--color-muted-foreground); font-size: 13px; padding-top: 2px; }
.detail-general dd { margin: 0; }

@media (max-width: 640px) {
  .detail-general { grid-template-columns: 1fr; }
  .detail-general dt { padding-top: var(--space-2); }
}

.detail-section { margin-bottom: var(--space-6); }
.detail-section h2 {
  font-size: 17px;
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-3);
}

.muted { color: #94a3b8; }
.unverified {
  background: #fff7ed;
  color: #9a3412;
  padding: 1px 6px;
  border-radius: 4px;
}

.admin-link { margin-top: var(--space-6); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: var(--space-3); text-align: left; vertical-align: top; border-bottom: 1px solid var(--color-border); }
th {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-muted-foreground);
  background: var(--color-muted);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.admin-table td { min-width: 160px; }

.ua-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagination { margin-top: var(--space-4); }
.admin-table input, .admin-table textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-size: 14px;
  background: #fff;
}
.admin-table input:focus, .admin-table textarea:focus {
  outline: none; border-color: var(--color-secondary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ---------- Admin forms ---------- */

.admin-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-card);
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.admin-section-header h2 { margin: 0; }

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.field-wide { grid-column: 1 / -1; }

@media (max-width: 768px) {
  .admin-form-grid { grid-template-columns: 1fr; }
}

.save-ok { color: var(--color-accent); font-weight: 600; font-size: 14px; }
.error { color: var(--color-destructive); font-weight: 500; }

/* ---------- Login ---------- */

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}
.login-form input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  font-size: 15px;
}
.login-form input:focus { outline: none; border-color: var(--color-secondary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* ---------- Map ---------- */

.map-wrap { position: relative; }
.map-wrap .leaflet-container { border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

.map-pin span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.map-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-3);
  font-size: 13px;
  color: var(--color-muted-foreground);
}
.map-legend span { display: inline-flex; align-items: center; gap: var(--space-2); }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--color-primary);
  color: rgba(255, 255, 255, 0.85);
  margin-top: auto;
}

.site-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  padding: var(--space-5) var(--space-4);
}

.site-footer-brand { display: flex; flex-direction: column; gap: var(--space-1); }
.site-footer .brand { font-size: 16px; }
.site-footer-tagline { margin: 0; font-size: 13px; color: rgba(255, 255, 255, 0.65); }

.site-footer-links {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 500;
}
.site-footer-links a { color: rgba(255, 255, 255, 0.85); }
.site-footer-links a:hover { color: #fff; }

.site-footer-copy {
  margin: 0 0 0 auto;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .site-footer-inner { flex-direction: column; align-items: flex-start; }
  .site-footer-copy { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
