/* ============================================================
   Activate — Tiva Canvas panel (canvas-panel.js)
   Slides in on the right, between the main content and the chat
   drawer. Luxe styling: frosted card, --radius, soft shadows.
   ============================================================ */

.canvas-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 55vw);
  background: var(--bg-card, #ffffff);
  border-left: 1px solid var(--border, rgba(37, 51, 120, 0.09));
  box-shadow: var(--shadow-lg, 0 24px 48px -16px rgba(37, 51, 120, 0.20));
  z-index: 510; /* above the app header (500), whose content can overflow the
                   narrowed main column and would otherwise paint over the panel */
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.32s var(--ease-luxe, cubic-bezier(0.22, 1, 0.36, 1));
  overflow: hidden;
}
body.canvas-open .canvas-panel { transform: translateX(0); }
/* keep the chat drawer above the canvas so both can be open at once */
body.canvas-open .chat-panel { z-index: 520; }

/* Split view: the app main content shifts left so it is never overlapped. */
.main-content { transition: margin-right 0.32s var(--ease-luxe, cubic-bezier(0.22, 1, 0.36, 1)); }
body.canvas-open .main-content { margin-right: min(720px, 55vw); }

/* Below 1100px the canvas overlays instead of splitting. */
@media (max-width: 1100px) {
  body.canvas-open .main-content { margin-right: 0; }
  .canvas-panel { width: min(720px, 92vw); }
}

/* ---- header ---- */
.cv-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, rgba(37, 51, 120, 0.09));
  background: var(--bg-sidebar, rgba(250, 250, 254, 0.82));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex-shrink: 0;
}
.cv-kind {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent, #4180f2);
  background: var(--accent-soft, rgba(65, 128, 242, 0.09));
  border-radius: 8px;
  padding: 3px 8px;
  flex-shrink: 0;
}
.cv-title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #1e2749);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cv-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm, 9px);
  background: transparent;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: background 0.18s var(--ease-luxe, ease), color 0.18s var(--ease-luxe, ease);
}
.cv-btn:hover { background: var(--bg-hover, rgba(65, 128, 242, 0.05)); color: var(--text-primary, #1e2749); }
.cv-btn.active { color: var(--accent, #4180f2); background: var(--accent-soft, rgba(65, 128, 242, 0.09)); }
.cv-btn svg { width: 16px; height: 16px; }

/* ---- body / tile grid ---- */
.cv-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}
.cv-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cv-tile {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, rgba(37, 51, 120, 0.09));
  border-radius: var(--radius, 14px);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(23, 26, 63, 0.05));
  padding: 14px 16px;
  min-width: 0;
  overflow: hidden;
}
.cv-tile-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  margin-bottom: 8px;
}
.cv-tile-err {
  font-size: 11px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm, 9px);
  padding: 8px 10px;
}

/* kpi */
.cv-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary, #64748b);
}
.cv-kpi-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary, #1e2749);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.cv-kpi-delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 8px; }
.cv-kpi-delta.up { color: #0f9d6e; }
.cv-kpi-delta.down { color: #c1153a; }
.cv-kpi-delta.flat { color: var(--text-secondary, #64748b); }
.cv-kpi-hint { font-size: 11px; color: var(--text-secondary, #64748b); margin-top: 4px; }

/* chart */
.cv-chart-wrap { position: relative; height: 220px; }

/* table */
.cv-table-wrap { overflow-x: auto; }
.cv-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.cv-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary, #64748b);
  border-bottom: 2px solid #e3e7f1;
  padding: 6px 8px;
  white-space: nowrap;
}
.cv-table td {
  border-bottom: 1px solid #eef1f8;
  padding: 6px 8px;
  color: var(--text-primary, #1e2749);
  font-variant-numeric: tabular-nums;
}
.cv-table tr:last-child td { border-bottom: none; }

/* markdown + svg */
.cv-md { font-size: 13px; line-height: 1.55; color: var(--text-primary, #1e2749); }
.cv-md h1, .cv-md h2, .cv-md h3 { margin: 8px 0 6px; }
.cv-md table { border-collapse: collapse; width: 100%; font-size: 12px; }
.cv-md th, .cv-md td { border: 1px solid #e3e7f1; padding: 4px 7px; text-align: left; }
.cv-md pre { overflow-x: auto; background: var(--bg-input, #f6f7fc); border-radius: 8px; padding: 8px 10px; }
.cv-svg svg { max-width: 100%; height: auto; display: block; }

/* refresh badge on live tiles */
.cv-live {
  float: right;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #0f9d6e;
  background: #ecfdf5;
  border-radius: 8px;
  padding: 2px 6px;
}

/* ---- gallery drawer (inside the panel) ---- */
.cv-gallery {
  display: none;
  flex-shrink: 0;
  max-height: 45%;
  overflow-y: auto;
  border-bottom: 1px solid var(--border, rgba(37, 51, 120, 0.09));
  background: var(--bg-secondary, #f5f5fb);
  padding: 10px 14px;
}
.cv-gallery.open { display: block; }
.cv-gallery-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  margin: 2px 0 8px;
}
.cv-gal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, rgba(37, 51, 120, 0.09));
  border-radius: var(--radius-sm, 9px);
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.18s var(--ease-luxe, ease), box-shadow 0.18s var(--ease-luxe, ease);
}
.cv-gal-item:hover { border-color: var(--accent-light, #6ba1f7); box-shadow: var(--shadow-sm, 0 1px 2px rgba(23,26,63,.05)); }
.cv-gal-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #1e2749);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cv-gal-meta { font-size: 10px; color: var(--text-secondary, #64748b); flex-shrink: 0; }
.cv-gal-empty { font-size: 12px; color: var(--text-secondary, #64748b); padding: 8px 2px; }

/* chat chip that reopens a canvas */
.cv-chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--accent-light, #6ba1f7);
  background: var(--accent-soft, rgba(65, 128, 242, 0.09));
  color: var(--accent, #4180f2);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s var(--ease-luxe, ease);
}
.cv-chat-chip:hover { background: rgba(65, 128, 242, 0.16); }
