/* pub/views/style/dashboards.css
 * Dashboard workbench styles. Self-contained theme variables that default to
 * dark and re-tone under the existing body.light-mode toggle used by chat.
 */

:root {
  --d-bg: #0f172a;
  --d-panel: #111827;
  --d-panel-2: #0b1220;
  --d-text: #e5e7eb;
  --d-muted: #9ca3af;
  --d-border: #1f2937;
  --d-accent: #22d3ee;
  --d-accent-strong: #06b6d4;
  --d-danger: #ef4444;
  --d-success: #22c55e;
  --d-shadow: rgba(0, 0, 0, 0.3);
  --d-radius: 10px;
  --d-header-h: 52px;
}

body.light-mode {
  --d-bg: #f8fafc;
  --d-panel: #ffffff;
  --d-panel-2: #f1f5f9;
  --d-text: #0f172a;
  --d-muted: #475569;
  --d-border: #e2e8f0;
  --d-accent: #2563eb;
  --d-accent-strong: #1d4ed8;
  --d-danger: #dc2626;
  --d-success: #16a34a;
  --d-shadow: rgba(0, 0, 0, 0.08);
}

body { background: var(--d-bg); color: var(--d-text); }

.hidden { display: none !important; }

/* ---- Header ---- */
.dash-header {
  height: var(--d-header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--d-panel);
  border-bottom: 1px solid var(--d-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.dash-header-left, .dash-header-right { display: flex; align-items: center; gap: 10px; }
.dash-back {
  color: var(--d-muted);
  text-decoration: none;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.dash-back:hover { background: var(--d-panel-2); color: var(--d-text); }
.dash-brand { font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }
.dash-session-pill {
  font-size: 12px; color: var(--d-muted);
  background: var(--d-panel-2);
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--d-border);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-icon-btn {
  background: transparent; color: var(--d-muted);
  border: 1px solid var(--d-border);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.dash-icon-btn:hover { color: var(--d-text); background: var(--d-panel-2); }

/* ---- Shell layout ---- */
.dash-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - var(--d-header-h));
}
.dash-sidebar {
  background: var(--d-panel);
  border-right: 1px solid var(--d-border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.dash-main {
  min-width: 0;
  display: flex; flex-direction: column;
  min-height: 0;
}

/* ---- Sidebar ---- */
.dash-sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--d-border);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--d-muted);
}
.dash-search { padding: 10px 12px; border-bottom: 1px solid var(--d-border); }
.dash-search input {
  width: 100%; box-sizing: border-box;
  background: var(--d-panel-2); color: var(--d-text);
  border: 1px solid var(--d-border); border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.dash-search input:focus { outline: none; border-color: var(--d-accent); }
.dash-list {
  list-style: none; margin: 0; padding: 6px;
  overflow-y: auto; flex: 1; min-height: 0;
}
.dash-list-item {
  padding: 9px 11px; border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  margin-bottom: 2px;
}
.dash-list-item:hover { background: var(--d-panel-2); }
.dash-list-item.active { background: var(--d-panel-2); box-shadow: inset 2px 0 0 var(--d-accent); }
.dash-list-item .dli-name { font-size: 13.5px; font-weight: 500; }
.dash-list-item .dli-meta { font-size: 11px; color: var(--d-muted); }
.dash-list-item.active .dli-name { color: var(--d-accent); }
.dash-list-placeholder { padding: 12px; color: var(--d-muted); font-size: 13px; }

/* ---- Empty state ---- */
.dash-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--d-muted); text-align: center; padding: 40px;
}
.dash-empty-icon { font-size: 40px; color: var(--d-accent); opacity: 0.7; }
.dash-empty h2 { margin: 4px 0 0; color: var(--d-text); font-weight: 600; }
.dash-empty p { margin: 0; font-size: 14px; max-width: 420px; }

/* ---- Editor bar ---- */
.dash-editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dash-editor-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--d-border);
  background: var(--d-panel); flex-wrap: wrap;
}
.dash-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.dash-title-input {
  background: transparent; border: 1px solid transparent;
  color: var(--d-text); font-size: 17px; font-weight: 600;
  padding: 6px 8px; border-radius: 8px; min-width: 0; flex: 1;
}
.dash-title-input:focus { outline: none; border-color: var(--d-accent); background: var(--d-panel-2); }
.dash-rev { font-size: 11px; color: var(--d-muted); font-family: monospace; white-space: nowrap; }
.dash-editor-actions { display: flex; align-items: center; gap: 8px; }

.dash-btn {
  background: var(--d-panel-2); color: var(--d-text);
  border: 1px solid var(--d-border); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.dash-btn:hover { border-color: var(--d-accent); }
.dash-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dash-btn-primary { background: var(--d-accent-strong); color: #fff; border-color: var(--d-accent-strong); }
.dash-btn-primary:hover { background: var(--d-accent); border-color: var(--d-accent); }
.dash-btn-ghost { background: transparent; }
.dash-btn-danger { color: var(--d-danger); }
.dash-btn-danger:hover { border-color: var(--d-danger); background: rgba(239, 68, 68, 0.08); }

/* ---- Widget add form ---- */
.widget-form {
  margin: 12px 16px 0;
  background: var(--d-panel);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  padding: 14px;
  box-shadow: 0 6px 18px var(--d-shadow);
}
.widget-form-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.widget-form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px;
}
.widget-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--d-muted); }
.widget-field input, .widget-field select {
  background: var(--d-panel-2); color: var(--d-text);
  border: 1px solid var(--d-border); border-radius: 8px; padding: 7px 9px; font-size: 13px;
}
.widget-field input:focus, .widget-field select:focus { outline: none; border-color: var(--d-accent); }
.widget-form-actions { display: flex; align-items: flex-end; }

/* ---- Canvas + widgets ---- */
.dash-canvas {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 78px;
  gap: 14px;
  align-content: start;
}
.dash-widget-empty {
  grid-column: 1 / -1;
  color: var(--d-muted); text-align: center; padding: 48px 16px; font-size: 14px;
  border: 1px dashed var(--d-border); border-radius: var(--d-radius);
}
.dashboard-widget {
  background: var(--d-panel);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--d-shadow);
}
.widget-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--d-border);
}
.widget-title { font-size: 13px; font-weight: 600; color: var(--d-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-remove {
  background: transparent; border: none; color: var(--d-muted);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px;
}
.widget-remove:hover { color: var(--d-danger); background: rgba(239, 68, 68, 0.08); }
.widget-body { flex: 1; min-height: 0; position: relative; padding: 6px; }
.widget-status, .widget-placeholder {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--d-muted); font-size: 13px; text-align: center; padding: 12px;
}
.widget-chart { width: 100%; height: 100%; min-height: 120px; }

/* ---- Widget table ---- */
.widget-table-wrap { height: 100%; overflow: auto; }
.widget-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.widget-table th, .widget-table td {
  padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--d-border);
  white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis;
}
.widget-table th { color: var(--d-muted); font-weight: 600; position: sticky; top: 0; background: var(--d-panel); }
.widget-table-more { padding: 6px 8px; font-size: 11px; color: var(--d-muted); }

/* ---- Toast ---- */
.dash-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--d-panel); color: var(--d-text);
  border: 1px solid var(--d-border); border-left: 3px solid var(--d-accent);
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px var(--d-shadow); z-index: 50;
  max-width: 90vw;
}
.dash-toast.error { border-left-color: var(--d-danger); }
.dash-toast.success { border-left-color: var(--d-success); }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .dash-shell { grid-template-columns: 1fr; height: auto; }
  .dash-sidebar { max-height: 240px; border-right: none; border-bottom: 1px solid var(--d-border); }
  .dash-canvas { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 520px) {
  .dash-canvas { grid-template-columns: 1fr; }
  .dashboard-widget { grid-column: span 1 !important; }
  .dash-editor-bar { flex-direction: column; align-items: stretch; }
}
