*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root {
  /* Premium Light Theme (Default) */
  --bg-dark: #f8fafc;
  --bg-gradient: radial-gradient(circle at 50% -20%, #ffffff, #f1f5f9 80%);
  --surface: rgba(255, 255, 255, 0.7);
  --surface-hover: rgba(241, 245, 249, 0.9);
  --border: rgba(0, 0, 0, 0.1);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-gradient: linear-gradient(135deg, #0284c7, #4f46e5);
  --sidebar: 320px;
  --panel: 400px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  /* Additional variables for inverted shadows & elements */
  --shadow-color: rgba(0,0,0,0.08);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --input-bg: rgba(0,0,0,0.03);
  --item-hover: rgba(0,0,0,0.04);
  --item-active: rgba(0,0,0,0.06);
}

body.dark-mode {
  /* Premium Dark Theme */
  --bg-dark: #09090b;
  --bg-gradient: radial-gradient(circle at 50% -20%, #1c1c28, #09090b 80%);
  --surface: rgba(24, 24, 27, 0.65);
  --surface-hover: rgba(39, 39, 42, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #38bdf8;
  --accent-gradient: linear-gradient(135deg, #38bdf8, #818cf8);
  
  --shadow-color: rgba(0,0,0,0.4);
  --glass-bg: rgba(9, 9, 11, 0.85);
  --input-bg: rgba(0,0,0,0.2);
  --item-hover: rgba(255,255,255,0.04);
  --item-active: rgba(255,255,255,0.08);
}

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}
#app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
#body-row { display: flex; flex: 1; overflow: hidden; position: relative; }

/* Glassmorphism Header */
#header {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 50;
}
.logo {
  font-size: 18px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  letter-spacing: -0.5px;
}
#search {
  flex: 1;
  min-width: 200px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}
#search:focus {
  border-color: rgba(56, 189, 248, 0.5);
  background: var(--input-bg);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1), inset 0 2px 4px rgba(0,0,0,0.1);
}
#search::placeholder { color: var(--muted); }

.view-tabs {
  display: flex;
  gap: 6px;
  background: var(--input-bg);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border);
}
.vtab {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  border: none;
  background: transparent;
  font-family: inherit;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.vtab:active {
  transform: scale(0.97);
}
.vtab.active {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: 0 2px 8px var(--input-bg);
  border: 1px solid var(--border);
}
.vtab:hover:not(.active) { color: var(--text); }
.hbadge {
  background: rgba(56,189,248,0.1);
  border: 1px solid rgba(56,189,248,0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
}

/* Glass Sidebar */
#sidebar {
  width: var(--sidebar);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
#sidebar-inner { overflow-y: auto; flex: 1; padding: 20px; }
.sb-head {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 150ms ease, color 150ms ease;
  font-size: 12.5px;
  color: var(--text);
}
.sb-item:active {
  transform: scale(0.97);
}
.sb-item:hover { background: var(--item-hover); color: var(--text); }
.sb-item.active {
  background: var(--item-active);
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.cnt-badge {
  margin-right: auto;
  background: var(--border);
  color: var(--text);
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.sb-item.active .cnt-badge { background: var(--accent); color: #fff; font-weight: 700; }

#tag-cloud { padding: 4px 2px; display: flex; flex-wrap: wrap; gap: 6px; }
.tchip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), border-color 150ms ease, background-color 150ms ease, color 150ms ease;
  background: var(--input-bg);
}
.tchip:active {
  transform: scale(0.95);
}
.tchip:hover:not(:active) { border-color: var(--item-hover); color: var(--text); transform: translateY(-1px); }
.tchip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(56,189,248,0.3);
}

#stat-row { display: flex; gap: 8px; padding-bottom: 12px; }
.scard {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
  flex: 1;
}
.scard .n { font-size: 22px; font-weight: 800; color: var(--text); }
.scard .l { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Canvas Area */
#graph-area { flex: 1; position: relative; }
#network { width: 100%; height: 100%; outline: none; }
#graph-controls { position: absolute; top: 16px; left: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.gc-btn {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 150ms ease, border-color 150ms ease;
  box-shadow: 0 4px 12px var(--input-bg);
}
.gc-btn:active {
  transform: scale(0.96);
}

.gc-btn:hover:not(:active) { background: var(--border); border-color: var(--item-hover); transform: translateY(-1px); }

/* Glass Legend & Tooltip */
#legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.lg-title { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.lg-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 11.5px; color: var(--text); }
.lg-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--border); }
.lg-box { width: 14px; height: 10px; border-radius: 3px; border: 2px solid var(--border); background: var(--input-bg); }
.lg-dia { width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid var(--border); background: var(--input-bg); }

#tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text);
  z-index: 20;
  box-shadow: 0 8px 32px var(--shadow-color);
  display: none;
  transform: translate(0, -10px);
  animation: fadeUp 125ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Detail Panel (Glass) */
#panel {
  width: var(--panel);
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}
#panel.closed { transform: translateX(100%); opacity: 0; position: absolute; right: 0; height: 100%; pointer-events: none; }
#panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
#panel-title { font-weight: 700; font-size: 15px; }
#panel-subtitle { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
#panel-close { background: var(--border); border: 1px solid var(--border); border-radius: 50%; width: 28px; height: 28px; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 150ms ease; }
#panel-close:active { transform: scale(0.9); }
#panel-close:hover:not(:active) { background: var(--border); transform: scale(1.05); }

#panel-list { overflow-y: auto; flex: 1; padding: 16px; }
.scard-full {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.scard-full:active {
  transform: scale(0.97);
}
.scard-full:hover:not(:active) {
  border-color: var(--item-hover);
  background: var(--border);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--input-bg);
}
.sc-num { font-size: 11px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.sc-num span { color: #09090b; border-radius: 12px; padding: 2px 10px; font-weight: 600; }
.sc-concept { font-size: 13.5px; color: var(--text); line-height: 1.6; margin-bottom: 10px; font-weight: 500; }
.sc-exact {
  font-size: 12px;
  color: #a1a1aa;
  line-height: 1.8;
  border-right: 2px solid var(--border);
  padding-right: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.sc-tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.sc-tag { font-size: 10.5px; background: var(--border); border: 1px solid var(--border); color: var(--text); border-radius: 12px; padding: 2px 8px; }

/* Modal Premium */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; display: none; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
#modal {
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(92vw, 700px);
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  box-shadow: 0 24px 64px var(--shadow-color);
  animation: zoomIn 250ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
@keyframes zoomIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
#modal-close { position: absolute; top: 20px; left: 20px; background: var(--border); border: none; border-radius: 50%; width: 32px; height: 32px; color: var(--muted); cursor: pointer; transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background-color 150ms ease, color 150ms ease; display: flex; align-items: center; justify-content: center; }
#modal-close:active { transform: scale(0.9); }
#modal-close:hover:not(:active) { background: var(--border); color: var(--text); }
.m-label { font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; margin-top: 20px; }
.m-val { font-size: 14.5px; color: var(--text); line-height: 1.8; }
.m-exact { white-space: pre-wrap; word-break: break-word; background: var(--input-bg); border: 1px solid var(--border); padding: 16px 20px; border-radius: var(--radius-md); font-size: 13.5px; line-height: 2; color: var(--text); margin-top: 8px; }
.m-pill { display: inline-block; padding: 4px 14px; border-radius: 20px; font-size: 12px; font-weight: 700; color: #fff; margin-left: 8px; box-shadow: 0 4px 12px var(--input-bg); }
.m-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.m-tag { background: var(--border); border: 1px solid var(--border); color: var(--text); border-radius: 16px; padding: 4px 12px; font-size: 12px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg-dark); }
::-webkit-scrollbar-thumb:hover { background: var(--item-hover); }


/* Status indicator and action buttons in header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--border);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  transition: all 0.2s ease;
}
.status-pill.live {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}
.status-pill.static {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}
.status-pill.warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--border);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.btn-header:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--text);
}

/* File Drop Zone / Fallback Overlay */
#file-drop-zone {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.drop-card {
  max-width: 500px;
  width: 100%;
  background: var(--surface);
  border: 2px dashed rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  transition: all 0.25s ease;
}
.drop-card.dragover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  transform: scale(1.02);
}
.drop-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--accent);
}
.drop-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}
.drop-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 24px;
}
.file-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent-gradient);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.file-btn:hover {
  opacity: 0.9;
}
#file-input {
  display: none;
}

/* Toast Notifications */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 900px) {
  #header {
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 10px 14px;
    gap: 10px;
  }
  .logo { order: 1; }
  .header-actions { order: 2; flex-wrap: wrap; }
  .view-tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }
  .vtab { flex: 1; text-align: center; padding: 6px 10px; font-size: 11px; }
  #search {
    order: 4;
    width: 100%;
    margin-top: 4px;
  }
  
  #body-row {
    flex-direction: column-reverse;
  }
  
  #sidebar {
    width: 100%;
    height: 40%;
    border-left: none;
    border-top: 1px solid var(--border);
    flex: none;
  }
  
  #graph-area {
    height: 60%;
    flex: none;
    position: relative;
  }
  
  #panel {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 60;
    border-left: none;
  }
  #panel.closed {
    transform: translateY(100%);
  }
  
  #legend {
    bottom: 10px;
    left: 10px;
    padding: 8px 12px;
    max-width: 50vw;
    font-size: 10px;
  }
  .lg-title { font-size: 9px; margin-bottom: 6px; }
  .lg-row { font-size: 10px; margin: 4px 0; }
  
  #graph-controls {
    top: 10px;
    left: 10px;
    gap: 6px;
  }
  .gc-btn { padding: 6px 10px; font-size: 10px; }
}

@media (max-width: 600px) {
  .logo { width: 100%; text-align: center; }
  .header-actions { width: 100%; justify-content: center; }
  .btn-header { padding: 4px 8px; font-size: 11px; }
  #stat-row { flex-wrap: wrap; }
}
