/* ============================================================================
 * Conimo Canonical Application Shell & UI Kit Stylesheet (conimo-shell.css)
 * Guarantees full-bleed 100vw x 100dvh desktop/web studio layouts, semantic
 * light/dark CSS tokens (--cm-*), unclipped bottom bars, and crisp UI controls.
 * ============================================================================ */

:root,
[data-theme="light"] {
  --cm-bg: #f8fafc;
  --cm-surface: #ffffff;
  --cm-surface-2: #f1f5f9;
  --cm-border: #e2e8f0;
  --cm-border-strong: #cbd5e1;
  --cm-text: #0f172a;
  --cm-muted: #64748b;
  --cm-accent: #2563eb;
  --cm-accent-hover: #1d4ed8;
  --cm-accent-soft: rgba(37, 99, 235, 0.10);
  --cm-danger: #dc2626;
  --cm-danger-soft: rgba(220, 38, 38, 0.10);
  --cm-success: #16a34a;
  --cm-success-soft: rgba(22, 163, 74, 0.10);
  --cm-warning: #d97706;
  --cm-warning-soft: rgba(217, 119, 6, 0.12);
  --cm-radius: 10px;
  --cm-radius-sm: 6px;
  --cm-shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --cm-shadow-lg: 0 18px 42px -12px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
  --cm-sidebar-width: 260px;
  --cm-drawer-width: 340px;
  --cm-topbar-height: 52px;
  --cm-bottom-bar-height: 48px;
  --cm-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --cm-font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"],
html.dark {
  --cm-bg: #0b0f17;
  --cm-surface: #111827;
  --cm-surface-2: #1e293b;
  --cm-border: #1f2937;
  --cm-border-strong: #334155;
  --cm-text: #f8fafc;
  --cm-muted: #94a3b8;
  --cm-accent: #3b82f6;
  --cm-accent-hover: #60a5fa;
  --cm-accent-soft: rgba(59, 130, 246, 0.16);
  --cm-danger: #ef4444;
  --cm-danger-soft: rgba(239, 68, 68, 0.16);
  --cm-success: #22c55e;
  --cm-success-soft: rgba(34, 197, 94, 0.16);
  --cm-warning: #f59e0b;
  --cm-warning-soft: rgba(245, 158, 11, 0.18);
  --cm-shadow: 0 6px 20px -4px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  --cm-shadow-lg: 0 22px 48px -12px rgba(0, 0, 0, 0.65), 0 4px 14px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--cm-bg);
  color: var(--cm-text);
  font-family: var(--cm-font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app,
#app-root {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

/* ── Full-Bleed 100vw × 100dvh Application Shell ─────────────────────────── */

.conimo-shell {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  max-width: none;
  overflow: hidden;
  background: var(--cm-bg);
  color: var(--cm-text);
}

.conimo-shell.conimo-shell-col,
.conimo-shell:has(> .conimo-topbar),
.conimo-shell:has(> .conimo-bottom-bar) {
  flex-direction: column;
}

.conimo-shell-row {
  display: flex;
  flex-direction: row;
  flex: 1 1 0%;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  overflow: hidden;
}

/* ── Left Sidebar Pane ───────────────────────────────────────────────────── */

.conimo-sidebar {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--cm-sidebar-width);
  width: var(--cm-sidebar-width);
  height: 100%;
  min-height: 0;
  background: var(--cm-surface);
  border-right: 1px solid var(--cm-border);
  overflow: hidden;
  transition: width 0.18s ease, flex-basis 0.18s ease;
}

.conimo-sidebar.collapsed {
  flex: 0 0 0px;
  width: 0;
  min-width: 0;
  border-right: 0;
  overflow: hidden;
}

.conimo-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--cm-topbar-height);
  padding: 10px 14px;
  border-bottom: 1px solid var(--cm-border);
  flex-shrink: 0;
}

.conimo-sidebar-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conimo-sidebar-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--cm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conimo-sidebar-subtitle {
  font-size: 11px;
  color: var(--cm-muted);
}

.conimo-sidebar-body {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conimo-sidebar-footer {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--cm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ── Main Stage & Scrollable Viewport (NEVER narrow-capped!) ─────────────── */

.conimo-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: none;
  overflow: hidden;
  background: var(--cm-bg);
}

.conimo-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--cm-topbar-height);
  padding: 8px 18px;
  background: var(--cm-surface);
  border-bottom: 1px solid var(--cm-border);
  flex-shrink: 0;
}

.conimo-topbar-titles {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.conimo-topbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--cm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conimo-topbar-subtitle {
  font-size: 12px;
  color: var(--cm-muted);
}

.conimo-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.conimo-scroll-body {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: none;
  overflow: auto;
  padding: 18px;
}

/* ── Unclipped Bottom Bar & Tabs ─────────────────────────────────────────── */

.conimo-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--cm-bottom-bar-height);
  padding: 6px 16px;
  background: var(--cm-surface);
  border-top: 1px solid var(--cm-border);
  flex-shrink: 0;
  z-index: 10;
}

.conimo-bottom-extra {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--cm-muted);
}

/* ── Collapsible Right Inspector Drawer ──────────────────────────────────── */

.conimo-drawer {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--cm-drawer-width);
  width: var(--cm-drawer-width);
  height: 100%;
  min-height: 0;
  background: var(--cm-surface);
  border-left: 1px solid var(--cm-border);
  overflow: hidden;
}

.conimo-drawer.closed {
  display: none;
}

.conimo-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--cm-topbar-height);
  padding: 10px 16px;
  border-bottom: 1px solid var(--cm-border);
  flex-shrink: 0;
}

.conimo-drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--cm-text);
}

.conimo-drawer-body {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conimo-drawer-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--cm-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Buttons (.conimo-btn & legacy .btn aliases) ─────────────────────────── */

.conimo-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--cm-radius-sm);
  border: 1px solid var(--cm-border);
  background: var(--cm-surface);
  color: var(--cm-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.conimo-btn:hover,
.btn:hover {
  background: var(--cm-surface-2);
  border-color: var(--cm-border-strong);
}

.conimo-btn:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.conimo-btn-primary,
.btn-primary {
  background: var(--cm-accent);
  border-color: var(--cm-accent);
  color: #ffffff;
}

.conimo-btn-primary:hover,
.btn-primary:hover {
  background: var(--cm-accent-hover);
  border-color: var(--cm-accent-hover);
  color: #ffffff;
}

.conimo-btn-secondary,
.btn-secondary {
  background: var(--cm-surface-2);
  border-color: var(--cm-border);
  color: var(--cm-text);
}

.conimo-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--cm-muted);
}

.conimo-btn-ghost:hover {
  background: var(--cm-surface-2);
  border-color: transparent;
  color: var(--cm-text);
}

.conimo-btn-danger {
  background: var(--cm-danger-soft);
  border-color: transparent;
  color: var(--cm-danger);
}

.conimo-btn-danger:hover {
  background: var(--cm-danger);
  color: #ffffff;
}

.conimo-btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.conimo-theme-toggle {
  min-width: 34px;
}

/* ── Inputs, Textareas & Selects (.conimo-input) ─────────────────────────── */

.conimo-input,
.conimo-textarea,
.conimo-select {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--cm-radius-sm);
  border: 1px solid var(--cm-border);
  background: var(--cm-surface);
  color: var(--cm-text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.conimo-input::placeholder,
.conimo-textarea::placeholder {
  color: var(--cm-muted);
}

.conimo-input:focus,
.conimo-textarea:focus,
.conimo-select:focus {
  border-color: var(--cm-accent);
  box-shadow: 0 0 0 3px var(--cm-accent-soft);
}

/* ── Cards (.conimo-card) ────────────────────────────────────────────────── */

.conimo-card {
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  box-shadow: var(--cm-shadow);
  padding: 16px;
}

.conimo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

/* ── Badges & Status Pills (.conimo-badge & .status-badge) ───────────────── */

.conimo-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--cm-surface-2);
  color: var(--cm-muted);
  border: 1px solid var(--cm-border);
  white-space: nowrap;
}

.conimo-badge-accent,
.status-badge.status-info {
  background: var(--cm-accent-soft);
  color: var(--cm-accent);
  border-color: transparent;
}

.conimo-badge-success,
.status-badge.status-live,
.status-badge.status-success,
.status-badge.status-ok {
  background: var(--cm-success-soft);
  color: var(--cm-success);
  border-color: transparent;
}

.conimo-badge-danger,
.status-badge.status-error,
.status-badge.status-danger {
  background: var(--cm-danger-soft);
  color: var(--cm-danger);
  border-color: transparent;
}

.conimo-badge-warning,
.status-badge.status-warning,
.status-badge.status-warn {
  background: var(--cm-warning-soft);
  color: var(--cm-warning);
  border-color: transparent;
}

/* ── Tabs & Segmented Controls (.conimo-tabs, .tab-bar, .segmented-control) */

.conimo-tabs,
.tab-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.conimo-tab,
.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--cm-radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--cm-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.conimo-tab:hover,
.tab-item:hover {
  background: var(--cm-surface-2);
  color: var(--cm-text);
}

.conimo-tab.active,
.tab-item.active {
  background: var(--cm-accent-soft);
  color: var(--cm-accent);
  font-weight: 600;
}

.conimo-tab-count,
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--cm-surface-2);
  color: var(--cm-text);
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--cm-radius-sm);
  background: var(--cm-surface-2);
  border: 1px solid var(--cm-border);
  gap: 2px;
}

.segmented-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--cm-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.segmented-btn.active {
  background: var(--cm-surface);
  color: var(--cm-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ── Search Bar, Collapsible Section & Empty State ───────────────────────── */

.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: var(--cm-radius-sm);
  border: 1px solid var(--cm-border);
  background: var(--cm-surface);
}

.search-bar-wrap:focus-within {
  border-color: var(--cm-accent);
  box-shadow: 0 0 0 3px var(--cm-accent-soft);
}

.search-input {
  flex: 1 1 0%;
  min-width: 0;
  padding: 7px 2px;
  border: 0;
  background: transparent;
  color: var(--cm-text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.search-clear-btn,
.modal-close-btn {
  border: 0;
  background: transparent;
  color: var(--cm-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.search-clear-btn:hover,
.modal-close-btn:hover {
  background: var(--cm-surface-2);
  color: var(--cm-text);
}

.collapsible-section {
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-sm);
  background: var(--cm-surface);
  overflow: hidden;
}

.collapsible-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.collapsible-title {
  flex: 1 1 0%;
}

.collapsible-body {
  padding: 10px 12px;
  border-top: 1px solid var(--cm-border);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed var(--cm-border-strong);
  border-radius: var(--cm-radius);
  color: var(--cm-muted);
  gap: 8px;
}

.empty-title {
  margin: 0;
  font-size: 15px;
  color: var(--cm-text);
}

.empty-message {
  margin: 0;
  font-size: 13px;
}

/* ── Tables (.conimo-table) ──────────────────────────────────────────────── */

.conimo-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--cm-surface);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  overflow: hidden;
  font-size: 13px;
}

.conimo-table th,
.conimo-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--cm-border);
}

.conimo-table th {
  background: var(--cm-surface-2);
  color: var(--cm-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.conimo-table tbody tr:hover {
  background: var(--cm-surface-2);
}

/* ── Modals (.conimo-modal-backdrop & .modal-overlay) ────────────────────── */

.conimo-modal-backdrop,
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.conimo-modal,
.modal-content {
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  background: var(--cm-surface);
  color: var(--cm-text);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius);
  box-shadow: var(--cm-shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--cm-border);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--cm-border);
  background: var(--cm-surface-2);
}

.code-viewer-pre {
  margin: 0;
  padding: 12px;
  border-radius: var(--cm-radius-sm);
  background: var(--cm-surface-2);
  font-family: var(--cm-font-mono);
  font-size: 12px;
  overflow-x: auto;
}

/* ── Toast Notifications (.conimo-toast & .toast-notification) ───────────── */

.conimo-toast,
.toast-notification {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--cm-radius-sm);
  background: var(--cm-surface);
  color: var(--cm-text);
  border: 1px solid var(--cm-border-strong);
  box-shadow: var(--cm-shadow-lg);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.conimo-toast.show,
.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left: 3px solid var(--cm-success);
}

.toast-error {
  border-left: 3px solid var(--cm-danger);
}

.toast-info {
  border-left: 3px solid var(--cm-accent);
}

/* ── Responsive Breakpoint ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .conimo-sidebar {
    flex: 0 0 210px;
    width: 210px;
  }

  .conimo-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
    max-width: 92vw;
    box-shadow: var(--cm-shadow-lg);
  }
}
