/* Kaiser Drug Knowledge Graph Explorer – Dashboard Styles */

:root {
  --kaiser-blue-dark: #1E3A8A;
  --kaiser-blue: #2563EB;
  --kaiser-blue-light: #3B82F6;

  --type-drug: #2563EB;
  --type-drug-bg: #DBEAFE;
  --type-disease: #991B1B;
  --type-disease-bg: #FEE2E2;
  --type-condition: #92400E;
  --type-condition-bg: #FEF3C7;
  --type-ingredient: #065F46;
  --type-ingredient-bg: #D1FAE5;
  --type-reaction: #9D174D;
  --type-reaction-bg: #FCE7F3;
  --type-patient: #6D28D9;
  --type-patient-bg: #EDE9FE;

  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;

  --bg-primary: #F9FAFB;
  --bg-white: #FFFFFF;
  --bg-light-blue: #F0F5FF;
  --border-color: #E5E7EB;
  --border-light: #F3F4F6;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.clean-header {
  background: linear-gradient(135deg, #1E3A5F 0%, #2563EB 100%);
  color: white;
  padding: 1.25rem 0;
}

.header-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.header-subtitle {
  font-size: 0.875rem;
  opacity: 0.8;
  margin-top: 0.125rem;
}

/* ── Nav Tabs ─────────────────────────────────────────────────────────── */
.nav-tabs-section {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  padding: 0;
}

.nav-tabs-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tab {
  padding: 1rem 1.5rem;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  white-space: nowrap;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--kaiser-blue);
  background: var(--bg-light-blue);
}

.nav-tab.active {
  color: var(--kaiser-blue);
  border-bottom-color: var(--kaiser-blue);
}

/* ── Type Tabs ────────────────────────────────────────────────────────── */
.type-tabs-section {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

.type-tabs-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 0.625rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.type-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: 2px solid transparent;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.type-tab .tab-label { color: var(--text-secondary); }

.type-tab .tab-count {
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 26px;
  text-align: center;
  background: #E5E7EB;
  color: var(--text-secondary);
}

.type-tab.active,
.type-tab:hover {
  background: var(--bg-light-blue);
  border-color: var(--kaiser-blue);
}

.type-tab.active .tab-label,
.type-tab:hover .tab-label { color: var(--kaiser-blue); }

.type-tab.active .tab-count {
  background: var(--kaiser-blue);
  color: white;
}

/* Colored tab variants */
.tab-Drug.active, .tab-Drug:hover { background: var(--type-drug-bg); border-color: var(--type-drug); }
.tab-Drug.active .tab-label, .tab-Drug:hover .tab-label { color: var(--type-drug); }
.tab-Drug.active .tab-count { background: var(--type-drug); color: white; }
.tab-Drug .tab-count { background: var(--type-drug-bg); color: var(--type-drug); }

.tab-Disease.active, .tab-Disease:hover { background: var(--type-disease-bg); border-color: var(--type-disease); }
.tab-Disease.active .tab-label, .tab-Disease:hover .tab-label { color: var(--type-disease); }
.tab-Disease.active .tab-count { background: var(--type-disease); color: white; }
.tab-Disease .tab-count { background: var(--type-disease-bg); color: var(--type-disease); }

.tab-Condition.active, .tab-Condition:hover { background: var(--type-condition-bg); border-color: var(--type-condition); }
.tab-Condition.active .tab-label, .tab-Condition:hover .tab-label { color: var(--type-condition); }
.tab-Condition.active .tab-count { background: var(--type-condition); color: white; }
.tab-Condition .tab-count { background: var(--type-condition-bg); color: var(--type-condition); }

.tab-ActiveIngredient.active, .tab-ActiveIngredient:hover { background: var(--type-ingredient-bg); border-color: var(--type-ingredient); }
.tab-ActiveIngredient.active .tab-label, .tab-ActiveIngredient:hover .tab-label { color: var(--type-ingredient); }
.tab-ActiveIngredient.active .tab-count { background: var(--type-ingredient); color: white; }
.tab-ActiveIngredient .tab-count { background: var(--type-ingredient-bg); color: var(--type-ingredient); }

.tab-AdverseReaction.active, .tab-AdverseReaction:hover { background: var(--type-reaction-bg); border-color: var(--type-reaction); }
.tab-AdverseReaction.active .tab-label, .tab-AdverseReaction:hover .tab-label { color: var(--type-reaction); }
.tab-AdverseReaction.active .tab-count { background: var(--type-reaction); color: white; }
.tab-AdverseReaction .tab-count { background: var(--type-reaction-bg); color: var(--type-reaction); }

.tab-Patient.active, .tab-Patient:hover { background: var(--type-patient-bg); border-color: var(--type-patient); }
.tab-Patient.active .tab-label, .tab-Patient:hover .tab-label { color: var(--type-patient); }
.tab-Patient.active .tab-count { background: var(--type-patient); color: white; }
.tab-Patient .tab-count { background: var(--type-patient-bg); color: var(--type-patient); }

/* ── Search ───────────────────────────────────────────────────────────── */
.search-section {
  background: var(--bg-white);
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.search-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 1rem;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  background: var(--bg-primary);
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--kaiser-blue);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.reset-btn {
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.reset-btn:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: #FEE2E2;
}

/* ── Entity Grid ──────────────────────────────────────────────────────── */
.entities-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.entities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.25rem;
}

.entity-card {
  background: var(--bg-white);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.entity-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.entity-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--kaiser-blue-light);
}

.entity-card:hover::before { opacity: 1; }

.entity-card[data-type="Drug"]::before             { background: var(--type-drug); }
.entity-card[data-type="Disease"]::before           { background: var(--type-disease); }
.entity-card[data-type="Condition"]::before         { background: var(--type-condition); }
.entity-card[data-type="ActiveIngredient"]::before  { background: var(--type-ingredient); }
.entity-card[data-type="AdverseReaction"]::before   { background: var(--type-reaction); }
.entity-card[data-type="Patient"]::before           { background: var(--type-patient); }

.entity-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.entity-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.3;
  flex: 1;
  margin-right: 0.75rem;
}

.entity-type-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-Drug             { background: var(--type-drug-bg); color: var(--type-drug); }
.badge-Disease          { background: var(--type-disease-bg); color: var(--type-disease); }
.badge-Condition        { background: var(--type-condition-bg); color: var(--type-condition); }
.badge-ActiveIngredient { background: var(--type-ingredient-bg); color: var(--type-ingredient); }
.badge-AdverseReaction  { background: var(--type-reaction-bg); color: var(--type-reaction); }
.badge-Patient          { background: var(--type-patient-bg); color: var(--type-patient); }

.entity-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.entity-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.entity-related {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.entity-arrow {
  color: var(--kaiser-blue);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.entity-card:hover .entity-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* ── Empty State ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); }
.empty-state-text { font-size: 0.9375rem; }

/* ── Detail Page ──────────────────────────────────────────────────────── */
.detail-header { position: sticky; top: 0; z-index: 1000; }

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

.back-link {
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  opacity: 0.9;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.back-link:hover { opacity: 1; transform: translateX(-3px); }

.entity-info-bar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

.entity-info-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.info-chip {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.info-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.detail-section {
  background: var(--bg-white);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.section-heading {
  color: var(--kaiser-blue);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--bg-light-blue);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

/* ── Data App Placeholder Sections ────────────────────────────────────── */
.data-app-section {
  background: var(--bg-white);
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.data-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, #FAFBFF 0%, #F0F5FF 100%);
}

.data-app-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.data-app-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.data-app-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.data-app-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.data-app-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
}

.status-ready {
  background: #D1FAE5;
  color: #065F46;
}

.status-pending {
  background: #FEF3C7;
  color: #92400E;
}

.data-app-body {
  padding: 2rem 1.5rem;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.data-app-placeholder {
  text-align: center;
  padding: 2rem;
}

.data-app-placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.data-app-placeholder-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.data-app-placeholder-subtext {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.data-app-endpoint {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  color: var(--kaiser-blue);
}

.endpoint-method {
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
}

.method-get { background: #D1FAE5; color: #065F46; }
.method-post { background: #DBEAFE; color: #1E3A8A; }

/* ── Compare Section (Drug Comparison) ────────────────────────────────── */
.compare-input-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.compare-input-group {
  flex: 1;
  min-width: 200px;
}

.compare-input-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compare-input-group input,
.compare-input-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  background: var(--bg-primary);
  transition: all 0.2s;
}

.compare-input-group input:focus,
.compare-input-group select:focus {
  outline: none;
  border-color: var(--kaiser-blue);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.compare-vs {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-tertiary);
  padding-top: 1.25rem;
  flex-shrink: 0;
}

/* ── Loading Spinner ──────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--text-secondary);
}

.spinner {
  border: 3px solid var(--border-color);
  border-top-color: var(--kaiser-blue);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-right: 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Detail Sections Grid ─────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.5rem;
}

.detail-grid .data-app-section {
  margin-bottom: 0;
}

/* ── Quick Actions Bar ────────────────────────────────────────────────── */
.quick-actions {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.quick-action-card {
  flex: 1;
  min-width: 200px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quick-action-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--kaiser-blue-light);
}

.quick-action-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.quick-action-text h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}

.quick-action-text p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-title { font-size: 1.25rem; }
  .type-tabs-wrapper { gap: 0.5rem; }
  .type-tab { padding: 0.5rem 0.75rem; font-size: 0.8125rem; }
  .search-wrapper { flex-direction: column; }
  .search-box { width: 100%; }
  .reset-btn { width: 100%; }
  .entities-grid { grid-template-columns: 1fr; }
  .entity-info-wrapper { flex-direction: column; gap: 1rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .compare-input-row { flex-direction: column; }
  .compare-vs { padding-top: 0; }
  .quick-actions { flex-direction: column; }
  .nav-tab { padding: 0.75rem 1rem; font-size: 0.8125rem; }
}
