/* ============================================
   EntreGraphe - CSS Styles
   ============================================ */

/* Variables */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-card: #16161f;

  --text-primary: #f0f0f5;
  --text-secondary: #9090a0;
  --text-muted: #606070;

  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --node-company: #3b82f6;
  --node-person: #10b981;
  --link-dirigeant: #f59e0b;
  --link-beneficiaire: #ef4444;
  --link-filiale: #6366f1;

  --border-color: #2a2a35;
  --border-glow: rgba(99, 102, 241, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-secondary);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
}

/* ============================================
   App Container
   ============================================ */

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   Header
   ============================================ */

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  color: var(--accent-primary);
}

.title {
  font-size: 2rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
}

/* ============================================
   Search Section
   ============================================ */

.search-section {
  margin-bottom: 2rem;
}

.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.25rem;
  transition: all var(--transition-normal);
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.search-icon {
  width: 24px;
  height: 24px;
  margin-left: 1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  padding: 1rem;
  font-size: 1rem;
  color: var(--text-primary);
  background: transparent;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  color: white;
  transition: all var(--transition-fast);
}

.search-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}

.search-btn:active {
  transform: scale(0.98);
}

.search-btn svg {
  width: 20px;
  height: 20px;
}

/* Search Suggestions */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-lg);
}

.search-suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

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

.suggestion-item:hover {
  background: var(--bg-tertiary);
}

.suggestion-name {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.suggestion-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* API Key Section */
.api-key-section {
  max-width: 600px;
  margin: 1rem auto 0;
  text-align: center;
}

.api-key-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.api-key-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.api-key-toggle svg {
  width: 16px;
  height: 16px;
}

.api-key-form {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.api-key-form.hidden {
  display: none;
}

.api-key-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.api-key-input:focus {
  border-color: var(--accent-primary);
}

.api-key-save {
  padding: 0.75rem 1.5rem;
  background: var(--accent-gradient);
  color: white;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.api-key-save:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.api-key-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  min-height: 500px;
  position: relative;
}

/* Graph Container */
.graph-container {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.graph-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.graph-placeholder.hidden {
  display: none;
}

.placeholder-icon {
  width: 120px;
  height: 120px;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.placeholder-text {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

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

.graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Graph Nodes and Links */
.graph-node {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.graph-node:hover {
  filter: brightness(1.2);
}

.node-company {
  fill: var(--node-company);
}

.node-person {
  fill: var(--node-person);
}

.node-label {
  font-size: 11px;
  fill: var(--text-primary);
  text-anchor: middle;
  pointer-events: none;
  font-weight: 500;
}

.graph-link {
  stroke-opacity: 0.6;
  transition: stroke-opacity var(--transition-fast);
}

.graph-link:hover {
  stroke-opacity: 1;
}

.link-dirigeant {
  stroke: var(--link-dirigeant);
}

.link-beneficiaire {
  stroke: var(--link-beneficiaire);
}

.link-filiale {
  stroke: var(--link-filiale);
}

.link-actionnaire {
  stroke: #22d3ee;
}

/* Info Panel */
.info-panel {
  width: 350px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow-y: auto;
  max-height: 600px;
}

.info-panel.hidden {
  display: none;
}

.info-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.info-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.info-close svg {
  width: 18px;
  height: 18px;
}

.info-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-right: 2rem;
}

.info-content .info-siren {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-family: monospace;
}

.info-section {
  margin-bottom: 1.5rem;
}

.info-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.info-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

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

.info-item-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.info-item-value {
  font-weight: 500;
  color: var(--text-primary);
}

.info-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.info-badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.info-badge.inactive {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Explore Button in Info Panel */
.explore-btn {
  width: 100%;
  padding: 0.75rem;
  margin-top: 1rem;
  background: var(--accent-gradient);
  color: white;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.explore-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

/* Bridge Node Badge */
.info-bridge-badge {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(244, 114, 182, 0.15);
  border: 1px solid #f472b6;
  border-radius: var(--radius-sm);
  color: #f472b6;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
}

/* Info Hint */
.info-hint {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* ============================================
   Legend
   ============================================ */

.legend-section {
  margin-top: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

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

.legend-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stats-panel {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stats-panel span {
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.legend-node {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-node.node-company {
  background: var(--node-company);
}

.legend-node.node-person {
  background: var(--node-person);
}

.legend-node.node-bridge {
  background: #f472b6;
  box-shadow: 0 0 6px rgba(244, 114, 182, 0.5);
}

.legend-expand {
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  font-weight: bold;
}

.legend-expand::after {
  content: '+';
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 2px;
}

.legend-line.line-dirigeant {
  background: var(--link-dirigeant);
}

.legend-line.line-beneficiaire {
  background: var(--link-beneficiaire);
}

.legend-line.line-actionnaire {
  background: #22d3ee;
}

.legend-line.line-filiale {
  background: var(--link-filiale);
}

/* ============================================
   Footer
   ============================================ */

.footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.footer-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.footer-credit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   Loading Overlay
   ============================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  margin-top: 1rem;
  color: var(--text-secondary);
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.toast-error {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.toast.toast-success {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
  }

  .info-panel {
    width: 100%;
    max-height: 400px;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 1rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .legend-items {
    gap: 1rem;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    max-width: none;
  }
}
