/* ============================
   Context Menu & Child Report Modal — RiskTiger
   ============================ */

/* --- Context Menu (Right-Click) --- */
.ctx-menu {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  background: #1e2235;
  border: 1px solid #3b7fc7;
  border-radius: 0.6em;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 0;
  overflow: hidden;
  animation: ctx-fade-in 0.12s ease-out;
}

@keyframes ctx-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

body.light-mode .ctx-menu {
  background: #fff;
  border: 1px solid #90caf9;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.ctx-menu-header {
  padding: 0.6em 1em;
  font-size: 0.82em;
  font-weight: 700;
  color: #ffb300;
  background: rgba(59, 127, 199, 0.15);
  border-bottom: 1px solid rgba(59, 127, 199, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

body.light-mode .ctx-menu-header {
  color: #1976d2;
  background: #e3f0ff;
}

.ctx-menu ul {
  list-style: none;
  margin: 0;
  padding: 0.3em 0;
}

.ctx-menu li {
  padding: 0.55em 1em;
  font-size: 0.88em;
  cursor: pointer;
  color: #e0e0e0;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.ctx-menu li:hover {
  background: #3b7fc7;
  color: #fff;
}

body.light-mode .ctx-menu li {
  color: #23243a;
}

body.light-mode .ctx-menu li:hover {
  background: #e3f0ff;
  color: #1976d2;
}

/* --- Child Report Modal Overlay --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-bg-fade 0.2s ease-out;
}

@keyframes modal-bg-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body.light-mode .modal-overlay {
  background: rgba(0, 0, 0, 0.3);
}

/* --- Modal Container --- */
.modal-container {
  background: #1e2235;
  border: 1px solid #3b7fc7;
  border-radius: 1em;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
  width: 92vw;
  max-width: 1400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-slide-up 0.25s ease-out;
}

@keyframes modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.light-mode .modal-container {
  background: #fff;
  border: 1px solid #90caf9;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.15);
}

/* --- Modal Header --- */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8em 1.2em;
  background: linear-gradient(90deg, #1976d2 60%, #1565c0 100%);
  color: #fff;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1em;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5em;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.3em;
  border-radius: 0.3em;
  transition: background 0.15s;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Modal Body --- */
.modal-body {
  overflow: auto;
  padding: 0;
  flex: 1;
}

.modal-body .child-table {
  min-width: 800px;
}

.modal-body .loading-spinner,
.modal-body .empty-state {
  padding: 2rem;
}

/* --- Error State --- */
.error-text {
  color: #e63946 !important;
  font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .modal-container {
    width: 98vw;
    max-height: 90vh;
    border-radius: 0.6em;
  }

  .ctx-menu {
    min-width: 180px;
  }
}
