/* ================================================================
   Smart Campus Navigator — Premium Dark-Mode Design
   ================================================================ */

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

/* ---------- Design Tokens ---------- */
:root {
  --bg-deep:    #0a0e1a;
  --bg-surface: #111827;
  --bg-card:    rgba(17, 24, 39, 0.65);
  --bg-glass:   rgba(255, 255, 255, 0.04);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --accent:       #6366f1;
  --accent-light: #818cf8;
  --accent-glow:  rgba(99, 102, 241, 0.35);

  --teal:       #14b8a6;
  --teal-glow:  rgba(20, 184, 166, 0.30);

  --rose:       #f43f5e;
  --rose-glow:  rgba(244, 63, 94, 0.25);

  --amber:      #f59e0b;

  --border:     rgba(148, 163, 184, 0.10);
  --border-glow: rgba(99, 102, 241, 0.25);

  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md:  0 8px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg:  0 16px 60px rgba(0, 0, 0, 0.45);

  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-pill: 999px;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Animated Background ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(800px 600px at 15% 10%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(600px 500px at 85% 80%, rgba(20, 184, 166, 0.08), transparent 55%),
    radial-gradient(400px 400px at 50% 50%, rgba(244, 63, 94, 0.05), transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { opacity: 0.8; }
  50%  { opacity: 1; }
  100% { opacity: 0.7; }
}

/* ---------- App Shell ---------- */
.app {
  position: relative;
  z-index: 1;
  width: min(1060px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
  display: grid;
  gap: 20px;
}

/* ---------- Glass Card Mixin ---------- */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* ---------- Header ---------- */
.header {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(20, 184, 166, 0.08));
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.header::after {
  content: '';
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--teal), var(--accent-light));
  border-radius: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-light);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal-glow);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.8); }
}

h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* ---------- Stats Bar ---------- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: center;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-light);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ---------- Controls Section ---------- */
.controls {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 20px;
  display: grid;
  gap: 16px;
}

.controls-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- Quick Buttons ---------- */
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-glass);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--transition);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn:hover::before {
  opacity: 1;
}

.btn:active {
  transform: translateY(0);
}

.btn .btn-icon {
  margin-right: 6px;
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  box-shadow: 0 8px 28px var(--accent-glow);
}

.btn-primary::before { display: none; }

.btn-ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--rose);
  box-shadow: 0 4px 16px var(--rose-glow);
}

/* ---------- Result Card ---------- */
.result {
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  transition: all 350ms ease;
  position: relative;
  overflow: hidden;
}

.result::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 3px;
  transition: background var(--transition);
}

.result[data-tone="ok"]::before { background: var(--teal); }
.result[data-tone="warn"]::before { background: var(--amber); }
.result[data-tone="error"]::before { background: var(--rose); }

.result[data-tone="ok"] {
  border-color: rgba(20, 184, 166, 0.2);
  background: rgba(20, 184, 166, 0.06);
}

.result[data-tone="warn"] {
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.06);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.result-icon {
  font-size: 16px;
}

.result-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result[data-tone="ok"] .result-title { color: var(--teal); }
.result[data-tone="warn"] .result-title { color: var(--amber); }

.result-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  padding-left: 2px;
}

.result[data-tone="ok"] .result-text,
.result[data-tone="warn"] .result-text {
  color: var(--text-primary);
}

/* ---------- Map Section ---------- */
.mapCard {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.mapHeader {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.mapTitle {
  font-weight: 800;
  font-size: 16px;
}

.mapHint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.mapWrap {
  position: relative;
  padding: 20px;
  background: linear-gradient(180deg, rgba(10, 14, 26, 0.4), rgba(17, 24, 39, 0.6));
  min-height: 380px;
}

/* SVG campus map styling */
.campus-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

/* Legacy image fallback */
.mapWrap img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  filter: brightness(0.85) contrast(1.05);
}

.mapOverlay {
  position: absolute;
  left: 20px;
  top: 20px;
  right: 20px;
  bottom: 20px;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* ---------- Map Pins ---------- */
.pin {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.25);
  border: 2px solid rgba(99, 102, 241, 0.35);
  transform: translate(-50%, -50%);
  opacity: 0.5;
  transition: all 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  pointer-events: auto;
}

.pin::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.pin:hover::after,
.pin.active::after {
  opacity: 1;
}

.pin.active {
  opacity: 1;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow:
    0 0 0 6px var(--accent-glow),
    0 0 30px var(--accent-glow);
  animation: pinGlow 2s ease-in-out infinite;
}

@keyframes pinGlow {
  0%, 100% { box-shadow: 0 0 0 6px var(--accent-glow), 0 0 30px var(--accent-glow); }
  50%      { box-shadow: 0 0 0 10px rgba(99,102,241,0.15), 0 0 50px var(--accent-glow); }
}

/* Pin positions */
.pin[data-pin="library"]        { left: 18%; top: 22%; }
.pin[data-pin="canteen"]        { left: 62%; top: 18%; }
.pin[data-pin="graphicslab"]    { left: 38%; top: 38%; }
.pin[data-pin="classroom"]      { left: 75%; top: 50%; }
.pin[data-pin="office"]         { left: 25%; top: 60%; }
.pin[data-pin="washroom"]       { left: 55%; top: 72%; }
.pin[data-pin="programminglab"] { left: 42%; top: 55%; }
.pin[data-pin="mathematicslab"] { left: 82%; top: 35%; }
.pin[data-pin="physicslab"]     { left: 15%; top: 78%; }
.pin[data-pin="chemistrylab"]   { left: 68%; top: 82%; }
.pin[data-pin="biologylab"]     { left: 88%; top: 68%; }

/* ---------- Legend ---------- */
.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 16px;
  color: var(--text-muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-glow);
}

.dot--active {
  background: var(--accent);
}

.dot--idle {
  background: rgba(99, 102, 241, 0.3);
  border: 1px solid rgba(99, 102, 241, 0.4);
}

/* ---------- Recent Activity ---------- */
.activity-section {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.activity-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.activity-title {
  font-weight: 800;
  font-size: 16px;
}

.activity-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.activity-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

.activity-list::-webkit-scrollbar {
  width: 4px;
}

.activity-list::-webkit-scrollbar-track {
  background: transparent;
}

.activity-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background var(--transition);
  animation: slideIn 300ms ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.activity-item:last-child { border-bottom: none; }

.activity-item:hover {
  background: var(--bg-glass);
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.activity-text {
  color: var(--text-secondary);
  flex: 1;
}

.activity-text strong {
  color: var(--text-primary);
}

.activity-time {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.activity-empty {
  padding: 24px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0 0;
}

.footer strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.footer-links {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.footer-link {
  color: var(--accent-light);
  text-decoration: none;
  font-size: 12px;
  transition: color var(--transition);
}

.footer-link:hover {
  color: var(--teal);
}

/* ---------- Accessibility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .app { padding: 16px 0 40px; }
  .header { padding: 20px; border-radius: var(--radius-md); }
  h1 { font-size: 24px; }
  .search { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .mapWrap { padding: 12px; min-height: 260px; }
  .mapOverlay { left: 12px; top: 12px; right: 12px; bottom: 12px; }
}

@media (max-width: 380px) {
  .stats-bar { grid-template-columns: 1fr; }
  .quick { gap: 6px; }
  .btn { padding: 8px 12px; font-size: 12px; }
}
