/* Groggy Realtime Visualization Styles */
html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: #eef1f6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2328;
}

.container {
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: #101827;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 10px;
  background: #f3f4f6;
  border: 1px solid #e4e6eb;
  color: #6a737d;
  margin-right: 10px;
}


.status-connected { color: #1f883d; }
.status-disconnected { color: #dc3545; }
.status-connecting { color: #d29922; }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control-group label {
  font-weight: 600;
  color: #495057;
  min-width: 80px;
}

.control-group select,
.control-group input[type="text"] {
  padding: 8px 12px;
  border: 2px solid #ced4da;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.control-group select:focus,
.control-group input[type="text"]:focus {
  outline: 0;
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.slider {
  flex: 1;
  margin: 0 10px;
}

.btn {
  background: #3267e3;
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s ease, transform .15s ease;
}

.btn:hover { background: #2756c4; }
.btn:active { transform: translateY(1px); }

.canvas-container {
  position: relative;
  background: #fcfcfd;
  border: 2px solid #e3e6eb;
  border-radius: 14px;
  overflow: hidden;
  height: 100%;
  margin: 10px
}

#canvas {
  display: block;
  cursor: crosshair;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 20% 20%, rgba(50,103,227,0.05), transparent 65%),
              radial-gradient(circle at 80% 30%, rgba(17,24,39,0.06), transparent 60%),
              #f9fbfd;
}

.attribute-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 250px;
  background: rgba(248, 249, 250, 0.95);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  backdrop-filter: blur(5px);
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  z-index: 10;
}

.attribute-panel.visible {
  transform: translateX(0);
}

.attribute-panel h3 {
  margin: 0 0 15px 0;
  color: #495057;
  font-size: 16px;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 5px;
}

.attribute-content {
  max-height: 300px;
  overflow-y: auto;
}

.attribute-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #f8f9fa;
}

.attribute-key {
  font-weight: 600;
  color: #495057;
}

.attribute-value {
  color: #6c757d;
  text-align: right;
}

.stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f6f8fa;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  margin: 10px;
  font-size: 10px;
  flex: 0 0 auto;
}

.stat-group {
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-label {
  font-weight: 600;
  color: #6c757d;
}

/* === Minimal rounded shell + floating eyes button + tabbed drawer === */

.viz-shell {
  position: relative;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height:100%
}

.viz-shell .canvas-container {
  border: 0;
  border-radius: 18px;
  flex: 1; min-height: 0;
}

/* Hide the old inline controls area by default (we'll replace it with a drawer) */
.controls {
  display: none;
}

/* Drawer */
.control-drawer {
  position: fixed;
  right: 20px;
  bottom: 60px;
  width: min(92vw, 980px);
  max-height: min(78vh, 720px);
  background: rgba(255,255,255,0.98);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.18);
  backdrop-filter: blur(6px);
  overflow: hidden;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 1100;
}
.control-drawer.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Drawer header with tabs */
.control-drawer__tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  background: #f9fafb;
  border-bottom: 1px solid #eef2f7;
}
.tab-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
}
.tab-btn[aria-selected="true"] {
  background: #111827;
  color: #fff;
}

/* Drawer body */
.control-drawer__body {
  padding: 14px;
  overflow: auto;
  max-height: calc(min(78vh, 720px) - 48px);
}

/* Panels reuse existing grid layout */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Small screens */
@media (max-width: 768px) {
  .control-drawer {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 86px;
    max-height: 75vh;
  }
}

.stat-group span:not(.stat-label) {
  font-weight: 700;
  color: #007bff;
  min-width: 40px;
  text-align: center;
}

.messages {
  max-height: 200px;
  overflow-y: auto;
  background: #212529;
  color: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
}

.messages:empty {
  display: none;
}

.message {
  margin-bottom: 5px;
  opacity: 0.9;
}

.message:last-child {
  margin-bottom: 0;
  opacity: 1;
  font-weight: 600;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    margin: 10px;
    padding: 15px;
  }

  .header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .attribute-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 400px;
    z-index: 1000;
  }

  .attribute-panel.visible {
    transform: translate(-50%, -50%);
  }
}

/* Animation keyframes */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-connecting span {
  animation: pulse 1.5s infinite;
}

.layout-params input {
  padding: 6px 8px;
  border: 2px solid #ced4da;
  border-radius: 6px;
}

/* ========================================
   Table View & View Toggle Styles
   ======================================== */

/* View toggle button group */
.view-toggle-group {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid #0969da;
  border-radius: 6px;
  background: white;
  color: #0969da;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn:hover {
  background: #f6f8fa;
  border-color: #0550ae;
}

.view-toggle-btn:active {
  background: #e7edf4;
  transform: scale(0.98);
}

.view-toggle-btn .view-icon {
  font-size: 16px;
  line-height: 1;
}

.view-toggle-btn .view-label {
  font-weight: 600;
}

/* Table container */
.table-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.table-scroll-wrapper {
  flex: 1;
  overflow: auto;
  position: relative;
}

/* Data table styling */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  position: sticky;
  top: 0;
  background: #f6f8fa;
  z-index: 10;
  border-bottom: 2px solid #d0d7de;
}

.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #1f2328;
  border-bottom: 1px solid #d0d7de;
  white-space: nowrap;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #e7edf4;
  color: #1f2328;
}

.data-table tbody tr:hover {
  background: #f6f8fa;
}

.data-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.data-table tbody tr:nth-child(even):hover {
  background: #f3f4f6;
}

/* Table type toggle (Nodes/Edges) */
.table-type-toggle {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid #d0d7de;
}

.table-type-btn {
  padding: 6px 16px;
  background: white;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #57606a;
  transition: all 0.15s ease;
}

.table-type-btn:hover {
  background: #f3f4f6;
  border-color: #8c959f;
}

.table-type-btn.active {
  background: #0969da;
  color: white;
  border-color: #0969da;
}

/* Table footer with pagination */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f6f8fa;
  border-top: 1px solid #d0d7de;
  font-size: 12px;
  color: #6a737d;
}

.table-nav-btn {
  padding: 6px 12px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: white;
  color: #1f2328;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.table-nav-btn:hover:not(:disabled) {
  background: #f6f8fa;
  border-color: #0969da;
}

.table-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Autofit button - floating in bottom right of graph window */
.autofit-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0969da;
  color: white;
  border: 2px solid #0550ae;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(9, 105, 218, 0.3);
  transition: all 0.2s ease;
  z-index: 100;
}

.autofit-btn:hover {
  background: #0550ae;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(9, 105, 218, 0.4);
}

.autofit-btn:active {
  transform: scale(0.95);
}

.autofit-btn span {
  line-height: 1;
}

/* View switching transitions */
.canvas-container, .table-container {
  transition: opacity 0.2s ease;
}

.canvas-container.hidden, .table-container.hidden {
  display: none;
}
