:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1f2320;
  --muted: #7c7a73;
  --line: #e6e3dc;
  --brand: #cb9a4b;
  --brand-ink: #9c6f2c;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  font-family: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1 { font-size: 26px; margin: 0 0 20px; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; margin-top: 4px; }

.screen { min-height: 100vh; }

/* ---------- Login ---------- */
.login-screen { display: grid; place-items: center; }
.login-card {
  width: 340px; background: var(--panel); padding: 32px; border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
}
.brand { font-size: 22px; font-weight: 700; }
.brand-sm { font-weight: 700; }

/* ---------- Inputs / botões ---------- */
input[type="text"], input[type="password"] {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 22px; }

.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; font-size: 15px;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #efece5; }
.back { margin-bottom: 14px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.crumbs { color: var(--muted); font-size: 14px; }

/* ---------- Vista Ficheiros ---------- */
.files-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 10px; flex-wrap: wrap; }
.files-head .files-h { margin: 0; }
.files-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#files-status { margin: 0 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: #e6c9c4; }
.btn.danger:hover { background: #fbeae7; }
.files-h { margin: 24px 0 10px; }
.files-list { list-style: none; margin: 0 0 10px; padding: 0; }
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.file-name { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.file-size { color: var(--muted); font-size: 12px; }
.file-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
a.btn { text-decoration: none; display: inline-block; }

.container { max-width: 820px; margin: 0 auto; padding: 32px 24px 80px; }

/* ---------- Pré-preencher por IA ---------- */
.ai-fill { display: flex; align-items: center; gap: 14px; margin: 0 0 22px; flex-wrap: wrap; }
.ai-btn { cursor: pointer; background: #efeafe; border: 1px solid #d9cdf6; color: #5b3ca8; }
.ai-btn:hover { background: #e6ddfb; }

/* ---------- Cards de restaurante ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; cursor: pointer; transition: transform .08s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.card { text-align: center; }
.card-thumb {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px;
  margin-bottom: 14px; display: block; background: #efece5;
}
.card h3 { margin: 0; }
.card .meta { color: var(--muted); font-size: 13px; }

/* ---------- Dia / editor ---------- */
.day {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.day-title { font-weight: 700; font-size: 16px; }

/* Toggle Feriado */
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.toggle input { display: none; }
.toggle .track {
  width: 40px; height: 22px; background: #d8d4cc; border-radius: 999px; position: relative; transition: background .15s;
}
.toggle .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track::after { transform: translateX(18px); }

/* Editor rich-text */
.editor-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.tbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 10px;
  font-size: 14px; cursor: pointer; min-width: 34px; font-family: inherit;
}
.tbtn:hover { background: #f0ede6; }
.tbtn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tbtn.sep-btn { color: var(--brand-ink); font-weight: 600; }
.editor {
  min-height: 90px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  background: #fff; font-size: 15px; line-height: 1.4; outline: none;
  text-align: center; /* centrado por defeito */
}
.editor:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(203,154,75,.2); }
.editor:empty::before { content: attr(data-placeholder); color: #b7b2a8; }

/* Separador visual do QB dentro do editor */
.qb-sep {
  display: block; width: 90px; height: 6px; background: #cb9a4b;
  margin: 12px auto; border-radius: 1px;
}

.holiday-input { text-align: center; }

.photo-preview img { max-width: 220px; border-radius: 8px; border: 1px solid var(--line); margin-top: 10px; }

/* ---------- Ações / output ---------- */
.actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.gen-status { color: var(--muted); font-size: 14px; }
.output-list { margin-top: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.output-list ul { margin: 8px 0 0; padding-left: 18px; }
.output-list li { margin: 4px 0; font-size: 14px; }

/* ---------- Pré-visualização ---------- */
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 30px; }
.preview-head h3 { margin: 0; }
.preview-hint { margin: 6px 0 16px; font-size: 13px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.preview-item { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.preview-dl { position: relative; display: block; cursor: pointer; }
.preview-dl img { width: 100%; height: 230px; object-fit: contain; display: block; background: #efece5; }
.dl-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(31, 35, 32, 0.55); color: #fff; font-weight: 600; font-size: 14px;
  opacity: 0; transition: opacity .12s;
}
.preview-dl:hover .dl-hint { opacity: 1; }
.preview-item figcaption { padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.preview-item .fname { display: flex; align-items: center; gap: 6px; }
.badge { background: var(--brand); color: #fff; border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 700; }
.copy-url {
  align-self: flex-start; border: 1px solid var(--line); background: #fff; color: var(--brand-ink);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.copy-url:hover { background: #f0ede6; }

.spinner {
  display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }
