/* ══════════════════════════════════════════════
   RESET & VARIABLES
══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #070b18;
  --bg-1:         #0c1225;
  --bg-2:         #111a30;
  --bg-3:         #18243d;
  --border:       #1e2f50;
  --border-glow:  #1e4a8a;
  --cyan:         #00d4ff;
  --cyan-dim:     rgba(0, 212, 255, 0.12);
  --cyan-mid:     rgba(0, 212, 255, 0.25);
  --violet:       #7c3aed;
  --green:        #00ff87;
  --orange:       #ff9f43;
  --red:          #ff4757;
  --yellow:       #ffd32a;
  --text:         #dce8ff;
  --text-2:       #8899bb;
  --text-3:       #4a5a7a;
  --radius:       12px;
  --radius-lg:    18px;
  --sidebar-w:    400px;
  --transition:   0.22s ease;
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ══════════════════════════════════════════════
   LANDING PAGE
══════════════════════════════════════════════ */
#landing {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

/* Animated background */
.landing-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, #0d1f4a 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, #0a1535 0%, transparent 55%),
              var(--bg);
}
.bg-orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.18; animation: drift 12s ease-in-out infinite alternate;
}
.orb-1 { width: 600px; height: 600px; background: #0047b3; top: -200px; left: -100px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: #00d4ff; bottom: -150px; right: -100px; animation-delay: -4s; }
.orb-3 { width: 350px; height: 350px; background: #7c3aed; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -8s; opacity: 0.1; }
@keyframes drift { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(40px,30px) scale(1.05); } }
.orb-3 { animation: drift3 10s ease-in-out infinite alternate; }
@keyframes drift3 { 0% { transform: translate(-50%,-50%) scale(1); } 100% { transform: translate(calc(-50% + 30px), calc(-50% - 20px)) scale(1.08); } }

.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* Content layout */
.landing-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 40px;
  width: 100%; max-width: 460px; padding: 24px;
}

/* Atom icon */
.atom-icon {
  position: relative; width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.atom-icon.small { width: 36px; height: 36px; }

.nucleus {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan), 0 0 30px rgba(0,212,255,0.5);
  z-index: 1;
}
.atom-icon.small .nucleus { width: 6px; height: 6px; }

.orbit {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(0,212,255,0.35);
  animation: spin linear infinite;
}
.atom-icon .orbit { width: 70px; height: 26px; }
.atom-icon.small .orbit { width: 32px; height: 12px; }
.orbit-1 { animation-duration: 3s; }
.orbit-2 { animation-duration: 4.5s; transform: rotate(60deg); }
.orbit-3 { animation-duration: 6s; transform: rotate(120deg); }
@keyframes spin { from { transform: rotate(var(--r, 0deg)); } to { transform: rotate(calc(var(--r, 0deg) + 360deg)); } }
.orbit-1 { --r: 0deg; }
.orbit-2 { --r: 60deg; }
.orbit-3 { --r: 120deg; }

.electron {
  position: absolute; top: 50%; right: 0;
  transform: translate(50%, -50%);
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}
.atom-icon.small .electron { width: 3px; height: 3px; }

/* Brand */
.landing-brand {
  display: flex; align-items: center; gap: 20px; text-align: left;
}
.brand-text h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem; font-weight: 700; letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.brand-text p { font-size: 0.85rem; color: var(--text-2); margin-top: 4px; letter-spacing: 0.06em; text-transform: uppercase; }

/* Login card */
.login-card {
  width: 100%;
  background: rgba(13, 22, 45, 0.75);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 0 0 1px rgba(0,212,255,0.05), 0 30px 80px rgba(0,0,0,0.6);
}
.login-card-header { text-align: center; margin-bottom: 28px; }
.access-badge {
  display: inline-block; padding: 3px 10px;
  background: rgba(0,212,255,0.08); border: 1px solid rgba(0,212,255,0.25);
  border-radius: 20px; font-size: 0.65rem; letter-spacing: 0.12em; color: var(--cyan);
  margin-bottom: 14px;
}
.login-card-header h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 600; margin-bottom: 6px; }
.login-card-header p { font-size: 0.82rem; color: var(--text-2); }

/* Form fields */
.field-group { margin-bottom: 18px; }
.field-group label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--text-2); margin-bottom: 7px; letter-spacing: 0.04em; }
.input-wrap {
  position: relative; display: flex; align-items: center;
}
.input-icon {
  position: absolute; left: 14px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.input-wrap input {
  width: 100%; padding: 12px 14px 12px 42px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input-wrap input::placeholder { color: var(--text-3); }
.input-wrap input:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,212,255,0.12);
}
#toggle-pw {
  position: absolute; right: 12px; background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 4px; display: flex;
}
#toggle-pw svg { width: 16px; height: 16px; }
#toggle-pw:hover { color: var(--text-2); }

.login-error {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,71,87,0.1); border: 1px solid rgba(255,71,87,0.3);
  border-radius: var(--radius); padding: 10px 14px;
  color: var(--red); font-size: 0.82rem; margin-bottom: 16px;
}
.login-error svg { width: 15px; height: 15px; flex-shrink: 0; }

#login-btn {
  width: 100%; padding: 13px 20px;
  background: linear-gradient(135deg, #0062cc, #0088ff);
  border: none; border-radius: var(--radius); cursor: pointer;
  color: #fff; font-size: 0.9rem; font-weight: 600; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 20px rgba(0,100,220,0.35);
  margin-top: 4px;
}
#login-btn svg { width: 16px; height: 16px; }
#login-btn:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 8px 28px rgba(0,100,220,0.45); }
#login-btn:active { transform: translateY(0); }

/* Auth tabs */
.auth-tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: rgba(0,0,0,0.25); border-radius: 10px; padding: 4px;
}
.auth-tab {
  flex: 1; padding: 9px 12px;
  background: transparent; border: none; color: var(--text-3);
  font-size: 0.78rem; font-weight: 500; font-family: inherit;
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--transition);
}
.auth-tab:hover { color: var(--text-2); }
.auth-tab.active {
  background: rgba(0,212,255,0.08); color: #fff;
  box-shadow: 0 0 0 1px rgba(0,212,255,0.15);
}
.auth-tab svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Microsoft / Entra ID panel */
#panel-entra {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 20px 0 8px;
}
#microsoft-login-btn {
  width: 100%; padding: 14px 20px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; color: #fff;
  font-size: 0.9rem; font-weight: 600; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
#microsoft-login-btn:hover {
  border-color: rgba(0,212,255,0.3);
  box-shadow: 0 8px 28px rgba(0,100,220,0.25);
  transform: translateY(-1px);
}
#microsoft-login-btn:active { transform: translateY(0); }

.entra-hint {
  font-size: 0.78rem; color: var(--text-3); text-align: center;
  margin: 0;
}

.login-footer {
  display: flex; justify-content: center; gap: 10px; margin-top: 24px;
  font-size: 0.72rem; color: var(--text-3);
}

/* ══════════════════════════════════════════════
   APPLICATION
══════════════════════════════════════════════ */
#app {
  display: flex; height: 100vh; overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w); min-width: 320px;
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  position: relative; z-index: 10;
}

#sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-title { font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.sidebar-subtitle { font-size: 0.68rem; color: var(--text-3); margin-top: 1px; }

#logout-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-3); cursor: pointer; padding: 6px; display: flex;
  transition: border-color var(--transition), color var(--transition);
}
#logout-btn svg { width: 15px; height: 15px; }
#logout-btn:hover { border-color: var(--red); color: var(--red); }

/* Messages */
#messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.message { display: flex; flex-direction: column; max-width: 90%; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.msg-bubble {
  padding: 10px 14px; border-radius: 14px; line-height: 1.55; font-size: 0.87rem; white-space: pre-wrap;
}
.message.user .msg-bubble {
  background: linear-gradient(135deg, #0055c4, #0077ff);
  color: #fff; border-bottom-right-radius: 3px;
  box-shadow: 0 2px 12px rgba(0,100,255,0.25);
}
.message.assistant .msg-bubble {
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 3px;
}

/* Loading dots */
.loading-dots { display: flex; gap: 5px; padding: 14px 16px; }
.loading-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--cyan);
  animation: bounce 1.2s infinite ease-in-out;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* Sources */
.msg-sources {
  margin-top: 6px; padding: 7px 12px;
  background: rgba(0,212,255,0.05); border: 1px solid rgba(0,212,255,0.12);
  border-radius: 8px; font-size: 0.73rem; color: var(--text-2);
}
.msg-sources strong { color: var(--cyan); font-weight: 500; }

/* Map ping message */
.msg-map-ping .msg-bubble {
  background: rgba(0,255,135,0.07); border-color: rgba(0,255,135,0.2); color: var(--green);
  display: flex; align-items: center; gap: 8px;
}
.msg-map-ping .msg-bubble svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Suggestions */
#suggestions {
  padding: 8px 16px 0; display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0;
}
.chip {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-2); font-size: 0.74rem; padding: 5px 11px; border-radius: 20px;
  cursor: pointer; transition: border-color var(--transition), color var(--transition), background var(--transition);
  font-family: inherit; white-space: nowrap;
}
.chip:hover { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-dim); }

/* Input area */
#input-area { padding: 12px 16px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
#input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 8px 8px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#input-wrap:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }

#question-input {
  flex: 1; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-size: 0.875rem; font-family: inherit; line-height: 1.5;
  max-height: 120px; overflow-y: auto;
}
#question-input::placeholder { color: var(--text-3); }

#send-btn {
  background: linear-gradient(135deg, #0055c4, #0077ff);
  border: none; border-radius: 8px; cursor: pointer;
  color: #fff; padding: 8px; display: flex; flex-shrink: 0;
  transition: opacity var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 10px rgba(0,100,255,0.3);
}
#send-btn svg { width: 16px; height: 16px; }
#send-btn:hover { opacity: 0.88; box-shadow: 0 4px 16px rgba(0,100,255,0.45); }
#send-btn:disabled { opacity: 0.35; cursor: default; box-shadow: none; }

#input-hint { font-size: 0.67rem; color: var(--text-3); margin-top: 6px; text-align: center; }

/* ── Map panel ── */
#map-panel { flex: 1; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; }

/* Leaflet dark theme overrides */
.leaflet-container { background: var(--bg); }
.leaflet-popup-content-wrapper {
  background: var(--bg-2) !important; color: var(--text) !important;
  border: 1px solid var(--border) !important; border-radius: var(--radius) !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
  min-width: 220px;
}
.leaflet-popup-tip { background: var(--bg-2) !important; }
.leaflet-popup-close-button { color: var(--text-2) !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }
.leaflet-control-zoom a {
  background: var(--bg-2) !important; color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-3) !important; }
.leaflet-control-attribution {
  background: rgba(7,11,24,0.75) !important; color: var(--text-3) !important; font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-2) !important; }

/* Map legend */
#map-legend {
  position: absolute; bottom: 32px; left: 16px; z-index: 1000;
  background: rgba(13,18,37,0.85); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px;
}
.legend-title { font-size: 0.68rem; font-weight: 600; color: var(--text-2); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-2); margin-bottom: 4px; }
.legend-item:last-child { margin-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.operational { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.construction { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.dot.planned      { background: var(--cyan);  box-shadow: 0 0 6px var(--cyan); }
.dot.shutdown     { background: var(--text-3); }

/* Map placeholder */
#map-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); pointer-events: none; z-index: 500;
  transition: opacity 0.4s;
}
.placeholder-inner { text-align: center; color: var(--text-3); }
.placeholder-inner svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: 0.4; }
.placeholder-inner p { font-size: 0.875rem; line-height: 1.6; }

/* Popup content */
.popup-title { font-family: 'Space Grotesk', sans-serif; font-size: 0.92rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.popup-row { display: flex; justify-content: space-between; gap: 16px; font-size: 0.78rem; margin-bottom: 4px; }
.popup-row span:first-child { color: var(--text-2); }
.popup-row span:last-child { color: var(--text); font-weight: 500; }
.popup-status { display: inline-flex; align-items: center; gap: 5px; }
.popup-status-dot { width: 7px; height: 7px; border-radius: 50%; }

/* Visibilité landing / app — JS toggle explicite */
#app { display: none; }
#app.visible { display: flex; }

/* Transition landing → app */
#landing { transition: opacity 0.5s ease, transform 0.5s ease; }
#landing.hide { opacity: 0; transform: scale(1.04); pointer-events: none; }

/* ══════════════════════════════════════════════
   ONBOARDING FLASHCARD
══════════════════════════════════════════════ */
#onboarding-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 16, 0.85);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.onboarding-card {
  background: linear-gradient(165deg, #0f1a30 0%, #0a1020 100%);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  width: 520px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 36px 32px 28px;
  box-shadow: 0 0 60px rgba(0, 212, 255, 0.08), 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.onboarding-header {
  text-align: center;
  margin-bottom: 28px;
}

.onboarding-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--cyan-dim);
  color: var(--cyan);
  margin-bottom: 16px;
}

.onboarding-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  color: #fff;
  margin-bottom: 6px;
}

.onboarding-sub {
  color: var(--text-2);
  font-size: 0.85rem;
}

.onboarding-body {
  display: flex; flex-direction: column; gap: 18px;
}

.onboarding-section {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
}

.onboarding-section strong {
  display: block;
  color: #fff;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.onboarding-section p {
  color: var(--text-2);
  font-size: 0.78rem;
  line-height: 1.5;
}

.onboarding-badge {
  flex-shrink: 0;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.onboarding-badge.rag {
  background: rgba(0, 212, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 212, 255, 0.25);
}

.onboarding-badge.sql {
  background: rgba(0, 255, 135, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 255, 135, 0.2);
}

.onboarding-badge.src {
  background: rgba(124, 58, 237, 0.12);
  color: #b388ff;
  border: 1px solid rgba(124, 58, 237, 0.25);
}

.onboarding-examples {
  padding: 14px 16px;
  background: rgba(0, 212, 255, 0.04);
  border: 1px solid rgba(0, 212, 255, 0.08);
  border-radius: var(--radius);
}

.example-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.example-q {
  color: var(--text-2);
  font-size: 0.8rem;
  font-style: italic;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.example-q:last-child { border-bottom: none; }

.onboarding-stats {
  display: flex; justify-content: center; gap: 32px;
  padding-top: 8px;
}

.stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--cyan);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#onboarding-close {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--cyan), #0090cc);
  color: #000;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

#onboarding-close:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

#onboarding-overlay.fade-out {
  opacity: 0;
  transition: opacity 0.35s ease;
}
