/*
  --- Enhanced Modern Style for AI Education Tools Graph ---
  - Modern color palette and gradients
  - Improved typography and spacing
  - Subtle animations and transitions
  - Card-like info panel with close button
  - Enhanced legend and controls
  - Responsive and accessible
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

:root {
  --bg-start: #f5f7fa;
  --bg-end: #c3cfe2;
  --surface: rgba(255,255,255,0.92);
  --surface-strong: rgba(255,255,255,0.98);
  --border: #e0e7ff;
  --text: #111827;
  --text-muted: #4b5563;
  --brand: #6366f1;
  --brand-hover: #818cf8;
  --shadow-sm: 0 2px 8px rgba(60,60,100,0.06);
  --shadow-md: 0 8px 32px rgba(60,60,100,0.14);
  --topbar-offset: 84px;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
  overflow: hidden;
}

/* Top bar */
.admin-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid rgba(224,231,255,0.9);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.admin-bar-left,
.admin-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#graph-container {
  width: 100vw;
  height: 100vh;
  background: transparent;
  box-shadow: 0 4px 32px rgba(60,60,100,0.07);
  border-radius: 0.5rem;
}

/* Card View */
.card-container {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  padding: calc(var(--topbar-offset) + 14px) 18px 18px 18px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.app-card {
  background: var(--surface-strong);
  border: 1px solid rgba(224,231,255,0.9);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

/* Category-tinted card backgrounds (match key colors) */
.app-card--LLM {
  background: linear-gradient(135deg, #ffb3b3 0%, #ffd6d6 100%);
}

.app-card--Platform {
  background: linear-gradient(135deg, #aaffb3 0%, #d6ffe0 100%);
}

.app-card--Image {
  background: linear-gradient(135deg, #7faaff 0%, #b3c6ff 100%);
}

.app-card--Assessment {
  background: linear-gradient(135deg, #b3b3ff 0%, #e0e0ff 100%);
}

.app-card:hover,
.app-card:focus {
  outline: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: rgba(99,102,241,0.35);
}

.app-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.app-card-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
  flex: 0 0 auto;
}

.app-card-title {
  min-width: 0;
  flex: 1 1 auto;
}

.app-card-name {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--text);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.app-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid rgba(224,231,255,0.9);
  background: rgba(255,255,255,0.7);
  color: var(--text-muted);
}

.app-card-badge.certified { color: #065f46; }
.app-card-badge.not-certified { color: #991b1b; }
.app-card-badge.unknown { color: #92400e; }

.app-card-desc {
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.35;
  margin: 0 0 10px 0;
}

.app-card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(99,102,241,0.10);
  border: 1px solid rgba(99,102,241,0.18);
  color: var(--text);
  font-size: 0.84rem;
}

.card-empty {
  background: var(--surface-strong);
  border: 1px solid rgba(224,231,255,0.9);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
}

.control-button.active {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

#controls {
  position: fixed;
  top: 72px;
  left: 18px;
  z-index: 100;
  background: var(--surface-strong);
  padding: 16px 16px 14px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: none;
  min-width: 260px;
  transition: box-shadow 0.2s;
  border: 1px solid rgba(224,231,255,0.9);
  backdrop-filter: blur(12px);
}

#controls:focus-within, #controls:hover {
  box-shadow: 0 8px 32px rgba(60,60,100,0.18);
}

.control-buttons {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 101;
  display: flex;
  gap: 12px;
}

.control-button {
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.control-button:hover, .control-button:focus {
  background: var(--brand-hover);
  color: #fff;
  box-shadow: 0 4px 16px rgba(60,60,100,0.10);
}

.controls-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--brand);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.feature-categories {
  margin-bottom: 12px;
}

.feature-categories label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.98rem;
  color: var(--text);
}

.feature-categories input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

#search {
  width: 100%;
  padding: 10px 36px 10px 14px;
  margin-bottom: 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
  background: #f8fafc url('data:image/svg+xml;utf8,<svg fill="gray" height="18" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99c.41.41 1.09.41 1.5 0s.41-1.09 0-1.5l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') no-repeat right 10px center/18px 18px;
  outline: none;
  transition: border 0.2s;
}
#search:focus {
  border: 1.5px solid #6366f1;
}

#legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: color 0.2s;
}
.legend-item:hover {
  color: #6366f1;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(60,60,100,0.10);
  border: 2px solid #fff;
}
.dot.image { background: linear-gradient(135deg, #7faaff 0%, #b3c6ff 100%); }
.dot.llm { background: linear-gradient(135deg, #ffb3b3 0%, #ffd6d6 100%); }
.dot.platform { background: linear-gradient(135deg, #aaffb3 0%, #d6ffe0 100%); }
.dot.assessment { background: linear-gradient(135deg, #b3b3ff 0%, #e0e0ff 100%); }

.tooltip {
  position: absolute;
  padding: 12px 16px;
  background: var(--surface-strong);
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  max-width: 320px;
  font-size: 1rem;
  box-shadow: 0 4px 24px rgba(60,60,100,0.13);
  transition: opacity 0.2s, box-shadow 0.2s;
}

.node {
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s;
}
.node:hover circle {
  filter: drop-shadow(0 0 12px #6366f1cc) url(#drop-shadow);
  stroke: #6366f1;
  stroke-width: 2.5px;
}
.node:focus circle {
  filter: drop-shadow(0 0 16px #6366f1cc) url(#drop-shadow);
  stroke: #6366f1;
  stroke-width: 3px;
}

.node text {
  filter: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  fill: #222;
  text-shadow: 0 1px 2px #fff8;
}

.text-container {
  fill: #fff;
  opacity: 0.92;
  stroke: #e0e7ff;
  stroke-width: 1.5px;
  filter: drop-shadow(0 1px 4px #b3b3ff33);
}

/* Info Panel Enhancements */
.info-panel {
  position: fixed;
  right: 2vw;
  top: 2vw;
  width: calc(100% - 4vw);
  max-width: 26rem;
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(12px);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(60,60,100,0.18);
  padding: 1.5rem 1.5rem 1.2rem 1.5rem;
  display: none;
  z-index: 200;
  border: 1.5px solid #e0e7ff;
  animation: fadeInPanel 0.4s cubic-bezier(.4,0,.2,1);
}
@keyframes fadeInPanel {
  from { opacity: 0; transform: translateY(-20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.info-header {
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  letter-spacing: 0.01em;
}

.app-category {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 0.4rem;
  background: #f0f0f0;
  font-size: 0.95rem;
  font-weight: 600;
  margin-left: 0.5rem;
  box-shadow: 0 1px 4px #b3b3ff33;
  color: #fff;
}

.info-panel .close-btn {
  font-size: 1.3rem;
  font-weight: 600;
  color: #6366f1;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
  margin-right: -0.5rem;
  margin-top: -0.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.3rem;
  transition: background 0.2s;
}
.info-panel .close-btn:hover {
  background: #e0e7ff;
}

.app-description {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 760px) {
  .admin-bar {
    padding: 10px 12px;
  }
  #controls {
    left: 12px;
    right: 12px;
    min-width: auto;
  }
  .control-button {
    padding: 10px 12px;
    border-radius: 12px;
  }
}

.features-section,
.security-section,
.similarity-section {
  margin-top: 1.1rem;
}

.features-section h4,
.security-section h4,
.similarity-section h4 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #6366f1;
}

.features-container,
.security-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.feature-badge,
.security-badge {
  padding: 0.28rem 0.7rem;
  border-radius: 0.4rem;
  font-size: 0.93rem;
  background: #f0f4ff;
  color: #374151;
  font-weight: 500;
  box-shadow: 0 1px 4px #b3b3ff22;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.2s;
}
.feature-badge:before {
  content: '\2714';
  color: #6366f1;
  font-size: 0.9em;
  margin-right: 0.3em;
  opacity: 0.7;
}
.security-badge {
  background: #e0e7ff;
  color: #6366f1;
}

.similarity-bar-container {
  width: 100%;
  height: 0.7rem;
  background: #e0e7ff;
  border-radius: 0.35rem;
  margin-top: 0.5rem;
  overflow: hidden;
}

.similarity-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50 0%, #6366f1 100%);
  border-radius: 0.35rem;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

/* SDC Certification Status in Info Panel */
.sdc-cert-status {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.5em;
  font-size: 1.08rem;
  font-weight: bold;
  letter-spacing: 0.01em;
}
.sdc-cert-status .cert-bracket {
  color: #7c3aed;
  font-weight: bold;
  font-size: 1.1em;
}
.sdc-cert-status .cert-check {
  color: #22c55e;
  font-weight: bold;
  font-size: 1.1em;
}
.sdc-cert-status .cert-x {
  color: #b91c1c;
  font-weight: bold;
  font-size: 1.1em;
}
.sdc-cert-status .cert-unknown {
  color: #b45309;
  font-weight: bold;
  font-size: 1.1em;
}

.sdc-cert-status.certified {
  position: relative;
  z-index: 1;
}
.sdc-cert-status.certified.certified-animate .cert-check {
  animation: certified-glow 1.2s infinite alternate cubic-bezier(.4,0,.2,1);
  position: relative;
  z-index: 2;
}
.sdc-cert-status.certified.certified-animate::before {
  animation: certified-bg-pulse 2.2s infinite alternate cubic-bezier(.4,0,.2,1);
}
.sdc-cert-status.certified::before {
  content: '';
  position: absolute;
  left: -12px; right: -12px; top: -8px; bottom: -8px;
  border-radius: 12px;
  background: radial-gradient(circle at 60% 40%, #c4b5fd88 0%, #a78bfa33 60%, transparent 100%);
  opacity: 0.7;
  z-index: 0;
  animation: certified-bg-pulse 2.2s infinite alternate cubic-bezier(.4,0,.2,1);
}
@keyframes certified-glow {
  0% { text-shadow: 0 0 0px #a78bfa, 0 0 0px #22c55e; }
  100% { text-shadow: 0 0 12px #a78bfa, 0 0 8px #22c55e; }
}
@keyframes certified-bg-pulse {
  0% { opacity: 0.5; transform: scale(1); }
  100% { opacity: 0.85; transform: scale(1.08); }
}

.sdc-cert-status.not-certified {
  position: relative;
  z-index: 1;
}
.sdc-cert-status.not-certified.not-certified-animate .cert-x {
  animation: notcert-shake 0.7s infinite cubic-bezier(.4,0,.2,1);
  position: relative;
  z-index: 2;
}
.sdc-cert-status.not-certified.not-certified-animate::before {
  animation: notcert-bg-pulse 1.5s infinite alternate cubic-bezier(.4,0,.2,1);
}
.sdc-cert-status.not-certified::before {
  content: '';
  position: absolute;
  left: -12px; right: -12px; top: -8px; bottom: -8px;
  border-radius: 12px;
  background: repeating-linear-gradient(135deg, #fca5a544 0 8px, #f8717144 8px 16px);
  opacity: 0.7;
  z-index: 0;
  animation: notcert-bg-pulse 1.5s infinite alternate cubic-bezier(.4,0,.2,1);
}
@keyframes notcert-shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-2px) rotate(-5deg); }
  40% { transform: translateX(2px) rotate(5deg); }
  60% { transform: translateX(-2px) rotate(-3deg); }
  80% { transform: translateX(2px) rotate(3deg); }
  100% { transform: translateX(0); }
}
@keyframes notcert-bg-pulse {
  0% { opacity: 0.5; }
  100% { opacity: 0.85; }
}

/* Table styles (if used) */
table {
  border-collapse: collapse;
  margin-top: 10px;
  width: 100%;
  font-size: 0.98rem;
}
th, td {
  border: 1px solid #e0e7ff;
  padding: 6px 8px;
}
th {
  background: #f0f4ff;
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .info-panel {
    right: 1vw;
    top: 1vw;
    max-width: 98vw;
    width: 98vw;
    padding: 1rem 0.7rem 1rem 0.7rem;
  }
  #controls {
    left: 1vw;
    top: 1vw;
    min-width: 180px;
    padding: 12px 8px 8px 8px;
  }
  .control-buttons {
    left: 1vw;
    top: 1vw;
  }
}

@media (max-width: 600px) {
  .info-panel {
    top: 0.5vw;
    right: 0.5vw;
    max-width: 99vw;
    width: 99vw;
    padding: 0.7rem 0.2rem 0.7rem 0.2rem;
    border-radius: 0.7rem;
  }
  #controls {
    left: 0.5vw;
    top: 0.5vw;
    min-width: 120px;
    padding: 8px 4px 4px 4px;
    border-radius: 0.7rem;
  }
  .control-buttons {
    left: 0.5vw;
    top: 0.5vw;
  }
}

/* Accessibility: focus styles */
.control-button:focus, #search:focus, .legend-item:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Microinteractions */
.similarity-bar {
  animation: fillBar 0.7s cubic-bezier(.4,0,.2,1);
}
@keyframes fillBar {
  from { width: 0; }
  to { width: 100%; }
}

.app-status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
