@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --terracotta: #C1633D;
  --terracotta-dark: #A34F2E;
  --jungle: #2F4A3C;
  --jungle-light: #3E634F;
  --cream: #FAF6F0;
  --ink: #24211E;
  --muted: #8A8378;
  --border: #E5DED2;
  --danger: #B3402E;
  --success: #3E634F;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
}

h1, h2, h3 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  color: var(--jungle);
  margin: 0 0 0.5rem;
}

a { color: var(--terracotta-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--jungle);
  padding: 0.9rem 1.5rem;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  color: #fff;
  letter-spacing: 0.02em;
}
.brand span { color: var(--terracotta); font-style: italic; }
.topbar nav a {
  color: #EFE9DE;
  margin-left: 1.2rem;
  font-size: 0.9rem;
}
.topbar nav a:hover { color: #fff; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.form-card { max-width: 520px; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--jungle);
  font-weight: 600;
  margin-bottom: 1rem;
}

input[type=text], input[type=url], input[type=password], input[type=file], select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
}

.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1.5rem;
  font-weight: 500;
}
.radio-inline input { width: auto; margin: 0; }

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}
fieldset legend {
  font-size: 0.85rem;
  color: var(--jungle);
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding: 0;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--terracotta); text-decoration: none; }
.btn-primary {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #fff;
}
.btn-primary:hover { background: var(--terracotta-dark); border-color: var(--terracotta-dark); }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.flash {
  padding: 0.7rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
}
.flash-success { background: #E4EEE6; color: var(--success); }
.flash-error { background: #F5E2DC; color: var(--danger); }

.filter-bar { margin-bottom: 1.5rem; }
.filter-bar select { max-width: 320px; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2.5rem;
}

.qr-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
}
.qr-thumb {
  width: 90px;
  height: 90px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
}
.qr-info h3 { font-size: 1.1rem; margin-bottom: 0.2rem; }
.building-tag {
  display: inline-block;
  background: #EFE4D8;
  color: var(--terracotta-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}
.clicks { color: var(--jungle-light); font-weight: 600; }

.section-title { margin-top: 1rem; }

.building-list { display: flex; flex-direction: column; gap: 0.6rem; }
.building-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.row-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; margin: 0; }

.login-wrap {
  display: flex;
  justify-content: center;
  padding-top: 4rem;
}
.login-card { width: 100%; max-width: 380px; text-align: left; }
.login-card h1 { text-align: center; }
.login-card p.muted { text-align: center; margin-bottom: 1.5rem; }

/* --- Scan history table --- */
.scan-table { width: 100%; border-collapse: collapse; margin-top: 1rem; background: #fff;
  border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.scan-table th, .scan-table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid #eee; }
.scan-table th { background: #f7f4ef; font-weight: 600; font-size: .85rem; }
.scan-table tr:last-child td { border-bottom: none; }
.scan-table tr.scan-skipped { opacity: .55; }
.flash-error-text { color: #b3402f; font-weight: 600; }

/* --- Destination badges on the dashboard --- */
.badge {
  display: inline-block;
  padding: .12rem .45rem;
  border-radius: 4px;
  background: #EFEAE1;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  vertical-align: middle;
}
.badge-content { background: var(--jungle); color: #fff; }

.backup-note { margin-top: 1.5rem; max-width: 46rem; }

/* --- Rich text editor (admin only) --- */
.field-label { display: block; font-weight: 600; margin-bottom: .4rem; }

#editor-shell { margin-bottom: .6rem; }
#editor-shell .ql-toolbar {
  border-color: var(--border);
  border-radius: 8px 8px 0 0;
  background: #fff;
}
#editor-shell .ql-container {
  border-color: var(--border);
  border-radius: 0 0 8px 8px;
  background: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
}
#editor-shell .ql-editor {
  min-height: 22rem;
  line-height: 1.6;
}
#editor-shell .ql-editor h2,
#editor-shell .ql-editor h3 { font-family: 'Cormorant Garamond', serif; }
#editor-shell .ql-editor.ql-blank::before { color: var(--muted); font-style: normal; }

/* Plain-textarea fallback when the editor CDN is unreachable. */
textarea.content-fallback {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9rem;
  line-height: 1.5;
  padding: .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  resize: vertical;
}

.target-hint { margin: -.3rem 0 .9rem; max-width: 46rem; }

.source-toggle { margin: .5rem 0 0; }

/* --- Editor height ---------------------------------------------------
   A reglamento runs to ~13,000 words. Left to grow with its content, the
   editor pushed the Guardar button thousands of pixels down the page. It
   now scrolls inside a fixed frame, with the toolbar directly above it. */
#editor-shell .ql-container {
  height: 60vh;
  min-height: 18rem;
  overflow-y: auto;
}
#editor-shell .ql-editor { min-height: 0; }
textarea.content-fallback { height: 60vh; }

/* Save and cancel stay reachable instead of living below the document. */
.form-card .row-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: .9rem 0 .3rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}
