/* ==========================================================================
   Woodrock Connect — design system
   Hand-authored (no build step). Tokens first, then base, layout, components.
   Brand colours are CSS variables so an organisation's settings can override
   them inline (see layouts/app.blade.php) without touching this file.
   ========================================================================== */

:root {
  /* Brand (overridable per-organisation) */
  --brand:        #0f7d6b;   /* warm teal-green */
  --brand-ink:    #0a5a4d;
  --brand-soft:   #e6f4f1;
  --accent:       #e89a3c;   /* warm amber */
  --accent-soft:  #fdf1e0;

  /* Neutrals — warm-tinted for a friendly, trustworthy feel */
  --bg:           #faf8f4;
  --surface:      #ffffff;
  --surface-2:    #f4f1ea;
  --border:       #e7e2d8;
  --ink:          #22262b;
  --ink-soft:     #5c636c;
  --ink-faint:    #8b929b;

  /* Semantic */
  --ok:      #1f9d61;
  --ok-soft: #e5f6ec;
  --warn:    #c9820f;
  --warn-soft:#fbf1dc;
  --danger:  #d4483b;
  --danger-soft:#fce8e6;
  --info:    #2f6fb0;

  /* Shape & depth */
  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(24,28,33,.06), 0 1px 3px rgba(24,28,33,.04);
  --shadow:    0 4px 12px rgba(24,28,33,.07), 0 2px 4px rgba(24,28,33,.04);
  --shadow-lg: 0 18px 40px rgba(24,28,33,.14);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.22; font-weight: 680; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
small { color: var(--ink-soft); }

/* ---------- App shell ---------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #10312c 0%, #0b241f 100%);
  color: #dfeae7;
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand__logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--brand); display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 18px; box-shadow: var(--shadow-sm);
}
.brand__name { font-weight: 720; color: #fff; font-size: 1.02rem; letter-spacing: -.01em; }
.brand__tag { font-size: .72rem; color: #8fb3ac; margin-top: 1px; }

.nav__section { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: #6f8f89; margin: 16px 10px 6px; font-weight: 700; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px; color: #cadbd7;
  font-weight: 550; font-size: .92rem; transition: background .12s, color .12s;
}
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav__item.is-active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav__icon { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav__spacer { flex: 1; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: rgba(255,255,255,.86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 650; font-size: 1.02rem; }
.content { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------- Page header -------------------------------------------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header__title { font-size: 1.55rem; }
.page-header__sub { color: var(--ink-soft); margin: 2px 0 0; }

/* ---------- Cards -------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px 22px;
}
.card--pad-lg { padding: 28px; }
.card__title { font-size: .95rem; font-weight: 650; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- Stat card ---------------------------------------------------- */
.stat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); }
.stat--accent::before { background: var(--accent); }
.stat--ok::before { background: var(--ok); }
.stat--danger::before { background: var(--danger); }
.stat__label { color: var(--ink-soft); font-size: .82rem; font-weight: 560; }
.stat__value { font-size: 1.9rem; font-weight: 740; letter-spacing: -.02em; margin-top: 3px; }
.stat__hint { font-size: .78rem; color: var(--ink-faint); margin-top: 2px; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  transition: transform .04s, background .12s, box-shadow .12s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-ink); text-decoration: none; }
.btn--accent { background: var(--accent); color: #3a2408; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 11px; font-size: .82rem; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Badges ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem;
  font-weight: 640; padding: 3px 9px; border-radius: 999px; }
.badge--ok { background: var(--ok-soft); color: #12683f; }
.badge--warn { background: var(--warn-soft); color: #8a5a06; }
.badge--danger { background: var(--danger-soft); color: #9c2a20; }
.badge--muted { background: var(--surface-2); color: var(--ink-soft); }
.badge--brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge--accent { background: var(--accent-soft); color: #92590f; }

/* ---------- Tables ------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 620; color: var(--ink-soft);
  font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfaf7; }
.table a { font-weight: 600; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-ink); display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; }

/* ---------- Forms -------------------------------------------------------- */
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; font: inherit; font-size: .92rem; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field-error { color: var(--danger); font-size: .8rem; margin-top: 5px; }
.field-hint { color: var(--ink-faint); font-size: .8rem; margin-top: 5px; }
.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

/* ---------- Alerts / flash ---------------------------------------------- */
.alert { border-radius: var(--radius-sm); padding: 12px 16px; font-size: .9rem; margin-bottom: 18px;
  border: 1px solid transparent; }
.alert--ok { background: var(--ok-soft); border-color: #bfe6cd; color: #14663f; }
.alert--warn { background: var(--warn-soft); border-color: #ecd6a4; color: #7d5406; }
.alert--danger { background: var(--danger-soft); border-color: #f2c3bd; color: #93271d; }

/* ---------- Empty states ------------------------------------------------- */
.empty { text-align: center; padding: 54px 24px; color: var(--ink-soft); }
.empty__art { width: 68px; height: 68px; border-radius: 20px; margin: 0 auto 16px;
  background: var(--brand-soft); display: grid; place-items: center; color: var(--brand); }
.empty h3 { color: var(--ink); }

/* ---------- Auth / public ------------------------------------------------ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 500px at 100% -10%, rgba(15,125,107,.10), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(232,154,60,.10), transparent),
    var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 34px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card .brand__name { color: var(--ink); }
.public-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.public-card { width: 100%; max-width: 520px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px; text-align: center; }

/* ---------- Utility ------------------------------------------------------ */
.muted { color: var(--ink-soft); }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-0{margin-bottom:0}.mb-2{margin-bottom:16px}
.stack > * + * { margin-top: 14px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display:flex; gap:10px; align-items:flex-start; padding:8px 0; border-bottom:1px solid var(--border); }
.checklist li:last-child{border-bottom:0;}
.dot { width:9px;height:9px;border-radius:50%;flex:none;margin-top:6px;background:var(--ink-faint); }
.dot--ok{background:var(--ok)} .dot--warn{background:var(--warn)} .dot--todo{background:var(--ink-faint)}

/* ---------- Template gallery --------------------------------------------- */
.tpl-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.tpl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.tpl-card.is-archived { opacity: .62; }
.tpl-card__name { font-weight: 680; font-size: 1.02rem; }
.tpl-card__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tpl-card__desc { color: var(--ink-soft); font-size: .88rem; margin: 0; flex: 1; }
.tpl-card__foot { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; }

.tpl-pick { display: block; cursor: pointer; background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 18px; transition: border-color .12s, box-shadow .12s; }
.tpl-pick:hover { border-color: var(--brand); }
.tpl-pick:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl-pick.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl-pick__art { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-size: 1.2rem; margin-bottom: 12px; }
.tpl-pick__name { font-weight: 680; }
.tpl-pick__desc { color: var(--ink-soft); font-size: .85rem; margin: 6px 0 0; }

/* ---------- Email builder ------------------------------------------------- */
.builder { display: grid; grid-template-columns: 220px 1fr 300px; gap: 16px; align-items: start; }
.builder__panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; position: sticky; top: 16px;
  max-height: calc(100vh - 120px); overflow-y: auto; }
.builder__panel-title { font-size: .74rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 10px; }

.bd-pal-group { margin-bottom: 14px; }
.bd-pal-group__label { font-size: .74rem; font-weight: 650; color: var(--ink-faint); margin-bottom: 5px; }
.bd-pal-item, .bd-tag { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 4px; font: inherit; font-size: .85rem; color: var(--ink); cursor: pointer; }
.bd-pal-item:hover, .bd-tag:hover { border-color: var(--brand); background: var(--brand-soft); }
.bd-pal-item__icon { width: 20px; text-align: center; color: var(--brand); font-weight: 700; }

.builder__canvas { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; }
.builder__toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.builder__toolbar .btn.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.bd-blocks { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
/* An author `display` rule beats the UA stylesheet, so [hidden] needs restating. */
.bd-blocks[hidden] { display: none; }
.bd-block { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.bd-block:hover { border-color: var(--brand); }
.bd-block.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.bd-block__bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: 8px 8px 0 0; }
.bd-block__icon { color: var(--brand); font-weight: 700; width: 18px; text-align: center; }
.bd-block__label { font-size: .82rem; font-weight: 650; flex: 1; }
.bd-block__actions { display: flex; gap: 2px; }
.bd-block__actions button { background: none; border: 0; cursor: pointer; color: var(--ink-soft);
  font-size: .9rem; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.bd-block__actions button:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand-ink); }
.bd-block__actions button:disabled { opacity: .3; cursor: default; }
.bd-block__body { padding: 10px 12px; font-size: .86rem; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-empty { padding: 54px 20px; text-align: center; color: var(--ink-soft); }

.bd-preview { padding: 14px; background: var(--surface-2); }
.bd-preview iframe { display: block; width: 100%; height: 70vh; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; margin: 0 auto; transition: max-width .18s; }
.bd-preview.is-mobile iframe { max-width: 380px; }

.bd-insp-head { font-weight: 680; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.bd-align { display: flex; gap: 4px; }
.bd-align button { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 4px; font: inherit; font-size: .78rem; cursor: pointer; color: var(--ink-soft); text-transform: capitalize; }
.bd-align button.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.bd-switch { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; }
.bd-rep-row { display: flex; gap: 5px; margin-bottom: 5px; }
.bd-rep-row .input { font-size: .82rem; padding: 7px 9px; }
.bd-rep-row button { background: none; border: 0; cursor: pointer; color: var(--ink-faint); padding: 0 4px; }
.bd-rep-row button:hover { color: var(--danger); }
.bd-media-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bd-media-field img { width: 60px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.bd-media-field__none { width: 60px; height: 46px; border-radius: 8px; border: 1px dashed var(--border);
  display: grid; place-items: center; font-size: .66rem; color: var(--ink-faint); text-align: center; }

.bd-issues { display: flex; flex-direction: column; gap: 8px; }
.bd-issue { border-radius: var(--radius-sm); padding: 9px 11px; font-size: .8rem; border: 1px solid transparent; margin: 0; }
.bd-issue strong { display: block; margin-bottom: 3px; }
.bd-issue span { color: inherit; opacity: .85; }
.bd-issue--error { background: var(--danger-soft); border-color: #f2c3bd; color: #93271d; }
.bd-issue--warn { background: var(--warn-soft); border-color: #ecd6a4; color: #7d5406; }
.bd-issue--ok { background: var(--ok-soft); border-color: #bfe6cd; color: #14663f; }

.bd-modal { position: fixed; inset: 0; z-index: 100; background: rgba(24,28,33,.5);
  display: grid; place-items: center; padding: 24px; }
.bd-modal[hidden] { display: none; }
.bd-modal__box { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 22px; width: 100%; max-width: 720px; max-height: 82vh; overflow-y: auto; }
.bd-media-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.bd-media-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px; cursor: pointer; font: inherit; font-size: .74rem; color: var(--ink-soft); text-align: center; }
.bd-media-item:hover { border-color: var(--brand); }
.bd-media-item img { width: 100%; height: 82px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 5px; }
.bd-media-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Media library ------------------------------------------------- */
.media-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); }
.media-card__art { height: 140px; background: var(--surface-2); display: grid; place-items: center; }
.media-card__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card__body { padding: 12px; display: flex; flex-direction: column; gap: 3px; font-size: .85rem; }

/* ---------- Responsive --------------------------------------------------- */
@media (max-width: 1200px) {
  .builder { grid-template-columns: 190px 1fr; }
  .builder__inspector { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: var(--sidebar-w); transform: translateX(-100%);
    transition: transform .2s; }
  .sidebar.is-open { transform: none; }
  .content { padding: 18px; }
  .form-row { grid-template-columns: 1fr; }
  .builder { grid-template-columns: 1fr; }
  .builder__panel { position: static; max-height: none; }
}
