/* Dashboard UI (the posters themselves are styled in templates.css) */
:root {
  --primary: #3a21a3;
  --primary-2: #4f35c9;
  --primary-soft: #efebfc;
  --secondary: #525060;
  --ink: #1d1a2e;
  --muted: #6d6a7c;
  --line: #e4e1ee;
  --bg: #f6f5fb;
  --panel: #ffffff;
  --danger: #c2334d;
  --radius: 10px;
  font-family: 'Inter', 'Noto Sans Malayalam', system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: 220px minmax(340px, 420px) 1fr;
  height: 100vh;
}

/* ---------- Nav ---------- */
.nav {
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 24px;
}
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.nav-brand img { width: 34px; height: 37px; filter: brightness(0) invert(1); }
.nav-brand b { display: block; font-size: 17px; font-weight: 700; }
.nav-brand span { display: block; font-size: 12px; font-weight: 300; opacity: .8; }
.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 0; border-radius: 8px;
  background: transparent; color: rgba(255,255,255,.82);
  font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
}
.nav-link svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: #fff; color: var(--primary); font-weight: 600; }
.nav-foot { margin-top: auto; font-size: 12px; padding: 0 6px; line-height: 1.5; }

/* ---------- Editor ---------- */
.editor {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
.editor-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.editor-head h1 { margin: 0; font-size: 20px; font-weight: 700; color: var(--primary); }
.editor-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.doc-actions { display: flex; gap: 8px; }
.doc-actions[hidden] { display: none; }
.saved-select {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; background: #fff; font-size: 13px;
}

.form { overflow-y: auto; padding: 6px 20px 40px; flex: 1; }

.sec { border-bottom: 1px solid var(--line); padding: 16px 0; }
.sec:last-child { border-bottom: 0; }
.sec-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--secondary); margin: 0 0 12px;
}
.sec-hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; line-height: 1.45; }

.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 10px; }
.fld { grid-column: span 6; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld.w3 { grid-column: span 3; }
.fld.w2 { grid-column: span 2; }
.fld.w4 { grid-column: span 4; }
.fld label { font-size: 12px; font-weight: 600; color: var(--secondary); }
.fld .hint { font-size: 11.5px; color: var(--muted); }
.fld input[type=text], .fld input[type=number], .fld input[type=date], .fld input[type=password], .fld input[type=search], .fld select, .fld textarea {
  width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; background: #fff;
  outline: none;
}
.fld textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(79,53,201,.15);
}

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 6px;
  padding: 7px 6px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(29,26,46,.12); }

.seg.multi { flex-wrap: wrap; }
.seg.multi button { flex: 0 0 auto; padding: 7px 12px; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch {
  border: 2px solid transparent; border-radius: 10px; padding: 0; cursor: pointer;
  background: none; text-align: center; font-size: 12px; font-weight: 600; color: var(--secondary);
}
.swatch i { display: block; height: 46px; border-radius: 8px; margin-bottom: 5px; border: 1px solid var(--line); }
.swatch.on { color: var(--primary); }
.swatch.on i { outline: 2px solid var(--primary); outline-offset: 2px; }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--primary); }

.img-field { display: flex; gap: 10px; align-items: center; }
.img-thumb {
  width: 64px; height: 48px; border-radius: 6px; border: 1px dashed var(--line);
  background: var(--bg) center/cover no-repeat; flex: none;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.li { border: 1px solid var(--line); border-radius: var(--radius); background: #fcfbff; }
.li-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--line);
}
.li-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-body { padding: 10px 12px 12px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn.del:hover { background: #fbe9ec; color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

.btn {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary-2); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); color: #fff; }
.btn.add { width: 100%; border-style: dashed; color: var(--primary); background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: wait; }

/* ---------- Preview ---------- */
.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.preview-info { font-size: 13px; color: var(--muted); }
.preview-actions { display: flex; gap: 8px; }
.stage-wrap { flex: 1; overflow: auto; padding: 28px; min-height: 0; }
.stage { margin: 0 auto; display: flex; flex-direction: column; gap: 24px; align-items: center; }
.stage-item { position: relative; flex: none; box-shadow: 0 10px 40px rgba(29,26,46,.18); border-radius: 4px; overflow: hidden; }
.stage-item > .scaler { transform-origin: top left; position: absolute; top: 0; left: 0; }

/* Off-screen area used to measure pages and render exports at full size */
.offscreen { position: fixed; left: -20000px; top: 0; pointer-events: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Settings view has no preview */
.app.no-preview { grid-template-columns: 220px minmax(340px, 640px) 1fr; }
.app.no-preview .preview { visibility: hidden; }

@media (max-width: 1100px) {
  .app, .app.no-preview { grid-template-columns: 1fr; grid-template-rows: auto auto auto; height: auto; }
  .nav { flex-direction: row; align-items: center; padding: 10px 16px; gap: 16px; overflow-x: auto; }
  .nav-links { flex-direction: row; }
  .nav-link span { white-space: nowrap; }
  .editor { border-right: 0; }
  .form { overflow: visible; }
  .stage-wrap { padding: 16px; min-height: 70vh; }
  .app.no-preview .preview { display: none; }
}

/* ---------- Organisation: avatars, departments, org chart, directory ---------- */
.av { display: inline-block; flex: none; border-radius: 50%; background-size: cover; background-position: center; background-color: #ece8f8; }
.av.ini { display: inline-grid; place-items: center; background: linear-gradient(150deg, #6d4cf0, #3a21a3); color: #fff; font-weight: 700; }
.person { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.person > .av + span { display: flex; flex-direction: column; min-width: 0; }
.person small { color: var(--muted, #8a879a); font-size: 12px; }
.img-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.dept .desig { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chipbtn { border: 1px solid var(--line, #e4e1ee); background: var(--card, #fff); color: inherit; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chipbtn span { opacity: .6; margin-left: 4px; }
.chipbtn.on, .chipbtn:hover { border-color: #3a21a3; color: #3a21a3; }
.chipbtn.add { border-style: dashed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dept-people { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.dept-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line, #e4e1ee); padding-top: 10px; }
.oc-card { overflow-x: auto; }
.orgchart ul { display: flex; justify-content: center; padding-top: 20px; position: relative; margin: 0; padding-left: 0; list-style: none; }
.orgchart > ul { padding-top: 0; }
.orgchart li { position: relative; padding: 20px 8px 0; display: flex; flex-direction: column; align-items: center; }
.orgchart li::before, .orgchart li::after { content: ''; position: absolute; top: 0; width: 50%; height: 20px; border-top: 2px solid #cfc8ea; }
.orgchart li::before { right: 50%; } .orgchart li::after { left: 50%; border-left: 2px solid #cfc8ea; }
.orgchart li:only-child::before, .orgchart li:only-child::after { display: none; }
.orgchart li:only-child { padding-top: 0; }
.orgchart li:first-child::before, .orgchart li:last-child::after { border: 0 none; }
.orgchart li:last-child::before { border-right: 2px solid #cfc8ea; border-radius: 0 6px 0 0; }
.orgchart li:first-child::after { border-radius: 6px 0 0 0; }
.orgchart ul ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 20px; border-left: 2px solid #cfc8ea; }
.orgchart > ul > li { padding-top: 0; } .orgchart > ul > li::before, .orgchart > ul > li::after { display: none; }
.oc-node { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; min-width: 140px; max-width: 170px; text-align: center;
  background: var(--card, #fff); border: 1px solid var(--line, #e4e1ee); border-radius: 14px; box-shadow: 0 4px 14px rgba(30, 20, 80, .06); }
.oc-node small { color: var(--muted, #8a879a); font-size: 11.5px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card.dir { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.card.dir span { color: #3a21a3; font-weight: 600; font-size: 14px; }
.card.dir small { font-size: 12px; color: var(--muted, #8a879a); }
.card.dir .btn-row { margin-top: 8px; justify-content: center; flex-wrap: wrap; }
.card.profile { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.prof-main { display: flex; align-items: center; gap: 14px; }
.prof-main > div { display: flex; flex-direction: column; }
.prof-main span { color: #3a21a3; font-weight: 600; } .prof-main small { color: var(--muted, #8a879a); }
.idc-prev { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.idc-prev .stage-item { position: relative; overflow: hidden; border-radius: 12px; box-shadow: 0 6px 20px rgba(20, 10, 60, .18); }
.idc-prev .scaler { transform-origin: 0 0; position: absolute; top: 0; left: 0; }
@media (prefers-color-scheme: dark) { .av { background-color: #2c2848; } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Search everything + quick create ---------- */
.finder { position: relative; margin: 14px 4px 4px; }
.finder-row { display: flex; gap: 6px; }
.finder input { flex: 1; min-width: 0; border: 0; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13.5px; background: rgba(255, 255, 255, .14); color: #fff; outline: none; }
.finder input::placeholder { color: rgba(255, 255, 255, .7); }
.finder input:focus { background: #fff; color: #1d1a2e; }
.finder .btn.small.primary { background: #fff; color: var(--primary); border-color: #fff; white-space: nowrap; }
.finder-out { position: absolute; left: 0; width: 400px; top: calc(100% + 6px); z-index: 60; background: #fff; color: #1d1a2e; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(20, 10, 60, .28); padding: 6px; max-height: 70vh; overflow: auto; }
.finder-out p { padding: 10px; margin: 0; }
.fr { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font: inherit; cursor: pointer; color: inherit; }
.fr.on, .fr:hover { background: #f1eefb; }
.fr > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.fr b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr small { color: #8a879a; font-size: 12px; }
.fr-k { flex: none; width: 66px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.quick { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 16px 12px; font: inherit; font-weight: 600; font-size: 14px; color: var(--primary); cursor: pointer; text-align: left; }
.quick:hover { border-color: var(--primary); background: #f6f4fd; }
.area-team { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 6px 0 12px; padding: 10px 12px; background: #f6f4fd; border-radius: 10px; }
.area-net li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.area-net li .btn { margin-left: auto; }
@media (max-width: 1100px) { .finder { flex: none; width: 280px; margin: 0; } .finder-out { position: fixed; left: 16px; right: 16px; width: auto; top: 64px; } }

/* ---------- Mandatory fields ---------- */
.fld[data-req] > label::after { content: ' *'; color: var(--danger); font-weight: 700; }
.fld.invalid > label { color: var(--danger); }
.fld.invalid input, .fld.invalid select, .fld.invalid textarea, .fld.invalid .seg { border-color: var(--danger) !important; background: #fff6f7; box-shadow: 0 0 0 3px rgba(194, 51, 77, .12); }
.fld .err { font-size: 12px; font-weight: 600; color: var(--danger); }
/* Poster buttons wrap instead of running off the edge */
.preview-actions { flex-wrap: wrap; justify-content: flex-end; }
.preview-info { white-space: nowrap; flex: none; }

/* ---------- Menu: groups & favourites ---------- */
.nav-row { position: relative; }
.nav-row .nav-link { padding-right: 34px; }
.nav-pin { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: rgba(255,255,255,.55); font-size: 15px; cursor: pointer; opacity: 0; }
.nav-row:hover .nav-pin, .nav-pin:focus-visible, .nav-pin.on { opacity: 1; }
.nav-pin.on { color: #f2cf5b; }
.nav-row:has(.nav-link.active) .nav-pin { color: var(--primary); }
.nav-row:has(.nav-link.active) .nav-pin.on { color: #c9971c; }
.nav-label.nav-toggle { display: flex; }
.nav-toggle { width: 100%; text-align: left; align-items: center; justify-content: space-between; background: none; border: 0; cursor: pointer; padding: 8px 12px; margin: 6px 0 0 !important; border-radius: 6px; font-family: inherit; }
.nav-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-toggle i { font-style: normal; font-size: 14px; transition: transform .15s; }
.nav-group.open .nav-toggle i { transform: rotate(90deg); }
.nav-items { display: none; flex-direction: column; gap: 4px; }
.nav-group.open .nav-items { display: flex; }
.nav-label.fav { margin: 0 12px 4px; }
/* Home shortcuts */
.home-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.home-link { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--primary); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.home-link:hover { border-color: var(--primary-2); }
.home-link svg { width: 18px; height: 18px; fill: currentColor; }
/* More menu */
.more-menu { position: relative; }
.more-menu summary { list-style: none; display: inline-block; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; min-width: 190px; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(20,10,60,.16); }
.more-list .btn { width: 100%; text-align: left; border: 0; text-decoration: none; display: block; }
.more-list .btn:hover { background: var(--primary-soft); }
/* Pager, tabs, tips, back */
.dt tr[hidden] { display: none !important; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); }
.pager-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-btns .btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pane-tabs { margin-bottom: 14px; }
.q-tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; cursor: pointer; vertical-align: 1px; margin-left: 2px; }
.q-tip::before { content: '?'; }
.q-tip:hover { background: var(--primary); color: #fff; }
.modal-back { margin-right: 10px; flex: none; }
.modal-head h2 { flex: 1; min-width: 0; }
.rem-all { margin-top: 10px; }
