/* ===== GRAPH VIEWER — Knowledge Graph Styles ===== */
/* Uses CSS variables from ../css/variables.css */

/* --- Layout --- */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  /* Override variables.css body flex */
  display: block !important;
}

.graph-layout {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
.graph-sidebar {
  background: var(--sidebar-glass);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-right: 1px solid rgba(255,255,255,.06);
  z-index: 10;
  transition: margin-left var(--duration-slow) var(--ease);
}

.graph-sidebar.collapsed {
  margin-left: -220px;
}

.gs-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 56px;
}

.gs-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  object-fit: contain;
}

.gs-name {
  color: #f1f3f5;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
}

.gs-label {
  font-size: 11px;
  color: var(--sidebar-text);
}

.gs-section {
  padding: 12px 14px 4px;
}

.gs-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(134,142,150,.6);
  font-weight: 600;
  margin-bottom: 8px;
}

/* --- View tabs --- */
.gs-views {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gs-view-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--sidebar-text);
  transition: all var(--duration-base) var(--ease);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.gs-view-item:hover {
  background: var(--sidebar-hover);
  color: #f1f3f5;
}

.gs-view-item.active {
  background: rgba(69,69,255,.15);
  color: #a3a3ff;
}

.gs-view-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gs-view-icon svg {
  width: 14px;
  height: 14px;
}

/* --- Search --- */
.gs-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-md);
  padding: 6px 10px;
}

.gs-search svg {
  color: rgba(134,142,150,.6);
  flex-shrink: 0;
}

.gs-search input {
  border: none;
  background: none;
  outline: none;
  color: #f1f3f5;
  font-size: 12px;
  font-family: var(--font);
  width: 100%;
}

.gs-search input::placeholder {
  color: rgba(134,142,150,.5);
}

/* --- Filters --- */
.gs-filters {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
}

.gs-filters::-webkit-scrollbar { width: 3px; }
.gs-filters::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

.gs-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 2px;
  font-size: 12px;
  color: var(--sidebar-text);
  cursor: pointer;
  user-select: none;
}

.gs-filter-item:hover {
  color: #f1f3f5;
}

.gs-filter-check {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.04);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.gs-filter-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.gs-filter-check:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.gs-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gs-filter-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-filter-count {
  font-size: 10px;
  color: rgba(134,142,150,.5);
  margin-left: auto;
}

/* --- Stats --- */
.gs-stats {
  display: flex;
  gap: 8px;
  padding: 14px !important;
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.06);
}

.gs-stat {
  flex: 1;
  text-align: center;
}

.gs-stat-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #f1f3f5;
  line-height: 1.2;
}

.gs-stat-label {
  font-size: 10px;
  color: rgba(134,142,150,.6);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* --- Sidebar footer --- */
.gs-footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.gs-back {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  font-size: 12px;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: all var(--duration-base) var(--ease);
}

.gs-back:hover {
  background: var(--sidebar-hover);
  color: #f1f3f5;
}

/* --- Main area --- */
.graph-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

/* --- Toolbar --- */
.graph-toolbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--header-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  flex-shrink: 0;
  z-index: 5;
}

.gt-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gt-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gt-view-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.gt-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: all var(--duration-base) var(--ease);
  padding: 0;
  gap: 4px;
  font-family: var(--font);
}

.gt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.gt-btn-label {
  font-size: 11px;
  font-weight: 600;
}

.gt-btn:has(.gt-btn-label) {
  width: auto;
  padding: 0 10px;
}

.gt-sidebar-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: all var(--duration-base) var(--ease);
  padding: 0;
}

.gt-sidebar-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.gt-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* --- Cytoscape canvas --- */
#cy {
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

/* --- Legend --- */
.graph-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-shadow);
  font-size: 11px;
  color: var(--text2);
  z-index: 4;
}

.gl-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.gl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gl-line {
  width: 18px;
  height: 2px;
  flex-shrink: 0;
  border-radius: 1px;
}

.gl-line.dashed {
  background: none;
  border-top: 2px dashed;
}

.gl-line.dotted {
  background: none;
  border-top: 2px dotted;
}

/* --- Detail panel --- */
.graph-detail {
  background: var(--card);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: margin-right var(--duration-slow) var(--ease);
}

.graph-detail::-webkit-scrollbar { width: 4px; }
.graph-detail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Detail empty state */
.gd-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  color: var(--text3);
}

.gd-empty svg {
  margin-bottom: 16px;
  opacity: .4;
}

.gd-empty-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text2);
}

.gd-empty-text {
  font-size: 12px;
  line-height: 1.5;
}

/* Detail content */
.gd-content {
  padding: 20px;
}

.gd-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.gd-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gd-info {
  flex: 1;
  min-width: 0;
}

.gd-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.gd-type-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}

.gd-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text3);
  transition: all var(--duration-base) var(--ease);
  flex-shrink: 0;
  padding: 0;
}

.gd-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.gd-file {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
  word-break: break-all;
}

.gd-file a {
  color: var(--accent);
  text-decoration: none;
}

.gd-file a:hover {
  text-decoration: underline;
}

.gd-purpose {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 10px 12px;
  background: var(--gradient-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* Business capabilities */
.gd-capabilities {
  margin-bottom: 16px;
}

.gd-caps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gd-caps-item {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  padding: 4px 8px 4px 16px;
  position: relative;
  border-radius: var(--radius-xs);
  transition: background var(--duration-fast) var(--ease);
}

.gd-caps-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .6;
}

.gd-caps-item:hover {
  background: var(--accent-bg);
}

/* Connection groups */
.gd-connections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gd-conn-group {
  /* A group of connections by edge type */
}

.gd-conn-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gd-conn-title-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.gd-conn-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gd-conn-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.gd-conn-item:hover {
  background: var(--accent-bg);
}

.gd-conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gd-conn-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gd-conn-type {
  font-size: 10px;
  color: var(--text3);
}

/* Impact summary */
.gd-impact {
  margin-top: 16px;
  padding: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.gd-impact-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.gd-impact-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gd-impact-stat {
  text-align: center;
}

.gd-impact-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.gd-impact-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* --- Dark mode overrides specific to graph --- */
[data-theme="dark"] .graph-main {
  background: var(--bg);
}

[data-theme="dark"] #cy {
  background: var(--bg);
}

/* --- Responsive --- */
@media (max-width: 1100px) {
  .graph-layout {
    grid-template-columns: 220px 1fr 0;
  }
  .graph-detail {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    z-index: 20;
    box-shadow: var(--shadow-xl);
    transition: right var(--duration-slow) var(--ease);
  }
  .graph-detail.open {
    right: 0;
  }
}

@media (max-width: 768px) {
  .graph-layout {
    grid-template-columns: 0 1fr 0;
  }

  .graph-sidebar {
    position: fixed;
    top: 0;
    left: -220px;
    width: 220px;
    height: 100vh;
    z-index: 20;
    box-shadow: var(--shadow-xl);
    transition: left var(--duration-slow) var(--ease);
  }

  .graph-sidebar.mobile-open {
    left: 0;
  }

  .graph-sidebar.collapsed {
    margin-left: 0;
  }

  .gt-sidebar-toggle {
    display: flex;
  }

  .graph-detail {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    z-index: 20;
    box-shadow: var(--shadow-xl);
    transition: right var(--duration-slow) var(--ease);
  }
  .graph-detail.open {
    right: 0;
  }

  .graph-legend {
    bottom: 8px;
    left: 8px;
    font-size: 10px;
    padding: 6px 10px;
    gap: 6px;
  }
}

/* Overlay for mobile panels */
.graph-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.4);
  z-index: 15;
}

.graph-overlay.active {
  display: block;
}
