/* ===========================================================
   Mapa de Referências
   Direção visual: caderno de especificação de materiais —
   fundo carvão quente, rótulos serifados como um ateliê de
   arquitetura escreveria à mão numa prancheta, acento em
   latão referenciando ferragens/metais do próprio briefing.
   =========================================================== */

:root {
  --bg: #1E1C19;
  --panel: #262218;
  --panel-2: #2C2820;
  --line: #423B30;
  --text: #EDE6D8;
  --text-dim: #A89C88;
  --brass: #C79A3E;
  --brass-soft: #8C6F30;
  --danger: #B5573F;

  --serif: "Fraunces", "Iowan Old Style", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
}

/* ---------- header ---------- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

#project-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.4rem;
  margin: 0;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ---------- layout ---------- */

#app-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 48px 24px 120px;
}

.screen[hidden] { display: none; }

.intro-block h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
  max-width: 34ch;
  line-height: 1.35;
  margin: 0 0 28px;
  color: var(--text);
}

.new-project-form {
  display: flex;
  gap: 10px;
  max-width: 480px;
}

#error-screen h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.3rem;
  color: var(--text-dim);
  max-width: 36ch;
}

/* ---------- form controls ---------- */

input[type="text"] {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 0.95rem;
}

input[type="text"]:focus,
input[type="color"]:focus,
button:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

input[type="text"]::placeholder { color: var(--text-dim); }

button {
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid transparent;
  padding: 11px 18px;
}

.btn-solid {
  background: var(--brass);
  color: #211B0F;
  font-weight: 600;
  border: 1px solid var(--brass);
}
.btn-solid:hover { background: #D6AC55; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: var(--brass-soft); }

/* ---------- categories ---------- */

#categories-list {
  display: flex;
  flex-direction: column;
}

.category {
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}
.category:first-child { padding-top: 0; }

.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.category-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0;
  color: var(--text);
}

.category-pass-badge {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--brass);
  border: 1px solid var(--brass-soft);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.category-pass-badge-default {
  color: var(--text-dim);
  border-color: var(--line);
}

.category-header .btn-add-pair {
  margin-left: auto;
}

.pairs-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ---------- pair card ---------- */

.pair {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px;
}

.pair-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; border-radius: 50%; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }

.pair-catalog {
  flex: 1;
  min-width: 0;
  position: relative;
}

.pair-catalog-search-wrap {
  position: relative;
}

.pair-catalog-search {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  padding: 4px 2px;
  font-size: 0.85rem;
  font-family: var(--sans);
}
.pair-catalog-search:focus { outline: none; border-color: var(--brass); }
.pair-catalog-search::placeholder { color: var(--text-dim); }

.pair-catalog-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.pair-catalog-results:empty { display: none; }

.pair-catalog-result {
  background: none;
  border: none;
  border-radius: 0;
  text-align: left;
  color: var(--text);
  font-size: 0.82rem;
  padding: 8px 10px;
}
.pair-catalog-result:hover { background: var(--panel); }
.pair-catalog-result-create {
  color: var(--brass);
  border-top: 1px solid var(--line);
}

.pair-catalog-linked {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.pair-catalog-thumb {
  width: 26px;
  height: 26px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--panel-2);
  flex-shrink: 0;
}
.pair-catalog-thumb[hidden] { display: none; }
.pair-catalog-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}
.pair-catalog-change {
  padding: 4px 10px;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.pair-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
}
.pair-delete:hover { color: var(--danger); }

.dropzone {
  border: 1px dashed var(--line);
  border-radius: 3px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.drag-over {
  border-color: var(--brass);
  background: var(--panel-2);
}

.dropzone-hint {
  margin: 6px 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.dropzone:has(.thumbs:not(:empty)) .dropzone-hint { display: none; }

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--panel-2);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- status ---------- */

#status-message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 3px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
#status-message.visible { opacity: 1; }

/* ---------- admin: quadros + catálogo ---------- */

.admin-section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.2rem;
  margin: 0 0 16px;
  color: var(--text);
}
.admin-section-title-catalog {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.new-project-link {
  font-family: var(--sans);
  font-size: 0.85rem;
  word-break: break-all;
  color: var(--text);
}

#new-project-result.catalog-entry {
  margin: 16px 0 40px;
}
#new-project-result[hidden] {
  display: none;
}

.admin-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  max-width: 50ch;
  margin: 0 0 20px;
}

.catalog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.catalog-filters select,
.catalog-filters input[type="text"] {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 0.85rem;
}
.catalog-filters .btn-solid {
  margin-left: auto;
}

#catalog-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.catalog-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.catalog-entry-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.catalog-entry-main {
  flex: 1;
  min-width: 0;
}
.catalog-entry-name {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--text);
}
.catalog-entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.catalog-entry-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.catalog-entry-thumbs {
  display: flex;
  gap: 4px;
}
.catalog-entry-thumbs img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 3px;
}
.catalog-entry-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
}
.catalog-entry-delete:hover { color: var(--danger); }

.catalog-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.catalog-form[hidden] {
  display: none;
}
.catalog-form h3 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0;
  color: var(--text);
}
.catalog-form-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.catalog-form-row input[type="text"] {
  flex: 1;
}
.catalog-form select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.catalog-form-actions {
  display: flex;
  gap: 10px;
}

/* ---------- home (tela sem link de projeto) ---------- */
/* Layout próprio, fora do fluxo de #app-main — cobre a tela inteira e
   esconde o cabeçalho padrão do site (ver app.js). */

@keyframes cnFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.home-screen {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  background: #1A1917;
  color: #EDE6D8;
  font-family: "Urbanist", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  text-transform: lowercase;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

.home-bg-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 45%, rgba(199, 154, 62, 0.055), rgba(26, 25, 23, 0) 65%);
  pointer-events: none;
}

.home-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 34px;
}

.home-eyebrow {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #8E8478;
  font-weight: 400;
}

.home-login-btn {
  font-family: inherit;
  text-transform: lowercase;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: #EDE6D8;
  background: transparent;
  border: 1px solid #423B30;
  border-radius: 2px;
  padding: 11px 22px;
  opacity: 0.45;
  cursor: not-allowed;
}

.home-main {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 34px 90px;
}

.home-logo {
  display: block;
  width: 320px;
  max-width: 70vw;
  height: auto;
  opacity: 0.96;
  animation: cnFade 0.7s ease both;
}

.home-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 34px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #A89C88;
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .new-project-form { flex-direction: column; }
  .pairs-row { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .catalog-filters .btn-solid { margin-left: 0; }
}
