/* IzzahTech ERP - Blog, AI, agent console and the dark theme for the ERP.
   Loaded after erp-theme.css. */
#erpView {
  --erp-grid: #ece6d8;
  --erp-label: var(--text-light);
  --erp-dot: #fff;
  --erp-gold: #C9A227;
  --erp-ink: #0f172a;
  --erp-track: #e8e2d4;
  --erp-card: #fff;
  --erp-card-2: #fbfaf6;
  --erp-line: var(--border-color);
}

/* ---------------------------------------------------------------- nav shell */
#erpView .erp-nav-search {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 0 10px; border-radius: 9px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .09);
}
#erpView .erp-nav-search svg { opacity: .55; flex-shrink: 0; }
#erpView .erp-nav-search input {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  color: #e2e8f0; font-family: inherit; font-size: .74rem; padding: 8px 0;
}
#erpView .erp-nav-search input::placeholder { color: #5b6b85; }
#erpView .erp-nav-group { display: block; }
#erpView .erp-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 7px 12px; border: none; background: transparent;
  font-family: inherit; font-size: .57rem; font-weight: 800;
  letter-spacing: 1.7px; text-transform: uppercase; color: #5b6b85;
  cursor: pointer; transition: color .16s ease;
}
#erpView .erp-group-head:hover { color: #d8b64a; }
#erpView .erp-group-head svg { transition: transform .22s cubic-bezier(.22, 1, .36, 1); opacity: .7; }
#erpView .erp-nav-group.open .erp-group-head svg { transform: rotate(180deg); }
#erpView .erp-group-body {
  display: none; flex-direction: column; gap: 3px; padding-bottom: 4px;
}
#erpView .erp-nav-group.open .erp-group-body { display: flex; }
#erpView .erp-group-count {
  margin-left: auto; font-size: .55rem; letter-spacing: 0; color: #6b7c96;
  background: rgba(255, 255, 255, .06); border-radius: 999px; padding: 1px 6px;
}

/* ------------------------------------------------------------------- blog */
.blog-layout { display: grid; grid-template-columns: 274px minmax(0, 1fr); gap: 14px; align-items: start; }
.blog-side {
  background: var(--erp-card); border: 1px solid var(--erp-line);
  border-radius: 13px; padding: 12px; position: sticky; top: 0;
}
.blog-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.blog-side-head strong { font-size: .8rem; font-weight: 800; }
.blog-side-head span { font-size: .68rem; color: var(--text-muted); background: #f4f0e6; border-radius: 999px; padding: 2px 8px; }
.blog-list { display: flex; flex-direction: column; gap: 4px; max-height: 56vh; overflow-y: auto; }
.blog-list-item {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; font-family: inherit; cursor: pointer; transition: .15s;
}
.blog-list-item:hover { background: #faf7ef; border-color: var(--erp-line); }
.blog-list-item.active { background: rgba(201, 162, 39, .1); border-color: rgba(201, 162, 39, .4); }
.blog-list-title { font-size: .78rem; font-weight: 700; color: var(--text-main); line-height: 1.35; }
.blog-list-meta { font-size: .64rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.blog-state { font-style: normal; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; font-size: .56rem; }
.blog-state.live { color: #047857; }
.blog-state.draft { color: #b45309; }
.blog-side-foot { margin-top: 10px; display: flex; gap: 8px; }
.blog-editor { min-width: 0; }
.blog-editor-empty {
  background: var(--erp-card); border: 1px dashed var(--erp-line); border-radius: 13px;
  padding: 40px 26px; text-align: center;
}
.blog-editor-empty h3 { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.blog-editor-empty p { font-size: .8rem; color: var(--text-muted); max-width: 460px; margin: 0 auto 14px; line-height: 1.6; }
.blog-ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 296px; gap: 14px; align-items: start; }
.blog-ed-main, .blog-ed-side {
  background: var(--erp-card); border: 1px solid var(--erp-line);
  border-radius: 13px; padding: 15px 16px;
}
.blog-ed-side { position: sticky; top: 0; }
.blog-ed-side h4 { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-muted); margin-bottom: 9px; }
.blog-ed-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.blog-ed-body {
  min-height: 300px; max-height: 58vh; overflow-y: auto;
  border: 1px solid var(--erp-line); border-radius: 10px; padding: 14px 16px;
  background: var(--erp-card-2); font-size: .88rem; line-height: 1.68; color: var(--text-main);
}
.blog-ed-body:focus { outline: 2px solid rgba(201, 162, 39, .35); outline-offset: 1px; }
.blog-ed-body h2 { font-size: 1.1rem; margin: 16px 0 7px; font-weight: 800; }
.blog-ed-body h3 { font-size: .96rem; margin: 13px 0 6px; font-weight: 800; }
.blog-ed-body p { margin: 0 0 10px; }
.blog-ed-body img { max-width: 100%; border-radius: 9px; }
.blog-ed-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .8rem; }
.blog-ed-body th, .blog-ed-body td { border: 1px solid var(--erp-line); padding: 7px 9px; text-align: left; }
.blog-ed-html {
  width: 100%; min-height: 300px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem; line-height: 1.6; border: 1px solid var(--erp-line);
  border-radius: 10px; padding: 12px; background: var(--erp-card-2); color: var(--text-main);
}
.blog-ed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.blog-ed-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .7rem; color: var(--text-muted); }
.badge-ai { background: rgba(139, 92, 246, .12); color: #6d28d9; border-radius: 999px; padding: 2px 8px; font-weight: 800; font-size: .6rem; }
.inline-row { display: flex; gap: 7px; }
.inline-row input { flex: 1; }
.serp {
  display: flex; flex-direction: column; gap: 3px; padding: 10px 11px;
  border: 1px solid var(--erp-line); border-radius: 10px; background: var(--erp-card-2); margin-bottom: 12px;
}
.serp span { font-size: .64rem; color: #0a7c42; }
.serp strong { font-size: .82rem; color: #1a0dab; font-weight: 600; line-height: 1.3; }
.serp em { font-size: .7rem; color: #4b5563; font-style: normal; line-height: 1.45; }
.cover-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.cover-row img { width: 56px; height: 34px; object-fit: cover; border-radius: 7px; border: 1px solid var(--erp-line); }
.cover-row input { flex: 1; font-size: .7rem; }
.mini-label { display: block; font-size: .62rem; color: var(--text-muted); margin: 8px 0 3px; }
.counter { float: right; font-size: .62rem; color: var(--text-light); font-weight: 600; }
.blog-modal {
  position: fixed; inset: 0; z-index: 90; background: rgba(8, 14, 26, .72);
  display: flex; align-items: center; justify-content: center; padding: 26px;
}
.blog-modal[hidden] { display: none; }
.blog-modal-box {
  background: #fff; border-radius: 14px; width: min(940px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.blog-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--erp-line); }
.blog-modal-head strong { font-size: .9rem; font-weight: 800; }
.blog-x { border: none; background: #f4f0e6; border-radius: 7px; padding: 6px 11px; font-family: inherit; font-size: .72rem; font-weight: 700; cursor: pointer; }
.blog-modal-body { padding: 14px 16px; overflow-y: auto; }
.blog-preview-frame { width: 100%; height: 66vh; border: 1px solid var(--erp-line); border-radius: 10px; background: #fff; }
.blog-suggest-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 9px; }
.blog-suggest {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 11px 12px;
  border: 1px solid var(--erp-line); border-radius: 11px; background: var(--erp-card-2);
  font-family: inherit; cursor: pointer; transition: .15s;
}
.blog-suggest:hover { border-color: #C9A227; background: rgba(201, 162, 39, .08); }
.blog-suggest strong { font-size: .82rem; color: var(--text-main); line-height: 1.35; }
.blog-suggest span { font-size: .64rem; color: #8a6800; font-weight: 700; }
.blog-suggest em { font-size: .68rem; color: var(--text-muted); font-style: normal; }
.modal-sub { font-size: .74rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin: 16px 0 6px; }
.blog-trends { margin: 0; padding-left: 18px; font-size: .74rem; color: var(--text-main); line-height: 1.7; }

/* --------------------------------------------------------- AI + integrations */
.erp-box {
  background: var(--erp-card); border: 1px solid var(--erp-line);
  border-radius: 13px; padding: 15px 17px; margin-bottom: 13px;
}
.erp-box h3 { font-size: .92rem; font-weight: 800; margin-bottom: 4px; }
.erp-hint { font-size: .74rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }
.ai-agent-row { border: 1px solid var(--erp-line); border-radius: 11px; padding: 12px; margin-bottom: 10px; background: var(--erp-card-2); }
.ai-agent-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.ai-agent-head strong { font-size: .82rem; font-weight: 800; }
.ai-agent-tag { font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; background: #f1ecdd; color: #6b5a1c; border-radius: 999px; padding: 2px 8px; }
.ai-agent-ok { font-size: .62rem; font-weight: 800; color: #047857; }
.ai-agent-warn { font-size: .62rem; font-weight: 800; color: #b45309; }
.ai-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .74rem; font-weight: 700; color: var(--text-muted); }
.ai-toggle input { width: 15px; height: 15px; accent-color: #C9A227; }

/* ------------------------------------------------------------ agent console */
.agent-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .85fr); gap: 14px; align-items: start; }
.agent-main { background: var(--erp-card); border: 1px solid var(--erp-line); border-radius: 13px; padding: 14px 15px; }
.agent-chat {
  display: flex; flex-direction: column; gap: 8px; min-height: 320px; max-height: 52vh;
  overflow-y: auto; padding: 10px; border-radius: 11px; background: var(--erp-card-2);
  border: 1px solid var(--erp-line); margin-bottom: 10px;
}
.agent-msg { font-size: .79rem; line-height: 1.55; padding: 8px 11px; border-radius: 10px; max-width: 88%; white-space: pre-wrap; word-break: break-word; }
.agent-msg.user { background: #0f172a; color: #f1f5f9; align-self: flex-end; }
.agent-msg.assistant { background: var(--erp-card); border: 1px solid var(--erp-line); color: var(--text-main); }
.agent-msg img { display: block; max-width: 100%; border-radius: 9px; margin-bottom: 6px; border: 1px solid var(--erp-line); }
.agent-input-row { display: flex; gap: 8px; align-items: flex-end; }
.agent-input-row textarea { flex: 1; resize: vertical; }
.agent-quick { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.agent-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.agent-preview, .agent-pending, .agent-deploys {
  background: var(--erp-card); border: 1px solid var(--erp-line); border-radius: 13px; padding: 12px 13px;
}
.agent-preview-head, .agent-side-head, .agent-deploy-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.agent-preview-head strong, .agent-side-head strong, .agent-deploy-head strong { font-size: .78rem; font-weight: 800; }
.agent-preview-head input {
  flex: 1; min-width: 120px; font-size: .7rem; padding: 6px 9px;
  border: 1px solid var(--erp-line); border-radius: 8px; background: var(--erp-card-2); font-family: inherit;
}
.agent-frame-wrap { position: relative; border: 1px solid var(--erp-line); border-radius: 10px; overflow: hidden; background: #fff; }
.agent-frame-wrap iframe { width: 100%; height: 320px; border: none; display: block; }
.agent-pick-hint {
  position: absolute; inset: auto 0 0 0; background: rgba(201, 162, 39, .92); color: #241a02;
  font-size: .68rem; font-weight: 800; text-align: center; padding: 5px;
}
.agent-pick-hint[hidden] { display: none; }
.agent-shot-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.agent-pick { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .66rem; color: #8a6800; word-break: break-all; }
.agent-change-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.agent-change {
  display: flex; align-items: center; justify-content: space-between; gap: 9px;
  padding: 8px 10px; border: 1px solid var(--erp-line); border-radius: 9px; background: var(--erp-card-2);
}
.agent-change strong { display: block; font-size: .74rem; font-weight: 800; }
.agent-change span { font-size: .66rem; color: var(--text-muted); }
.agent-deploy-list { display: flex; flex-direction: column; gap: 7px; }
.agent-deploy {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 9px 11px; border: 1px solid var(--erp-line); border-radius: 10px; background: var(--erp-card-2);
}
.agent-deploy strong { display: block; font-size: .76rem; font-weight: 800; }
.agent-deploy span { display: block; font-size: .66rem; color: var(--text-muted); }
.agent-deploy em { font-style: normal; font-size: .62rem; color: #8a6800; }
.agent-deploy-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.agent-deploys { margin-top: 13px; }

/* ----------------------------------------------------------- ERP dark theme */
html[data-theme="dark"] #erpView {
  background: #0b1220;
  --erp-grid: #24314b;
  --erp-label: #8b9bb4;
  --erp-dot: #0f172a;
  --erp-ink: #dbe4f0;
  --erp-track: #1b2740;
  --erp-card: #121c30;
  --erp-card-2: #0f1727;
}
html[data-theme="dark"] #erpView .erp-kpi,
html[data-theme="dark"] #erpView .erp-card,
html[data-theme="dark"] #erpView .erp-box,
html[data-theme="dark"] #erpView .erp-alert,
html[data-theme="dark"] #erpView .erp-range-wrap,
html[data-theme="dark"] #erpView .erp-seg,
html[data-theme="dark"] #erpView .blog-side,
html[data-theme="dark"] #erpView .blog-ed-main,
html[data-theme="dark"] #erpView .blog-ed-side,
html[data-theme="dark"] #erpView .blog-ed-body,
html[data-theme="dark"] #erpView .blog-ed-html,
html[data-theme="dark"] #erpView .serp,
html[data-theme="dark"] #erpView .ai-agent-row,
html[data-theme="dark"] #erpView .agent-main,
html[data-theme="dark"] #erpView .agent-preview,
html[data-theme="dark"] #erpView .agent-pending,
html[data-theme="dark"] #erpView .agent-deploys,
html[data-theme="dark"] #erpView .agent-change,
html[data-theme="dark"] #erpView .agent-deploy,
html[data-theme="dark"] #erpView .agent-msg.assistant,
html[data-theme="dark"] #erpView .blog-suggest {
  background: var(--erp-card);
  border-color: #22304a;
  color: #e6ecf6;
}
html[data-theme="dark"] #erpView .erp-kpi-tag,
html[data-theme="dark"] #erpView .erp-kpi-sub,
html[data-theme="dark"] #erpView .erp-kpi-foot,
html[data-theme="dark"] #erpView .erp-card-head p,
html[data-theme="dark"] #erpView .blog-list-meta,
html[data-theme="dark"] #erpView .blog-side-head span,
html[data-theme="dark"] #erpView .erp-hint,
html[data-theme="dark"] #erpView .agent-change span,
html[data-theme="dark"] #erpView .agent-deploy span,
html[data-theme="dark"] #erpView .erp-page-head p,
html[data-theme="dark"] #erpView .erp-empty span { color: #93a3bd; }
html[data-theme="dark"] #erpView .erp-kpi-label,
html[data-theme="dark"] #erpView .erp-card-head h3,
html[data-theme="dark"] #erpView .erp-page-head h2,
html[data-theme="dark"] #erpView .blog-list-title,
html[data-theme="dark"] #erpView .erp-box h3 { color: #f1f5f9; }
html[data-theme="dark"] #erpView .erp-kpi-value { color: #f8fafc; }
html[data-theme="dark"] #erpView .erp-seg button { color: #93a3bd; }
html[data-theme="dark"] #erpView .erp-seg button.active { background: #C9A227; color: #0f172a; }
html[data-theme="dark"] #erpView .erp-range-wrap select { background: #16223a; color: #e2e8f0; }
html[data-theme="dark"] #erpView input[type="text"],
html[data-theme="dark"] #erpView input[type="password"],
html[data-theme="dark"] #erpView input[type="email"],
html[data-theme="dark"] #erpView input[type="number"],
html[data-theme="dark"] #erpView input[type="file"],
html[data-theme="dark"] #erpView select,
html[data-theme="dark"] #erpView textarea {
  background: #0f1727; border-color: #22304a; color: #e6ecf6;
}
html[data-theme="dark"] #erpView .erp-nav-search { background: rgba(255, 255, 255, .04); }
html[data-theme="dark"] #erpView .agent-msg.user { background: #1d2a44; color: #e8eef8; }
html[data-theme="dark"] #erpView .blog-list-item:hover,
html[data-theme="dark"] #erpView .blog-list-item.active { background: rgba(201, 162, 39, .14); }
html[data-theme="dark"] #erpView .blog-modal-box { background: #0f1727; }
html[data-theme="dark"] #erpView .blog-x { background: #1d2a44; color: #e2e8f0; }
html[data-theme="dark"] #erpView .erp-tab-content .data-table th { background: #16223a; color: #cbd5e1; }
html[data-theme="dark"] #erpView .erp-tab-content .data-table td { border-color: #22304a; color: #dbe4f0; }
html[data-theme="dark"] #erpView .erp-tab-content .data-table tbody tr:hover { background: rgba(255, 255, 255, .03); }
html[data-theme="dark"] #erpView .erp-empty strong { color: #cbd5e1; }

/* ------------------------------------------------------- responsive tweaks */
@media (max-width: 1180px) {
  .blog-layout { grid-template-columns: 1fr; }
  .blog-side { position: static; }
  .blog-list { max-height: 240px; }
  .blog-ed-grid { grid-template-columns: 1fr; }
  .blog-ed-side { position: static; }
  .agent-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  #erpView .erp-nav-search { display: none; }
  #erpView .erp-nav-group { display: contents; }
  #erpView .erp-group-head { display: none; }
  #erpView .erp-group-body { display: contents; }
  #erpView .erp-nav-group .erp-tab-btn { display: flex; }
}
@media (max-width: 720px) {
  .blog-ed-actions .erp-btn { flex: 1 1 auto; }
  .agent-frame-wrap iframe { height: 240px; }
}

/* ---------- sub-nav chips inside an ERP tab ---------- */
.erp-subnav{
  display:flex;gap:8px;flex-wrap:wrap;margin:0 0 16px;
  padding:6px;border-radius:14px;
  background:var(--erp-card, #fff);border:1px solid var(--erp-grid, #e2e8f0);
}
.erp-subnav-chip{
  border:0;background:transparent;color:var(--erp-label, #64748b);
  border-radius:10px;padding:8px 14px;font-size:.78rem;font-weight:700;cursor:pointer;
  transition:background .2s ease, color .2s ease;
}
.erp-subnav-chip:hover{color:var(--erp-ink, #0f172a);background:rgba(201,162,39,.12)}
.erp-subnav-chip.active{background:linear-gradient(180deg,#d9b23a,#b8912a);color:#241d05}
html[data-theme="dark"] .erp-subnav{background:var(--erp-card, #121c30);border-color:var(--erp-grid, #24314b)}
html[data-theme="dark"] .erp-subnav-chip{color:var(--erp-label, #8b9bb4)}
html[data-theme="dark"] .erp-subnav-chip:hover{color:var(--erp-ink, #dbe4f0)}
@media (max-width: 720px) {
  .erp-subnav{overflow-x:auto;flex-wrap:nowrap;scrollbar-width:thin}
  .erp-subnav-chip{flex:0 0 auto;white-space:nowrap}
}

/* ---------- ERP buttons in dark mode ---------- */
html[data-theme="dark"] #erpView .erp-btn{
  background: var(--erp-card, #121c30);
  border-color: var(--erp-grid, #24314b);
  color: var(--erp-ink, #dbe4f0);
}
html[data-theme="dark"] #erpView .erp-btn:hover{ background: var(--erp-card-2, #0f1727); border-color: #33405c; }
html[data-theme="dark"] #erpView .erp-btn-primary{
  background: linear-gradient(180deg, #d9b23a, #b8912a);
  border-color: transparent; color: #241d05;
}
html[data-theme="dark"] #erpView .erp-btn-ghost{ background: transparent; color: var(--erp-label, #8b9bb4); }
html[data-theme="dark"] #erpView .erp-btn-ghost:hover{ background: rgba(255,255,255,.05); color: var(--erp-ink, #dbe4f0); }
html[data-theme="dark"] #erpView .erp-btn-danger{
  background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.38); color: #fca5a5;
}
html[data-theme="dark"] #erpView .erp-btn-danger:hover{ background: rgba(239,68,68,.22); }

/* ---------- AI layer checks ---------- */
.ai-diag{
  margin:14px 0;
  border:1px solid var(--erp-grid,#dfe5ee);
  border-radius:12px;
  overflow:hidden;
  background:var(--erp-card,#fff);
}
.ai-diag[hidden]{display:none}
.ai-diag-row{
  display:flex;gap:10px;align-items:flex-start;
  padding:9px 12px;border-bottom:1px solid var(--erp-grid,#e9edf4);
  font-size:.86rem;color:var(--erp-ink,#1f2937);
}
.ai-diag-row:last-child{border-bottom:0}
.ai-diag-row b{
  flex:0 0 42px;text-align:center;border-radius:6px;
  font-size:.68rem;letter-spacing:.06em;text-transform:uppercase;padding:3px 0;
}
.ai-diag-row.ok b{background:rgba(16,185,129,.16);color:#0f766e}
.ai-diag-row.fail b{background:rgba(239,68,68,.16);color:#b91c1c}
.ai-diag-row.fail{background:rgba(239,68,68,.06)}
html[data-theme="dark"] .ai-diag-row.ok b{color:#34d399}
html[data-theme="dark"] .ai-diag-row.fail b{color:#fca5a5}
