/* ============================================================
   VIBREEM ADMIN PANEL — stylesheet
============================================================ */
:root {
  --green: #157a44; --deep: #0c5530; --darkbg: #0b2e1c;
  --orange: #f7941e; --yellow: #ffc93c;
  --cream: #fdf9f1; --line: #e8e4d8;
  --ink: #1e2b23; --muted: #5f6f64;
  --grad-solar: linear-gradient(135deg, #f7941e, #ffc93c);
  --grad-green: linear-gradient(135deg, #157a44, #2aa35e);
  --radius: 14px;
  --shadow: 0 10px 34px rgba(30,43,35,.09);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Figtree', sans-serif; background: var(--cream); color: var(--ink); }
h1,h2,h3,h4 { font-family: 'Bricolage Grotesque', sans-serif; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ---- Shell ---- */
.adm-shell { display: flex; min-height: 100vh; }
.adm-sidebar {
  width: 250px; flex-shrink: 0;
  background: linear-gradient(180deg, #0c3822 0%, #071f13 100%);
  color: #cfe3d6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.adm-brand { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.adm-brand img { height: 44px; }
.adm-nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.adm-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  font-weight: 600; font-size: .93rem; color: #a9c3b3;
  transition: background .25s, color .25s;
}
.adm-nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.adm-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.adm-nav a.active { background: var(--grad-solar); color: var(--deep); }
.adm-side-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 9px; font-size: .85rem; }
.adm-db-badge { font-size: .7rem; font-weight: 700; letter-spacing: .06em; color: var(--yellow); }
.adm-view-site { color: #a9c3b3; font-weight: 600; }
.adm-view-site:hover { color: var(--yellow); }
.adm-logout {
  text-align: center; padding: 9px; border-radius: 9px;
  background: rgba(255,255,255,.08); color: #fff; font-weight: 700;
}
.adm-logout:hover { background: #c0392b; }

.adm-main { flex: 1; min-width: 0; }
.adm-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.adm-topbar h1 { font-size: 1.35rem; font-weight: 800; }
.adm-user { font-size: .88rem; font-weight: 600; color: var(--muted); }
.adm-content { padding: 30px 32px 60px; max-width: 1200px; }

/* ---- Cards / grid ---- */
.adm-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.adm-card h2 { font-size: 1.12rem; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.adm-grid { display: grid; gap: 20px; }
.adm-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.adm-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.adm-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Stats (dashboard) ---- */
.adm-stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.adm-stat .ic {
  width: 50px; height: 50px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--grad-solar); color: #fff;
}
.adm-stat .ic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.adm-stat b { display: block; font-size: 1.5rem; font-family: 'Bricolage Grotesque', sans-serif; }
.adm-stat span { color: var(--muted); font-size: .85rem; font-weight: 600; }

/* ---- Forms ---- */
label { display: block; font-weight: 700; font-size: .85rem; margin: 14px 0 6px; }
label small { font-weight: 500; color: var(--muted); }
input[type=text], input[type=url], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--cream); font-family: inherit; font-size: .95rem;
  outline: none; transition: border-color .25s, box-shadow .25s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(21,122,68,.13); background: #fff; }
textarea { resize: vertical; }
input[type=file] { font-size: .88rem; padding: 8px 0; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border: none; border-radius: 100px;
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: .92rem;
  transition: transform .25s, box-shadow .25s, opacity .25s;
}
.btn:hover { transform: translateY(-2px); }
.btn-green { background: var(--grad-green); color: #fff; box-shadow: 0 7px 18px rgba(21,122,68,.3); }
.btn-orange { background: var(--grad-solar); color: var(--deep); box-shadow: 0 7px 18px rgba(247,148,30,.3); }
.btn-ghost { background: #fff; color: var(--green); border: 2px solid var(--green); }
.btn-red { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0; }
.btn-sm { padding: 7px 15px; font-size: .8rem; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---- Flash + notices ---- */
.adm-flash {
  padding: 13px 18px; border-radius: 11px; margin-bottom: 20px;
  font-weight: 600; font-size: .92rem;
}
.adm-flash.ok { background: #e6f5eb; color: #14603a; border: 1px solid #bfe4cd; }
.adm-flash.err { background: #fdecea; color: #b03a2e; border: 1px solid #f5c6c0; }
.adm-note { font-size: .85rem; color: var(--muted); margin-top: 8px; }

/* ---- Tables / list rows ---- */
.adm-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(30,43,35,.05);
}
.adm-row img.thumb { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: #eee; }
.adm-row .grow { flex: 1; min-width: 0; }
.adm-row .grow b { display: block; font-size: .98rem; }
.adm-row .grow small { color: var(--muted); }
.adm-row .acts { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- Gallery admin grid ---- */
.adm-gal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.adm-gal-item { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.adm-gal-item img, .adm-gal-item video { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.adm-gal-item .doc { display: grid; place-items: center; aspect-ratio: 4/3; background: #e9f5ec; color: var(--green); font-weight: 800; font-size: .8rem; }
.adm-gal-item form { position: absolute; top: 6px; right: 6px; }
.adm-gal-item .del {
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(192,57,43,.92); color: #fff; font-weight: 700;
}
.adm-gal-item figcaption { padding: 7px 10px; font-size: .75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- AI generate zone ---- */
.ai-zone {
  border: 2px dashed rgba(21,122,68,.4); border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(21,122,68,.05), rgba(247,148,30,.07));
  padding: 22px; margin-bottom: 22px;
}
.ai-zone h3 { display: flex; align-items: center; gap: 9px; font-size: 1rem; margin-bottom: 8px; }
.ai-zone p { font-size: .87rem; color: var(--muted); margin-bottom: 14px; }
.ai-spin {
  display: none; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: aspin .8s linear infinite;
}
@keyframes aspin { to { transform: rotate(360deg); } }
.btn.loading .ai-spin { display: inline-block; }

/* ---- Login page ---- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(255,201,60,.15), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(21,122,68,.15), transparent 45%),
    linear-gradient(180deg, #0c3822, #071f13);
  padding: 20px;
}
.login-card {
  width: min(410px, 100%);
  background: #fff; border-radius: 20px; padding: 40px 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  text-align: center;
}
.login-card img { height: 52px; margin-bottom: 6px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-card > p { color: var(--muted); font-size: .88rem; margin-bottom: 18px; }
.login-card label { text-align: left; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 20px; }
.login-back { display: inline-block; margin-top: 16px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.login-back:hover { color: var(--green); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .adm-shell { flex-direction: column; }
  .adm-sidebar { width: 100%; height: auto; position: static; }
  .adm-nav { flex-direction: row; flex-wrap: wrap; }
  .adm-side-foot { flex-direction: row; align-items: center; justify-content: space-between; }
  .adm-content { padding: 20px 16px 50px; }
  .adm-grid.cols-2, .adm-grid.cols-3, .adm-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .adm-gal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .adm-grid.cols-2, .adm-grid.cols-3, .adm-grid.cols-4 { grid-template-columns: 1fr; }
  .adm-row { flex-wrap: wrap; }
}

/* ============================================================
   LETTERHEAD GENERATOR
============================================================ */
.lh-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: start; }
.lh-form-col { min-width: 0; }
.lh-preview-col { min-width: 0; position: sticky; top: 90px; }
.lh-preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.lh-preview-head span:first-child { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.05rem; }
.lh-preview-head small { color: var(--muted); font-weight: 500; }

.lh-preview-stage {
  background: #55606a;
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  max-height: calc(100vh - 140px);
}
.lh-scale { transform-origin: top left; width: 794px; }

/* Template selector */
.lh-tpl-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.lh-tpl-opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 16px 10px; border: 2px solid var(--line); border-radius: 12px;
  cursor: pointer; text-align: center; transition: border-color .2s, background .2s;
}
.lh-tpl-opt .lh-tpl-ic { font-size: 1.6rem; }
.lh-tpl-opt b { font-size: .92rem; }
.lh-tpl-opt small { color: var(--muted); font-size: .76rem; }
.lh-tpl-opt.sel { border-color: var(--green); background: #eef8f1; }

.lh-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- A4 PAPER ---------- */
.lh-paper {
  width: 794px;
  min-height: 1123px;
  background: #fff;
  color: #23302a;
  font-family: 'Figtree', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
  position: relative;
}

/* Header */
.lh-head {
  display: flex; align-items: center; gap: 22px;
  padding: 30px 46px 16px;
}
.lh-head-brand { flex-shrink: 0; }
.lh-logo { height: 66px; width: auto; display: block; }
.lh-head-info { flex: 1; text-align: right; }
.lh-co { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 24px; color: #157a44; letter-spacing: .02em; }
.lh-tag { font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: #f7941e; font-weight: 700; margin-top: 2px; }
.lh-contact { margin-top: 8px; font-size: 12.5px; color: #55625a; display: flex; flex-direction: column; gap: 1px; }
.lh-contact span { white-space: nowrap; }

/* Gold/green accent under header */
.lh-accent {
  height: 5px; margin: 6px 46px 0;
  background: linear-gradient(90deg, #157a44 0%, #157a44 55%, #ffc93c 55%, #f7941e 100%);
  border-radius: 3px;
}

/* Banner (template 2) */
.lh-banner { display: none; margin: 18px 46px 0; border-radius: 8px; overflow: hidden; position: relative; }
.lh-banner img { width: 100%; height: 150px; object-fit: cover; display: block; }
.lh-banner-fallback {
  display: none;
  height: 66px; align-items: center; justify-content: center;
  background: linear-gradient(120deg, #157a44, #2aa35e 70%, #f7941e);
  color: #fff; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
  letter-spacing: .18em; font-size: 15px;
}
.lh-paper.tpl-2 .lh-banner { display: block; }
/* when template 2 has no uploaded image, show the branded strip */
.lh-paper.tpl-2 .lh-banner img[src=""],
.lh-paper.tpl-2 .lh-banner img:not([src]) { display: none; }
.lh-paper.tpl-2 .lh-banner:not(:has(img[style*="block"])) .lh-banner-fallback { display: flex; }

/* Body */
.lh-body { flex: 1; padding: 26px 46px 20px; }
.lh-date { text-align: right; font-size: 14px; color: #40504a; margin-bottom: 20px; }
.lh-title {
  text-align: center; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
  font-size: 18px; text-transform: uppercase; letter-spacing: .04em;
  color: #157a44; margin: 0 0 18px; padding-bottom: 8px; border-bottom: 1px dashed #d9e6dd;
}
.lh-recipient { margin-bottom: 16px; }
.lh-recipient div { min-height: 2px; }
.lh-subject { margin: 14px 0 16px; font-size: 15px; }
.lh-greeting { margin-bottom: 12px; }
.lh-content { white-space: normal; text-align: justify; min-height: 120px; }
.lh-content p { margin: 0 0 12px; }
.lh-close { margin-top: 34px; }
.lh-sign-gap { height: 40px; }
.lh-sign-name { font-weight: 700; font-size: 15px; }
.lh-sign-desig { font-size: 13.5px; color: #55625a; }
.lh-sign-co { font-size: 13px; color: #157a44; font-weight: 700; margin-top: 2px; }

/* Footer */
.lh-foot { margin-top: auto; }
.lh-foot-note { text-align: center; font-size: 11.5px; font-style: italic; color: #7a867f; padding: 0 46px 8px; }
.lh-foot-strip {
  background: linear-gradient(90deg, #0c5530, #157a44);
  color: #eaf5ee; font-size: 12px; text-align: center;
  padding: 12px 30px;
  border-top: 4px solid #f7941e;
}

/* ---------- Print: only the letterhead, true A4 ---------- */
@media print {
  @page { size: A4; margin: 0; }
  body.lh-printing * { visibility: hidden !important; }
  body.lh-printing .lh-paper, body.lh-printing .lh-paper * { visibility: visible !important; }
  body.lh-printing .lh-scale { transform: none !important; height: auto !important; }
  body.lh-printing .lh-paper {
    position: absolute; left: 0; top: 0; margin: 0;
    box-shadow: none; width: 210mm; min-height: 297mm;
  }
}

@media (max-width: 1100px) {
  .lh-layout { grid-template-columns: 1fr; }
  .lh-preview-col { position: static; }
  .lh-preview-stage { max-height: none; }
}
